pciSample(5)

2019-08-26 17:36

BEGIN

\ \

\ \ \END

3 TEXTINCLUDE DISCARDABLE BEGIN \ \END

#endif // APSTUDIO_INVOKED

#endif // Chinese (P.R.C.) resources

/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED

///////////////////////////////////////////////////////////////////////////// //

// Generated from the TEXTINCLUDE 3 resource. //

///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED Exe

TestPciSample.cpp

// Test_PCISample.cpp : Defines the entry point for the console application.

//

#include \

#include #include #include #include #include #include

#include \

PCHAR

GetDevicePath(

IN LPGUID InterfaceGuid );

void doRead(void); void doWrite(void);

HANDLE hDevice = INVALID_HANDLE_VALUE;

int main(int argc, char* argv[]) { PCHAR DevicePath; printf(\

DevicePath = GetDevicePath((LPGUID)&PCISample_DEVINTERFACE_GUID);

hDevice = CreateFile(DevicePath,

GENERIC_READ|GENERIC_WRITE,

FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,

OPEN_EXISTING, 0,

NULL );

if (hDevice == INVALID_HANDLE_VALUE) { printf(\ return 0; } printf(\

doWrite(); doRead();

if (hDevice != INVALID_HANDLE_VALUE) { CloseHandle(hDevice); } return 0; }

PCHAR

GetDevicePath(

IN LPGUID InterfaceGuid ) {

HDEVINFO HardwareDeviceInfo;

SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;

PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData = NULL; ULONG Length, RequiredLength = 0; BOOL bResult;

HardwareDeviceInfo = SetupDiGetClassDevs( InterfaceGuid, NULL, NULL,

(DIGCF_PRESENT | DIGCF_DEVICEINTERFACE));

if (HardwareDeviceInfo == INVALID_HANDLE_VALUE) { printf(\ exit(1); }

DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);

bResult = SetupDiEnumDeviceInterfaces(HardwareDeviceInfo, 0,

InterfaceGuid, 0,

&DeviceInterfaceData);

if (bResult == FALSE) {

printf(\

SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);

exit(1); }

SetupDiGetDeviceInterfaceDetail( HardwareDeviceInfo, &DeviceInterfaceData, NULL, 0,

&RequiredLength, NULL );

DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalAlloc(LMEM_FIXED, RequiredLength);

if (DeviceInterfaceDetailData == NULL) {

SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); printf(\ exit(1); }

DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

Length = RequiredLength;

bResult = SetupDiGetDeviceInterfaceDetail( HardwareDeviceInfo, &DeviceInterfaceData, DeviceInterfaceDetailData, Length,

&RequiredLength, NULL);

if (bResult == FALSE) {

printf(\

SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); LocalFree(DeviceInterfaceDetailData); exit(1); }

return DeviceInterfaceDetailData->DevicePath; }

void doRead(void) { char buf[32],*f; ULONG nRead; int i,j; // Read data from driver printf(\ ReadFile(hDevice, buf, 32, &nRead, NULL); printf(\ // Print what was read f=buf; for (i=0;i<2;i++) { for (j=0;j<16;j++) {

fprintf(stderr, \ };

fprintf(stderr, \ }; }

void doWrite(void) { char buf[32],*f; ULONG nWritten; int i,j; for (i=0; i<32; i++) { buf[i] = i; } // Write data to driver printf(\ WriteFile(hDevice, buf, 32, &nWritten, NULL); printf(\ // Print what was written f=buf; for (i=0;i<2;i++) { for (j=0;j<16;j++) {


pciSample(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2号主变铁芯夹件接地故障处理方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: