C++Win32APIReadFile()读取文件
我们直接看一下:
# include
# include
# include
# include
void main()
{
unsigned long
char LP buffer[50]= " ";//Examda提示:file
char IP _ path[80]= " ";
getcwd(IP_path,80);
strcat(IP_path," \ \ IP . txt ");//获取资源路径
handle file = create file(IP _ path,
generic _ read,
0,
null,
open _ existing,
file _ attribute _ normal,。
if(hfile = = invalid _ handle _ value)
{
messagebox(null,“创建文件句柄时出错”,“错误”,MB _ OK);
}
intfile succ = readfile(hfile,
lpbuffer,
50,//文件中读取多少内容
& lpnumber,
null
);
close handle(hFile);
if(file succ = = 0)
{
MessageBox(null,“读取文件失败”,“错误”,MB _ OK);
}
return;
}
0条评论