| 发表于:2008-02-03 10:29:54 楼主 |
我有一dll连接库,在vb里是这样调用的 public declare function portopen lib "bc245g.dll" (byval port as long) as long dim ret as integer ret = portopen(edtcommport.text) if ret <> 1 then label1.caption = "打开串口失败" else label1.caption = "打开串口成功" end if vb里调用没问题 然后我在vc里这样调用 hinstance hmodule = loadlibrary("bc245g.dll"); if(hmodule) { typedef long int (__stdcall *portopen) (long int); portopen open = (portopen)::getprocaddress(hmodule, "portopen"); if(open) { cstring str; str.format("%d",m_port); str="没有发现com"+str+"或被占用"; m_bserialportopened[m_port-1]=true; if(open(m_port)!=1) { m_bserialportopened[m_port-1]=false; afxmessagebox(str); } } freelibrary(hmodule); hmodule = null; } else afxmessagebox("dll文件未找到!"); 这是一个打开串口的程序,其中if(open(m_port)!=1) 返回值是1,代表是成功的,但是实际上想打开的串口并没有打开,可为什么返回值还是正确的呢?请各位高手帮忙帮忙! |
|
|
|
|