带out的用法

gum 2000-07-28 01:53:00
$$$.lib 声明文件:$$$.h

$$$.h

#ifndef FT_DEFINED
#define FT_DEFINED

#ifndef FT_DLL_INTERFACE

#ifdef __cplusplus
#define FT_DLL_INTERFACE extern "C" __declspec(dllimport)
#else
#define FT_DLL_INTERFACE __declspec(dllimport)
#endif
...

FT_DLL_INTERFACE
void FT_getVersion(
OUT FT_VERSION_PT versionPt); /* software version */
...

typedef struct
{
unsigned major;
unsigned minor;
unsigned build;
}
FT_VERSION, *FT_VERSION_PT;
以上为结构等的声明。
************************************************************

void __fastcall TForm1::Button2Click(TObject *Sender)
{
1) HINSTANCE hdl;
2) FT_VERSION_PT versionPt;
3) typedef int _stdcall(*GetVersion)(FT_VERSION_PT);
4) GetVersion lpGetVersion;
5) int ddd;

6) hdl = LoadLibrary("$$$.dll");7
7) if(!hdl)
Form1->Close();
8) lpGetVersion =(GetVersion)GetProcAddress(hdl,"FT_getVersion");
9) if(lpGetVersion!=(FARPROC)NULL)
10) ddd=lpGetVersion(versionPt);
11) FreeLibrary(hdl);

}
第8行 lpGetVersion 可得到函数的指针
第10行 报告versionPt :"read of address "fffffffff""


...全文
143 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2000-08-05
  • 打赏
  • 举报
回复
哦,对了,函数声明的时候
3) typedef int _stdcall(*GetVersion)(FT_VERSION_PT);

声明成
3) typedef int _stdcall(*GetVersion)(FT_VERSION_PT *);

「已注销」 2000-08-05
  • 打赏
  • 举报
回复
将第10行改成ddd=lpGetVersion(&versionPt);
Wingsun 2000-07-28
  • 打赏
  • 举报
回复
versionPt没有初始化吧
versionPt=new FT_VERSION_PT;

13,822

社区成员

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

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