#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#define MAX 256
int main(void){
char DATA[] = "nashuidian";
HANDLE hFile;
char path[MAX] = {0};
char fileName[MAX] ={0};
DWORD dwWrite = 0;
for(int i=0 ; i<10000; ++i){
GetWindowsDirectory(path,MAX);
sprintf(fileName,"\\%d.txt",i);
lstrcat(path,fileName);
printf(" %s\n",path);
hFile = CreateFile(path,GENERIC_WRITE,FILE_SHARE_WRITE,0,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if(hFile == INVALID_HANDLE_VALUE){
printf("CreateFile failed: %d\n",GetLastError());
continue;
}
if(!WriteFile(hFile,DATA,strlen(DATA),&dwWrite,0))
printf("WriteFile failed: %d\n",GetLastError());
memset(path,0x00,MAX);
memset(fileName,0x00,MAX);
}
return 0;
}