| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2476 人关注过本帖
标题:求助delphi 调用C++ dll 求助
取消只看楼主 加入收藏
fjkk
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-10-6
收藏
 问题点数:0 回复次数:0 
求助delphi 调用C++ dll 求助

#ifndef _N_IDREADERAPI_H_
#define _N_IDREADERAPI_H_   1


#define  IDREADER_WINAPI __stdcall


#define  IDREADER_DLLEXPORT _declspec(dllexport)


    /**********************************************************************************************
    *
    * 函数名:     ReadIDCardComm
    * 功能:         读取身份证函数
    * 作者:         shz
    * 日期:         2015-6-1
    * 备注:      出参 编码为unicode 两个字节一个汉字
    *            照片解码后 会在当目录生成一个名"ZP.bmp"的身份证图片
    * 参数说明:
    *    int iPort,  COM口 是1-9 USB口是1001-1016
    *    unsigned char *ucName,  //姓名
    *    int &iNamelen,
    *    unsigned char *ucSex,   //性别
    *    int &iSexLen,
    *    unsigned char *ucIDNo,  //身份证号
    *    int &iIDNoLen,
    *    unsigned char *ucNation, //民族
    *    int &iNationLen,
    *    unsigned char *ucBirthday, //生日
    *    int &iBirthdayLen,
    *    unsigned char *ucAddress, //地址
    *    int &iAddressLen,
    *    unsigned char *ucGrantDept, //签发机关
    *    int &iGrantDeptLen,
    *    unsigned char *ucUserLifeBegin, //有效开始日期
    *    int &iUserLifeBeginLen,
    *    unsigned char *ucUserLifeEnd, //有效结尾日期
    *    int &iUserLifeEndLen,
    *    unsigned char *errMsg,  //错误信息
    *    int &iErrMsgLen,
    *    int nTimeOut           //超时时间
    * 返回值 0 成功 -1 失败 -2超时 -3取消
    *
    ***********************************************************************************************/


extern "C"  IDREADER_DLLEXPORT int IDREADER_WINAPI  ReadIDCardComm(
                          int iPort,
                          unsigned char *ucName,
                          int &iNamelen,
                          unsigned char *ucSex,
                          int &iSexLen,
                          unsigned char *ucIDNo,
                          int &iIDNoLen,
                          unsigned char *ucNation,
                          int &iNationLen,
                          unsigned char *ucBirthday,
                          int &iBirthdayLen,
                          unsigned char *ucAddress,
                          int &iAddressLen,
                          unsigned char *ucGrantDept,
                          int &iGrantDeptLen,
                          unsigned char *ucUserLifeBegin,
                          int &iUserLifeBeginLen,
                          unsigned char *ucUserLifeEnd,
                          int &iUserLifeEndLen,
                          unsigned char *errMsg,
                          int &iErrMsgLen,
                          int nTimeOut);

    /**********************************************************************************************
    *
    * 函数名:     StopReadIDCardComm
    * 功能:         取消身份证读取
    * 作者:         shz
    * 日期:         2015-6-1
    * 备注:      
    *
    ***********************************************************************************************/


extern "C"  IDREADER_DLLEXPORT void IDREADER_WINAPI StopReadIDCardComm(void);

extern "C"  IDREADER_DLLEXPORT void IDREADER_WINAPI SetPicPathComm(const char *szFilePath);

typedef struct ID_INFO
{
    char aName[50];
    char aSex[5];
    char aNation[20];
    char aBrithday[10];
    char aAddress[140];
    char ID[20];
    char aOrgan[50];
    char date[30];
    char aPassNum[20];
    char aPassCount[6];
    char aCategory[20];
}ID_INFO;
extern "C"  IDREADER_DLLEXPORT int IDREADER_WINAPI ReadIDCardCommEx (
                                                    int iPort,
                                                    ID_INFO &info,
                                                    char *errMsg,
                                                    int & iErrMsgLen,
                                                    int nTimeOut);


typedef struct FOREIGN_INFO
{
    char aEName[140];
    char aSex[20];
    char ID[40];
    char aNationCode[6];
    char aCName[30];
    char aUserLifeBegin[16];
    char aUserLifeEnd[16];
    char aBrithday[16];
    char aCardVersion[4];
    char aCategoryCode[8];
    char aCardType[50];
    char aSaveAred[6];
}FOREIGN_INFO;
extern "C"  IDREADER_DLLEXPORT int IDREADER_WINAPI ReadForeignIDCard (
                                                    int iPort,
                                                    FOREIGN_INFO &info,
                                                    char *errMsg,
                                                    int & iErrMsgLen,
                                                    int nTimeOut);

extern "C"  IDREADER_DLLEXPORT int IDREADER_WINAPI GetIDCardType (int iPort,char *errMsg);
#endif






如何用delphi 动态调用


procedure TForm1.Button1Click(Sender: TObject);
var
th:Thandle;
tp:Tfarproc;
begin
 th:= loadlibrary('Idreaderapicomm.dll'); //装载dll
 if th>0 then
 begin
 // memo1.Lines.Insert(0,'装载 Idreaderapicomm.dll 成功!');
  tp:=getprocaddress(th,pchar('ReadIDCardComm'));
  if assigned(tp) then
  begin
   memo1.Text := tp
  end;

 end
 else
 begin
  showmessage('Idreaderapicomm.dll 没有找到!');
 end;


end;


需要加什么声明。。。求助如何动态调用。。。
搜索更多相关主题的帖子: dll extern int unsigned char 
2020-02-18 03:20
快速回复:求助delphi 调用C++ dll 求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033625 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved