首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

动态库联接

2012-12-28 
动态库连接在主机插入了一个usbkey然后定义了一个DLL头文件typedef struct _UsbKeyInfo{intindexunsigned

动态库连接
在主机插入了一个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);
}

[其他解释]
Connect192KeyByATR 这个函数怎么去连接 谢谢你了
[其他解释]
和上面代码类似呀,无非就是取到Dll中函数地址,然后直接调用
[其他解释]
求代码 我是新手,刚学 谢谢了
[其他解释]
上面的代码更正一下

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);
}

[其他解释]
nGetUsbKeyHandle中不是获取了 unsigned char ATR[32];然后我想传这个参数给nConnect192KeyByATR。使得连接动态库,这个该怎么实现 
[其他解释]
USBKeyInfo info;
   int iLen = sizeof(USBKeyInfo);
   nGetUsbKeyHandle(&info,iLen);

nConnect192KeyByATR(info.ATR,32);
[其他解释]
我这样写过 ,我的工程会在nConnect192KeyByATR(info.ATR,32)这里中断
[其他解释]
这个你要看看usbkey的说明书了,看看有没有什么demo什么的,函数中参数有什么要求,参数内容分别是什么,你要找找资料。
[其他解释]
谢谢你了 , _UsbKeyInfo需要重置一下;memset(&_UsbKeyInfo, 0, sizeof(USBKeyInfo));这样才联通了
很感谢你

热点排行