Delphi调用VC++的动态库问题

hongss 2013-01-30 04:29:06
VC++给的动态库函数说明
/******************************************************************************
* Function: HV_OpenDevice
* Description: 打开设备
* Format:
* HRESULT HV_OpenDevice(int nDevId) ;
* Params:
* int nId: 设备索引
* Return:
* HV_SUCCESS: 成功; HV_NO_SUCH_DEVICE: 未找到
******************************************************************************/
HVGIGE_WP_API HRESULT __stdcall HV_OpenDevice(int nDevId);


我的调用方式
function HV_OpenDevice(nDevId: Integer):Integer;stdcall;external 'HVGigE_WP.dll' name 'HV_OpenDevice';


哪里不对啊?

运行的时候直接就弹出提示:
无法定位程序输入点 HV_OpenDevice 于动态链接库 'HVGigE_WP.dll' 上

为什么?
...全文
2588 27 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
27 条回复
切换为时间正序
请发表友善的回复…
发表回复
boneheart 2013-02-04
  • 打赏
  • 举报
回复
关于delphi调vc DLL的问题,我深入研究过。贴些已经正常工作的代码给你参考。 vc dll代码: #define DllExport __declspec(dllexport) extern "C" DllExport int ShowVideoView(HWND HParent); extern "C" DllExport HWND GetVideoViewHandle(); extern "C" DllExport void SetSelectVWinNum(int SelectWinNum); extern "C" DllExport int GetSelectVWinNum(); extern "C" DllExport void SelectVideoModel(int SelectNum); extern "C" DllExport void PlayVideo(int VideoWindowNum,LPCTSTR StreamMediaServerIP,int StreamMediaServerPort, LPCTSTR DVRIP,int DVRPort,LPCTSTR UserName,LPCTSTR PassWord,int MonitorChannelNO); extern "C" DllExport void StopVideo(int VideoWindowNum); extern "C" DllExport SetMainFormHandle3(HWND hMainForm); extern "C" DllExport bool GetSelectVWinBigFlag(int SelectWinNum); extern "C" DllExport void SetSelectVView(int SelectNum,bool SelectFlag); extern "C" DllExport void SetPTZCtrl(int ArrowNum,int ArrowStatus); 以上是在.h文件中定义dll输出函数。 对应的.cpp中。每个函数实现的代码: extern "C" DllExport SetMainFormHandle3(HWND hMainForm) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CJRVideoDLLApp* pApp = (CJRVideoDLLApp*)AfxGetApp(); pApp->m_hMainForm = hMainForm; } extern "C" DllExport bool GetSelectVWinBigFlag(int SelectWinNum) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CJRVideoDLLApp* pApp = (CJRVideoDLLApp*)AfxGetApp(); return pApp->GetVWinBigFlag(SelectWinNum); } extern "C" DllExport void SetSelectVView(int SelectNum,bool SelectFlag) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CJRVideoDLLApp* pApp = (CJRVideoDLLApp*)AfxGetApp(); pApp->SelectVView(SelectNum,SelectFlag); } extern "C" DllExport void SetPTZCtrl(int ArrowNum,int ArrowStatus) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CJRVideoDLLApp* pApp = (CJRVideoDLLApp*)AfxGetApp(); pApp->PlayWinPTZCtrl(ArrowNum,ArrowStatus); } delphi中的调用引用如下: function ShowVideoView(pHwnd:HWND): Integer;cdecl;external 'JRVideoDLL.dll'; function GetVideoViewHandle(): HWND;cdecl;external 'JRVideoDLL.dll'; function GetSelectVWinNum(): Integer;cdecl;external 'JRVideoDLL.dll'; function GetSelectVWinBigFlag(SelectWinNum:Integer):Boolean;cdecl;external 'JRVideoDLL.dll'; procedure SelectVideoModel(SelectNum:Integer);cdecl;external 'JRVideoDLL.dll'; procedure PlayVideo(VideoWindowNum:Integer; StreamMediaServerIP:String; StreamMediaServerPort:integer; DVRIP:String; DVRPort:integer; UserName:String; PassWord:String; MonitorChannelNO:integer);cdecl;external 'JRVideoDLL.dll'; procedure StopVideo(VideoWindowNum:Integer);cdecl;external 'JRVideoDLL.dll'; procedure SetMainFormHandle3(hMainForm:HWND);cdecl;external 'JRVideoDLL.dll'; procedure SetSelectVWinNum(SelectWinNum:Integer);cdecl;external 'JRVideoDLL.dll'; procedure SetSelectVView(SelectNum:Integer;SelectFlag:Boolean);cdecl;external 'JRVideoDLL.dll'; procedure SetPTZCtrl(ArrowNum:Integer;ArrowStatus:Integer);cdecl;external 'JRVideoDLL.dll'; 这些代码是一个视频监控平台的代码,已经正常工作了7,8年时间了。到现在程序还在24小时跑着。你自己对照着看看哪里出的错。仅供参考。
wzwind 2013-02-04
  • 打赏
  • 举报
回复
这样的帖子置顶了~~~~~~~ extern "C" 。。。
hsfzxjy 2013-02-01
  • 打赏
  • 举报
回复
呵,祝楼主成功!
terran_ye 2013-02-01
  • 打赏
  • 举报
回复
c++那边 extern "C"
零-点 2013-01-31
  • 打赏
  • 举报
回复
用工具查看一下函数名是不是不对
hsfzxjy 2013-01-31
  • 打赏
  • 举报
回复
用另一些反编译软件也行
hongss 2013-01-31
  • 打赏
  • 举报
回复
引用 8 楼 feiba7288 的回复:
修改下参数的传递方式看下,stdcall --> cdecl
不行。。。问题依旧
feiba7288 2013-01-31
  • 打赏
  • 举报
回复
修改下参数的传递方式看下,stdcall --> cdecl
hongss 2013-01-31
  • 打赏
  • 举报
回复
至于DLL版本,这个是最新的,而且,这个DLL在VC中调用是成功的。。。改到Delphi就不行了,烦躁!!
hongss 2013-01-31
  • 打赏
  • 举报
回复

这是Depends查看到的函数名。。。
编译后的函数名都是带修饰的,这个怎么办?
山东蓝鸟贵薪 2013-01-31
  • 打赏
  • 举报
回复
努力学习中
feiba7288 2013-01-31
  • 打赏
  • 举报
回复
你的dll版本不是最新的,找厂商要拿最新的
hongss 2013-01-31
  • 打赏
  • 举报
回复
好了,只能这么用了,谢谢各位! 年前还要赶工,年终奖在哪~~~~~~
hongss 2013-01-31
  • 打赏
  • 举报
回复
引用 20 楼 sgzhou12345 的回复:
应该是 接口 没有做好吧
应该是,但人家咬死这个库在他们的VC里可以正常使用。。。NND
山东蓝鸟贵薪 2013-01-31
  • 打赏
  • 举报
回复
应该是 接口 没有做好吧
hsfzxjy 2013-01-31
  • 打赏
  • 举报
回复

type
  PHVGigE_Dev_i = ^_HVGIGE_DEV_I;
  _HVGIGE_DEV_I = record
    pName: PChar;
    pDescription: PChar;
    pSrcMacSddr: PByte;
    pNext: PHVGIGE_DEV_I; 
  end;
  HVGIGE_DEV_I = _HVGIGE_DEV_I; 
hongss 2013-01-31
  • 打赏
  • 举报
回复
type
  _HVGIGE_DEV_I = record
    pName: PChar;
    pDescription: PChar;
    pSrcMacSddr: PByte;
    pNext: ^_HVGIGE_DEV_I; 
//  [Error] UnitDLL.pas(47): Type '_HVGIGE_DEV_I' is not yet completely defined 
  end;
  HVGIGE_DEV_I = _HVGIGE_DEV_I;
  PHVGigE_Dev_i = ^_HVGIGE_DEV_I; 
hsfzxjy 2013-01-31
  • 打赏
  • 举报
回复
sorry,打错了,把^放到前面,即_HVGIGE_DEV_I^改成^_HVGIGE_DEV_I
hongss 2013-01-31
  • 打赏
  • 举报
回复
type
  _HVGIGE_DEV_I = record
    pName: PChar;
    pDescription: PChar;
    pSrcMacSddr: PByte;
    pNext: _HVGIGE_DEV_I^;
//  [Error] UnitDLL.pas(47): Type '_HVGIGE_DEV_I' is not yet completely defined
//  [Error] UnitDLL.pas(47): ';' expected but '^' found
  end;
  HVGIGE_DEV_I = _HVGIGE_DEV_I;
  PHVGigE_Dev_i = _HVGIGE_DEV_I^;
//  [Error] UnitDLL.pas(50): ';' expected but '^' found
hsfzxjy 2013-01-31
  • 打赏
  • 举报
回复
typedef struct _HVGIGE_DEV_I { CHAR * pName; //设备GUID CHAR * pDescription; //设备描述符 BYTE * pSrcMacSddr; struct _HVGIGE_DEV_I * pNext; //指向下一个设备的指针 }HVGigE_Dev_i, *pHVGigE_Dev_i; 等价于: type _HVGIGE_DEV_I=record pName,pDescription:PChar; pSrcMacSddr:PBYTE; pNext:_HVGIGE_DEV_I^; end; HVGigE_DEV_I=_HVGIGE_DEV_I; PHVGIGE_Dev_I=_HVGIGE_DEV_I^;
加载更多回复(7)

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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