代码
#include <windows.h>
#include <tchar.h>
int _tmain(int argc,LPTSTR argv[])
{
HANDLE hFile = CreateFile(TEXT("d:\\test.txt"),
GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD writeBytes = 0;
PTSTR text = TEXT("hello,world");
DWORD len = strlen(text);
WriteFile(hFile,text,len,&writeBytes,NULL);
CloseHandle(hFile);
}
}
#include <tchar.h>
int _tmain(int argc,LPTSTR argv[])
{
HANDLE hFile = CreateFile(TEXT("d:\\test.txt"),
GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD writeBytes = 0;
PTSTR text = TEXT("hello,world");
DWORD len = strlen(text);
WriteFile(hFile,text,len,&writeBytes,NULL);
CloseHandle(hFile);
}
}