我是 C++ 新手,我希望我的应用程序在执行时能够 self 复制一次或两次。我在这个论坛上搜索过这个主题,但没有运气。所以我希望我没有挖掘已经讨论过的东西。到目前为止我得到的代码如下,我只是在尝试并尝试看看我可以在 C++ 中做哪些不同的事情 - 我正在制作的程序没有实际用途。 到目前为止我得到的代码如下。
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>
#include <fstream.h>
void main()
{
int id;
cout << "Hello\n";
cin >> id;
cout << "Testing" << id << endl;
int i=0;
do
{
i++;
fstream feck ("lucinada.doc", fstream::in | fstream::out);
feck << "testing";
24
}while(i<100);
int j=0;
do
{
j++;
fstream feck ("ludacris.doc", fstream::in | fstream::out);
feck << "testing";
}while(j<100);
int k=2;
do
{
k++;
fstream feck ("400l.doc", fstream::in | fstream::out);
feck << "testing";}while(k<100);}
如何将我的应用程序 .exe 复制到多个路径。
提前致谢
最佳答案
使用 GetModuleFileName 获取可执行文件的路径然后使用 CopyFile 复制它.
当然,这个解决方案只能在 Windows 下工作,但就文件系统操作而言,您始终必须为每个操作系统实现它们(除非您使用 boost::filesystem 之类的东西)。
关于c++ - 如何在 C++ 中使 .Exe 复制自身?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37434012/