演示代码:

将WINDOWS系统目录写入TXT文件
 1 /*header file*/
 2 #include <Windows.h>
 3 
 4 int main(int argc,TCHAR argv[])
 5 {
 6     //file handle
 7     HANDLE hFile;
 8     DWORD dwWritten;
 9     //char array ,store system dir
10     TCHAR szSystemDir[MAX_PATH];
11     //get system dir
12     GetSystemDirectory(szSystemDir,MAX_PATH);
13 
14     //make file systemroot.txt
15     hFile = CreateFile("systemroot.txt",
16         GENERIC_WRITE,
17     0,NULL,CREATE_ALWAYS,
18     FILE_ATTRIBUTE_NORMAL,
19     NULL);
20     //IF the create file
21     if(hFile != INVALID_HANDLE_VALUE)
22     {
23         //write the system dir info to file
24         if(!WriteFile(hFile,szSystemDir,lstrlen(szSystemDir),&dwWritten,NULL))
25         {
26             return GetLastError();
27         }
28     }
29     CloseHandle(hFile);
30     return 0;
31 
32 }
将WINDOWS系统目录写入TXT文件

 

运行效果:

将WINDOWS系统目录写入TXT文件

相关文章:

  • 2021-08-17
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-04
  • 2021-11-30
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
相关资源
相似解决方案