1 //拷贝文件
2 void copy()
3 {
4 //自身路径
5 char selfpath[256] = { 0 };
6 //Windows路径
7 char windowpath[256] = { 0 };
8 //系统路径
9 char systempath[256] = { 0 };
10
11 //获取自身路径
12 GetModuleFileNameA(NULL, selfpath, 256);
13 //获取Windows路径
14 GetWindowsDirectoryA(windowpath, 256);
15 //获取系统路径
16 GetSystemDirectoryA(systempath, 256);
17 strcat(windowpath, "\test.exe");
18 strcat(systempath, "\test.exe");
19 //输出目录
20 printf("%s
", selfpath);
21 printf("%s
", windowpath);
22 printf("%s
", systempath);
23 //拷贝函数
24 CopyFileA(selfpath, windowpath, FALSE);
25 }