动态库连接
在主机插入了一个usbkey
然后定义了一个DLL头文件
typedef struct _UsbKeyInfo
{
int index;
unsigned char ATR[32];
} USBKeyInfo;
typedef int (*Connect192KeyByATR)(BYTE* ATR,int ATRLen);
typedef int (*GetUsbKeyHandle)(USBKeyInfo* pInfo,int Len);
怎么获取UsbKeyInfo 和连接动态库
求高手 求代码
[最优解释]
HINSTANCE hinstDLL = LoadLibrary((LPCTSTR)"XXX.dll");
if(hinstDLL)
{
GetUsbKeyHandle nGetUsbKeyHandle = NULL;
nGetUsbKeyHandle = (GetUsbKeyHandle )GetProcAddress(hinstDLL, "xxx");
if(nGetUsbKeyHandle)
{
USBKeyInfo info;
int iLen = 0;
nGetUsbKeyHandle(&info,iLen);
}
::FreeLibrary(hinstDLL);
}
HINSTANCE hinstDLL = LoadLibrary((LPCTSTR)"XXX.dll");
if(hinstDLL)
{
GetUsbKeyHandle nGetUsbKeyHandle = NULL;
nGetUsbKeyHandle = (GetUsbKeyHandle )GetProcAddress(hinstDLL, "xxx");
if(nGetUsbKeyHandle)
{
USBKeyInfo info;
int iLen = sizeof(USBKeyInfo);
nGetUsbKeyHandle(&info,iLen);
}
::FreeLibrary(hinstDLL);
}
HINSTANCE hinstDLL = LoadLibrary((LPCTSTR)"XXX.dll");
if(hinstDLL)
{
Connect192KeyByATR nConnect192KeyByATR = NULL;
nConnect192KeyByATR = (Connect192KeyByATR )GetProcAddress(hinstDLL, "???相应dll中的函数名");
if(nConnect192KeyByATR )
{
nConnect192KeyByATR(,);你需要传的参数(我也知道你是什么参数)
}
::FreeLibrary(hinstDLL);
}