请大家给指点下 该用什么连接库文件 有完整代码
这个是chris cant写的设备驱动程序开发指南当中的WDM1的EXE程序,可我却无法把它编译成功,一直提示连接错误 我实在不知道该用什么连接库头文件 请大家指点一下把
附件有完整的头文件和程序代码 请哪位老大给看编译一下把 看看缺什么连接头文件 谢谢大家了
-------------------------------这个是错误编译提示
Compiling...
Wdm1Test.cpp
Linking...
Wdm1Test.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailA@24
Wdm1Test.obj : error LNK2001: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4
Wdm1Test.obj : error LNK2001: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20
Wdm1Test.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetClassDevsA@16
Debug/452.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
452.exe - 5 error(s), 0 warning(s)
------------------------------------------------这个是主要CPP文件--
#include "windows.h"
#include "setupapi.h"
#include "stdio.h"
#include "initguid.h"
#include "winioctl.h"
#include "Ioctl.h"
#include "GUIDs.h"
HANDLE GetDeviceViaInterface( GUID* pGuid, DWORD instance);
int main(int argc, char* argv[])
{
int TestNo = 1;
printf("\nWdm1Test\n");
/////////////////////////////////////////////////////////////////////////
// Open device
printf("\1111nTest %d\n",TestNo++);
HANDLE hWdm1 = GetDeviceViaInterface((LPGUID)&WDM1_GUID,0);
if( hWdm1==NULL)
{
printf("3333XX Could not find open Wdm1 device\n");
return 1;
}
printf(" Opened OK\n");
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// 获得设备接口句柄函数GetDeviceViaInterface: Open a handle via a device interface
HANDLE GetDeviceViaInterface( GUID* pGuid, DWORD instance)
{
// Get handle to relevant device information set
HDEVINFO info = SetupDiGetClassDevs(pGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
if(info==INVALID_HANDLE_VALUE)
{
printf("No HDEVINFO available for this GUID\n");
return NULL;
}
// Get interface data for the requested instance
SP_INTERFACE_DEVICE_DATA ifdata;
ifdata.cbSize = sizeof(ifdata);
if(!SetupDiEnumDeviceInterfaces(info, NULL, pGuid, instance, &ifdata))
{
printf("No SP_INTERFACE_DEVICE_DATA available for this GUID instance\n");
SetupDiDestroyDeviceInfoList(info);
return NULL;
}
// Get size of symbolic link name
DWORD ReqLen;
SetupDiGetDeviceInterfaceDetail(info, &ifdata, NULL, 0, &ReqLen, NULL);
PSP_INTERFACE_DEVICE_DETAIL_DATA ifDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)(new char[ReqLen]);
if( ifDetail==NULL)
{
SetupDiDestroyDeviceInfoList(info);
return NULL;
}
// Get symbolic link name
ifDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
if( !SetupDiGetDeviceInterfaceDetail(info, &ifdata, ifDetail, ReqLen, NULL, NULL))
{
SetupDiDestroyDeviceInfoList(info);
delete ifDetail;
return NULL;
}
printf("Symbolic link is %s\n",ifDetail->DevicePath);
// Open file
HANDLE rv = CreateFile( ifDetail->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if( rv==INVALID_HANDLE_VALUE) rv = NULL;
delete ifDetail;
SetupDiDestroyDeviceInfoList(info);
return rv;
}
wdm.1.rar
(34.95 KB)