![]() ![]() |
|
C++Win32APIReadFile()读取文件 | |
作者:佚名 文章来源:不详 点击数 更新时间:2008/11/1 20:41:16 文章录入:杜斌 责任编辑:杜斌 | |
|
|
#include <iostream.h> #include <Windows.h> #include <direct.h> #include <stdlib.h> #include <stdio.h> void main() { unsigned long lpNumber=0; char lpBuffer[50]="";//Examda提示:文件读取的内容 char IP_path[80]=""; getcwd(IP_path,80); strcat(IP_path,"\\IP.txt");//获得资源路径 HANDLE hFile= CreateFile(IP_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if(hFile==INVALID_HANDLE_VALUE) { MessageBox(NULL,"创建文件句柄出错","error",MB_OK); } int filesucc=ReadFile(hFile, lpBuffer, 50,//读取文件中多少内容 &lpNumber, NULL ); CloseHandle(hFile); if(filesucc==0) { MessageBox(NULL,"读取文件失败","error",MB_OK); } return; } http://ks.examda.com |
|
![]() ![]() |