本文共 798 字,大约阅读时间需要 2 分钟。
演示代码:
1 /*header file*/ 2 #include3 4 int main(int argc,TCHAR argv[]) 5 { 6 //file handle 7 HANDLE hFile; 8 DWORD dwWritten; 9 //char array ,store system dir10 TCHAR szSystemDir[MAX_PATH];11 //get system dir12 GetSystemDirectory(szSystemDir,MAX_PATH);13 14 //make file systemroot.txt15 hFile = CreateFile("systemroot.txt",16 GENERIC_WRITE,17 0,NULL,CREATE_ALWAYS,18 FILE_ATTRIBUTE_NORMAL,19 NULL);20 //IF the create file21 if(hFile != INVALID_HANDLE_VALUE)22 {23 //write the system dir info to file24 if(!WriteFile(hFile,szSystemDir,lstrlen(szSystemDir),&dwWritten,NULL))25 {26 return GetLastError();27 }28 }29 CloseHandle(hFile);30 return 0;31 32 }
运行效果:
转载地址:http://dnsno.baihongyu.com/