writefile的使用
#include"windows.h"main(){HANDLEfileHandle;fileHandle=CreateFile("d:\\Hello.txt",GENE...
#include "windows.h"
main()
{
HANDLE fileHandle;
fileHandle=CreateFile("d:\\Hello.txt",GENERIC_WRITE,FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
char data="http://www.baidu.com/";
DWORD a;
unsigned long b;
OVERLAPPED * c;
WriteFile(fileHandle,data,a,0,c);
}
编译可以通过,运行不了。 展开
main()
{
HANDLE fileHandle;
fileHandle=CreateFile("d:\\Hello.txt",GENERIC_WRITE,FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
char data="http://www.baidu.com/";
DWORD a;
unsigned long b;
OVERLAPPED * c;
WriteFile(fileHandle,data,a,0,c);
}
编译可以通过,运行不了。 展开
1个回答
展开全部
#include "windows.h"
#include "iostream"
int main()
{
HANDLE fileHandle;
fileHandle=CreateFile("d:\\Hello.txt", GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
//如果使用OPEN_EXISTING则不会创建文件
if(fileHandle == INVALID_HANDLE_VALUE)
return 1;
char *data="http://www.baidu.com/";
DWORD a = 25;
unsigned long b;
OVERLAPPED c;
WriteFile(fileHandle, data, a, &b, NULL);
return 0;
}
参考资料:解读VC++编程中的文件操作API和CFile类
#include "iostream"
int main()
{
HANDLE fileHandle;
fileHandle=CreateFile("d:\\Hello.txt", GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
//如果使用OPEN_EXISTING则不会创建文件
if(fileHandle == INVALID_HANDLE_VALUE)
return 1;
char *data="http://www.baidu.com/";
DWORD a = 25;
unsigned long b;
OVERLAPPED c;
WriteFile(fileHandle, data, a, &b, NULL);
return 0;
}
参考资料:解读VC++编程中的文件操作API和CFile类
参考资料: http://news.newhua.com/html/VC/2006-3/6/06361049276603_58_2.shtml
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询