//1.加上定义
/*
typedef struct struct_MY{
int x;
int y;
} Point;
typedef void *HANDLE;
*/
DWORD b=0;
HANDLE h;
Point ptSave;
Point ptFileIn;
ptSave.x=100;
ptSave.y=200;
char * inMessage="Hello this is in string"; //输入
char outMessage[255]; //输出
memset(outMessage,0,255);
/*
//存入字符串
h=CreateFile(L"abc1.txt",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(h,inMessage,strlen(inMessage),&b,NULL);
//WriteFile(h,&pt,sizeof(Point),&b,NULL);
CloseHandle(h);
//read file
h=CreateFile(L"abc1.txt",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
ReadFile(h, outMessage, 255, &b, NULL);
printf("%s",outMessage);
CloseHandle(h);
*/
//存入结构体
h=CreateFile(L"point1.txt",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(h,&ptSave,sizeof(ptSave),&b,NULL);
CloseHandle(h);
h=CreateFile(L"point1.txt",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ReadFile(h, (char *)&ptFileIn, sizeof(Point), &b, NULL);
printf("点x=%d,y=%d/n",ptFileIn.x,ptFileIn.y);
CloseHandle(h);