嘿,我希望有人可以告诉我知道解决这个问题我正在从Visual Studio获取错误2019以获取以下文件。现在大部分功能已被删除,所以请原谅空的varriables等。
错误错误LNK2019:未解析的外部符号“void * __cdecl OpenOneDevice(void *,struct _SP_DEVICE_INTERFACE_DATA *,char *)”(?OpenOneDevice @@ YAPAXPAXPAU_SP_DEVICE_INTERFACE_DATA @@ PAD @ Z)在函数_wmain中引用c:\ Users \ K \ documents \ visual studio 2010 \ Projects \ test2 \ test2 \ test2.obj test2
#include "stdafx.h"
#include <windows.h>
#include <setupapi.h>
SP_DEVICE_INTERFACE_DATA deviceInfoData;
HDEVINFO hwDeviceInfo;
HANDLE hOut;
char *devName;
//
HANDLE OpenOneDevice(IN HDEVINFO hwDeviceInfo,IN PSP_DEVICE_INTERFACE_DATA DeviceInfoData,IN char *devName);
//
HANDLE OpenOneDevice(IN HDEVINFO HardwareDeviceInfo,IN PSP_DEVICE_INTERFACE_DATA DeviceInfoData,IN char *devName) {
PSP_DEVICE_INTERFACE_DETAIL_DATA functionClassDeviceData = NULL;
ULONG predictedLength = 0, requiredLength = 0;
HANDLE hOut = INVALID_HANDLE_VALUE;
SetupDiGetDeviceInterfaceDetail(HardwareDeviceInfo, DeviceInfoData, NULL, 0, &requiredLength, NULL);
predictedLength = requiredLength;
functionClassDeviceData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(predictedLength);
if(NULL == functionClassDeviceData) {
return hOut;
}
functionClassDeviceData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail(HardwareDeviceInfo, DeviceInfoData, functionClassDeviceData,
predictedLength, &requiredLength, NULL)) {
free( functionClassDeviceData );
return hOut;
}
//strcpy(devName,functionClassDeviceData->DevicePath) ;
hOut = CreateFile(functionClassDeviceData->DevicePath, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
free(functionClassDeviceData);
return hOut;
}
//
int _tmain(int argc, _TCHAR* argv[])
{
hOut = OpenOneDevice (hwDeviceInfo, &deviceInfoData, devName);
if(hOut != INVALID_HANDLE_VALUE)
{
// error report
}
return 0;
}
让我疯了几个小时。任何帮助表示赞赏。
感谢克里斯: - )
添加#pragma comment(lib,“Setupapi.lib”)
由于