Windows API之ReadFile的用法实例

char szReadBlock[1024] = {
      0 } ;
DWORD dwNumberOfBytesTransffered = 0 ;
OVERLAPPED overlapped ;
memset(&overlapped, 0, sizeof(overlapped));
if(ReadFile(m_hReadHandle, szReadBlock, sizeof(szReadBlock),
 &dwNumberOfBytesTransffered, &overlapped))
 //m_hReadHandle为全局变量

ReadFile的第一个参数m_hReadHandle的定义为

m_hReadHandle=CreateFile(MyDevPathName, 
				GENERIC_READ,
				FILE_SHARE_READ|FILE_SHARE_WRITE, 
				NULL, 
				OPEN_EXISTING, 
				FILE_FLAG_OVERLAPPED,
				NULL) ;

MyDevPathName的定义为

Result = SetupDiGetDeviceInterfaceDetail(hDevInfoSet, &DevInterfaceData, 
                               pDevDetailData, RequiredSize, NULL, NULL) ;
_tcscpy(MyDevPathName, pDevDetailData->DevicePath);

你可能感兴趣的:(编程高级进阶)