DLL调用,实时错误“49”:DLL调用约定错误

tongfeng1981 2010-11-28 11:07:31
小弟做一个摄像头控制程序,需要调用摄像头厂家给的DLL,厂家给的VC.NET函数声明如下:
extern "C"
{

//how to enumerate multi-device, and select one to handle.
//first enumerate devices that are connecting to the PC(call GetVMCUVCDevCount()s).
//if you would like to print the device name string (call GetDevFriendlyNameByIndex())
//second, attach the special device you like.(using AttachUVCDeviceByIndex() function)
//end, detach all device(using DetachUVCDeviceALL())
DECLDIR ULONG GetVMCUVCDevCount();
DECLDIR ULONG GetDevFriendlyNameByIndex(ULONG iIndex,TCHAR *DevName, ULONG DevNamesize);
DECLDIR BOOL AttachUVCDeviceByIndex(ULONG iIndex);
DECLDIR VOID DetachUVCDeviceALL();

//TRUE for a successful call, FALSE for any error.
//1 for Pressing the Snapshot key, 0 for no operation.
DECLDIR BOOL GetSnapShotStatus(BYTE *SnapShotbStatus);
}
我在VB中声明如下:
Private Declare Function GetSnapShotStatus Lib "UVCXUControl.dll" (ByRef Parm As Long) As Boolean
Private Declare Function GetVMCUVCDevCount Lib "UVCXUControl.dll" () As Long
Private Declare Function AttachUVCDeviceByIndex Lib "UVCXUControl.dll" (ByVal iIndex As Long) As Boolean
Private Declare Sub DetachUVCDeviceALL Lib "UVCXUControl.dll" ()
其中GetVMCUVCDevCount 可用,调用GetSnapShotStatus 时一直提醒实时错误“49”:DLL调用约定错误,
望高人帮忙解决!
谢谢
...全文
693 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
oldnebula 2010-12-02
  • 打赏
  • 举报
回复
直接生成应用程序就不会有错误提示了。
myjisgreat 2010-11-28
  • 打赏
  • 举报
回复
vc的dll中需要把调用模式设为_stdcall才能让vb调用
比如函数:
void add (int a ,int b)
就无法在VB中调用
要改为:
void add _stdcall (int a ,int b)

但我不知道.net有神马变化
lyserver 2010-11-28
  • 打赏
  • 举报
回复
Private Declare Function GetSnapShotStatus Lib "UVCXUControl.dll" (ByRef Parm As Long) As Boolean
改成
Private Declare Function GetSnapShotStatus Lib "UVCXUControl.dll" (ByVal lpParm As Long) As Boolean
这里lpParm表示一个指针,即BYTE *SnapShotbStatus,使用varptr获得。
也可以改成
Private Declare Function GetSnapShotStatus Lib "UVCXUControl.dll" (ByRef lpBytes As Byte) As Boolean
world_broken 2010-11-28
  • 打赏
  • 举报
回复
Private Declare Function AttachUVCDeviceByIndex Lib "UVCXUControl.dll" (ByVal iIndex As Long) As Boolean
bool 对应改成 long 而不是boolean
另外
DECLDIR ULONG GetDevFriendlyNameByIndex(ULONG iIndex,TCHAR *DevName, ULONG DevNamesize);
DECLDIR ULONG GetVMCUVCDevCount();

ulong 对应参数传递均可声明 x as double, 传进去 varptr(x),vb 中并没有ULONG这个类型,传地址吧,函数返回则应该声明成long

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧