DLL中未定义的函数指针 [英] Undefined function pointer in DLL

查看:65
本文介绍了DLL中未定义的函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我的问题是我得到标识符是未定义的问题,尽管定义它。这是情况的背景:



 ... 
typedef WINSETUPAPI BOOL(* SetupDiEnumDeviceInterfacesUMPTR)(HDEVINFO,PSP_DEVINFO_DATA,LPGUID,DWORD,PSP_DEVICE_INTERFACE_DATA);
...
class DLL
{
public
DLL()
{
...
SetupDiEnumDeviceInterfacesUMPTR _SetupDiEnumDeviceInterfacesUMPTR;
...
HINSTANCE hSetUpApi = LoadLibrary( setupapi.dll) ;
...
_SetupDiEnumDeviceInterfacesUMPTR =(SetupDiEnumDeviceInterfacesUMPTR)GetProcAddress(hSetUpApi, SetupDiEnumDeviceInterfaces);
...
}
...
if (_ SetupDiEnumDeviceInterfacesUMPTR(DeviceInfoTable,NULL,& InterfaceClassGuid,InterfaceIndex) ,InterfaceDataStructure)) // _SetupDiEnumDeviceInterfacesUMPTR undefined
...
}





感谢您的帮助。

解决方案

_SetupDiEnumDeviceInterfacesUMPTR <当你到达if语句时,/ code>超出了范围 - 它是在 DLL()的大括号内定义的



此处说明...

http:// www.tutorialspoint.com/cplusplus/cpp_variable_scope.htm [ ^ ]

Hello. My problem is i get identifier is undefined problem despite defining it. Here''s the context of the situation:

...
typedef WINSETUPAPI BOOL (*SetupDiEnumDeviceInterfacesUMPTR)(HDEVINFO, PSP_DEVINFO_DATA, LPGUID, DWORD, PSP_DEVICE_INTERFACE_DATA);
...
class DLL
{ 
  public:
         DLL()
         {
             ...
             SetupDiEnumDeviceInterfacesUMPTR _SetupDiEnumDeviceInterfacesUMPTR;
             ...
             HINSTANCE hSetUpApi = LoadLibrary("setupapi.dll");
             ...
             _SetupDiEnumDeviceInterfacesUMPTR = (SetupDiEnumDeviceInterfacesUMPTR)GetProcAddress(hSetUpApi, "SetupDiEnumDeviceInterfaces");
             ...
         }
         ...
         if(_SetupDiEnumDeviceInterfacesUMPTR(DeviceInfoTable, NULL, &InterfaceClassGuid, InterfaceIndex, InterfaceDataStructure)) // _SetupDiEnumDeviceInterfacesUMPTR undefined
         ...
}



Thanks for help.

解决方案

_SetupDiEnumDeviceInterfacesUMPTR is out of scope by the time you get to the if statement - it''s defined inside the braces of DLL()

Explanation here ...
http://www.tutorialspoint.com/cplusplus/cpp_variable_scope.htm[^]


这篇关于DLL中未定义的函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆