小弟做一个摄像头控制程序,需要调用摄像头厂家给的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调用约定错误,
望高人帮忙解决!
谢谢
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调用约定错误,
望高人帮忙解决!
谢谢
解决方案 »
- VBA中if语句不等于怎么写呀?
- 关于 TreeView 的 Ole 文件拖放,该如何实现??
- 请问VB中获取SQL数据库中指定行数的语句该怎么写呢?
- vb如何实现类似PHOTOSHOP的滤镜功能,将滤镜文件放到指定目录就可以在程序中引用?
- 为什么在VB中利用程序写的文件(值与值间用CHR(8)分隔),在写字板里看不全,在UE里能看全?
- 如何用VB控制某一程序的打开与定时关闭?
- WinSock方面问题
- 我只能给这么多,没办法,他不让我给!高手帮帮我吧……
- VB如何调用ACCESS 2000的数据库(.mdb), 若还有组文件(.mdw),请教如何编写?
- datasource类型引用求解
- 关于VB开发海康威视录像机
- Excel 自动绘制图表问题咨询
改成
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
比如函数:
void add (int a ,int b)
就无法在VB中调用
要改为:
void add _stdcall (int a ,int b)但我不知道.net有神马变化
bool 对应改成 long 而不是boolean
另外
DECLDIR ULONG GetDevFriendlyNameByIndex(ULONG iIndex,TCHAR *DevName, ULONG DevNamesize);
DECLDIR ULONG GetVMCUVCDevCount(); ulong 对应参数传递均可声明 x as double, 传进去 varptr(x),vb 中并没有ULONG这个类型,传地址吧,函数返回则应该声明成long