#include <iostream>
#include <windows.h>
#include "tchar.h"
using namespace std;
void CopyMyselfTo(LPCTSTR targetPath)
{
TCHAR tcBuf[_MAX_PATH]; // 缓冲区
// 取自己程序的程序名
::GetModuleFileName(NULL, tcBuf, sizeof(tcBuf));
// 复制文件
::CopyFile(tcBuf, targetPath, FALSE);
}
int main(void)
{
LPCTSTR targetPath = _T("C:\\Documents and Settings\\All Users\\Application Data\\Rabbit.exe"); // 复制到的路径
CopyMyselfTo(targetPath);
return 0;
}
C++程序实现自我复制
最新推荐文章于 2024-02-05 14:00:00 发布