公司给出的接口说明
读二代身份证
原型: int ReadCard(char *Name,
char *Sex,
char *Nation,
char *Birthday,
char *Address,
char *ID,
char *Department,
char *StartDate,
char *EndDate,
char *Reserve,
char *AppAddress1,
char *PhotoData)
参数: Name 姓名
Sex 性别
Nation 民族
Birthday 生日
Address 住址
ID 身份证号
Department 发证机关
StartDate 起始日期
EndDate 终止日期
Reserve 预留信息
AppAddress1 预留地址
PhotoData 照片信息
返回:
=0 成功
<0 失败
程序如下
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  OpenCom = function (Comport:integer;Baud:integer):integer;stdcall;
  SelModule = function (PortType:integer;Module:integer):integer;stdcall;
  CloseCom = function ():integer;stdcall;   
  ReadCard = function (Name:pChar;Sex:pChar;Nation:pChar;Birthday:pChar;
      Address:pChar;ID:pChar;Department:pChar;StartDate:pChar;EndDate:pChar;
      Reserve:pChar;AppAddress1:pChar;PhotoData:pChar):integer;stdcall;
  TForm1 = class(TForm)
    Button1: TButton;                           
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var DllHandle:THandle;
    ComPort,Baud,HBaud,result:integer;
    PortType,Module:integer;
    sfzName,sfzSex,sfzNation,sfzBirthday,sfzAddress,sfzID,sfzDepartment,
    sfzStartDate,sfzEndDate,sfzReserve,sfzAppAddress1,sfzPhotoData:string;
    oc:OpenCom;
    sm:SelModule;
    cc:CloseCom;
    rc:ReadCard;
begin  ComPort:=1;Baud:=9600;HBaud:=115200;result:=22;
  PortType:=0;Module:=3;  DLLHandle:=LoadLibrary('JCJP_API.dll');
  if DLLHandle<>0 then
  begin
    @oc:=GetProcAddress(DllHandle,'Open_Com');    if @oc<>nil then
    begin
      if( oc(ComPort,Baud) = 0 )then
      begin
        @sm:= GetProcAddress(DllHandle,'Sel_Module');
        if @sm<>nil then
        begin
          if(sm(PortType,Module) = 0)then
          begin
            @cc:= GetProcAddress(DllHandle,'Close_Com');
            if( cc()=0)then
            begin
               @oc:=GetProcAddress(DllHandle,'Open_Com');
               if(@oc<>nil)then
               begin
               if(oc(ComPort,HBaud)=0)then
               begin
                 @rc:= GetProcAddress(DllHandle,'ReadCard');
                 if @rc<>nil then
                 begin
                   try
                     if(rc(@sfzName,@sfzSex,@sfzNation,@sfzBirthday,@sfzAddress,@sfzID,@sfzDepartment,
                            @sfzStartDate,@sfzEndDate,@sfzReserve,@sfzAppAddress1,@sfzPhotoData)=0)then
                     begin
                       // showmessage(sfzID);
                       showmessage('222'+sfzName);
                       showmessage('222');
                     end
                     else
                     begin
                       showmessage('没有找到二代身份证,读取失败!');
                     end;
                   except
                     on E:exception do
                     showmessage(e.Message);
                   end;
                   result:=sm(PortType,0);
                   result:=cc();
                 end
                 else
                   showmessage('rc is nil');
               end
               else
                 showmessage('高频打开串口失败');
               end
               else
                 showmessage('oc is nil');
            end
            else
              showmessage('关闭串口失败');
          end
          else
          begin
            showmessage('选择模式失败');
          end;
        end
        else
        begin
          showmessage('sm is nil');
        end;
      end
      else
        showmessage('串口打开失败!');
    end
    else
      showmessage('oc is nil');
  end
  else
    showmessage('222');
    FreeLibrary(DLLHandle);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  close;
end;
end.-----------------------------------------
把下面这句删掉一切正常。
rc( sfzName,@sfzSex,@sfzNation,@sfzBirthday,@sfzAddress,
@sfzID,@sfzDepartment,@sfzStartDate,@sfzEndDate,@sfzReserve,
@sfzAppAddress1,@sfzPhotoData)=0
请高手帮忙look lookdll Windows指针 

解决方案 »

  1.   

    试下修改成如下:if(rc(PChar(sfzName),PChar(sfzSex),PChar(sfzNation),PChar(sfzBirthday),PChar(sfzAddress),PChar(sfzID),PChar(sfzDepartment),                           PChar(sfzStartDate),PChar(sfzEndDate),PChar(sfzReserve),PChar(sfzAppAddress1),PChar(sfzPhotoData))=0)then
      

  2.   


    按照上面提示修改。现在提示
    Project Project1.exe raised exception class EaccessViolation with message 'Access violation at address 1000511B in module 'JCJP_AP'.Write of address 00404311' Process stopped.Use Step or Run to continue.
      

  3.   

    定义sfzName等参照如下,试试
    我的方法function ReadBaseInfosPhoto(Name,Sex,Folk,BirthDay,ID,Address,Issue,dBegin,dEnd,Photopath:PAnsiChar):integer;stdcall;External '.\dll\sdtapi.dll';
    type
      TIDCardInfo=record
        _Name:array[1..31] of AnsiChar;
        _Sex:array[1..3] of AnsiChar;
        _Folk:array[1..10] of AnsiChar;
        _Birthday:array[1..9] of AnsiChar;
        _Addr:array[1..71] of AnsiChar;
        _ID:array[1..19] of AnsiChar;
        _Issue:array[1..31] of AnsiChar;
        _dBegin:array[1..9] of AnsiChar;
        _dEnd:array[1..9] of AnsiChar;
      private
        Fport:Integer;         //端口状态
        Fauthenticate:Integer; //认证状态
        Freadinfo:Integer;     //读卡状态
      end;
    ReadCard.Freadinfo:=ReadBaseInfosPhoto(@ReadCard._Name,@ReadCard._Sex,@ReadCard._Folk,@ReadCard._Birthday,@ReadCard._ID,@ReadCard._Addr,@ReadCard._Issue,@ReadCard._dBegin,@ReadCard._dEnd,PAnsiChar(AnsiString(Fphotopath)));
      

  4.   

    直接声明:
    var
        sfzName,sfzSex,sfzNation,sfzBirthday,sfzAddress,sfzID,sfzDepartment,
        sfzStartDate,sfzEndDate,sfzReserve,sfzAppAddress1,sfzPhotoData:pchar;这个地方:
      ReadCard = function (var Name:pChar;var Sex:pChar;var Nation:pChar;var Birthday:pChar;
          var Address:pChar;var ID:pChar;var Department:pChar;var StartDate:pChar;var EndDate:pChar;
          var Reserve:pChar;var AppAddress1:pChar;var PhotoData:pChar):integer;stdcall;
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      OpenCom = function (Comport:integer;Baud:integer):integer;stdcall;
      SelModule = function (PortType:integer;Module:integer):integer;stdcall;
      CloseCom = function ():integer;stdcall;   
      ReadCard = function (Name,Sex,Nation,Birthday,Address,ID,Department,
        StartDate,EndDate,Reserve,AppAddress1,PhotoData:PAnsiChar):integer;stdcall;  TIDCardInfo=record
    _Name:array[1..31] of AnsiChar;
    _Sex:array[1..3] of AnsiChar;
    _Nation:array[1..51] of AnsiChar;
    _Birthday:array[1..9] of AnsiChar;
    _Address:array[1..51] of AnsiChar;
    _ID:array[1..19] of AnsiChar;
    _Department:array[1..51] of AnsiChar;
    _StartDate:array[1..9] of AnsiChar;
    _EndDate:array[1..9] of AnsiChar;
    _Reserve:array[1..51] of AnsiChar;
    _AppAddress1:array[1..51] of AnsiChar;
    _PhotoData:array[1..51] of AnsiChar;
        Freadinfo:Integer;     //读卡状态
      end;
      
      TForm1 = class(TForm)
        Button1: TButton;                           
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var DllHandle:THandle;
        ComPort,Baud,HBaud,result:integer;
        PortType,Module:integer;
        oc:OpenCom;
        sm:SelModule;
        cc:CloseCom;
        rc:ReadCard;
        idci:TIDCardInfo;
    begin  ComPort:=1;Baud:=9600;HBaud:=115200;result:=22;
      PortType:=0;Module:=3;  DLLHandle:=LoadLibrary('JCJP_API.dll');
      if DLLHandle<>0 then
      begin
        @oc:=GetProcAddress(DllHandle,'Open_Com');    if @oc<>nil then
        begin
          if( oc(ComPort,Baud) = 0 )then
          begin
            @sm:= GetProcAddress(DllHandle,'Sel_Module');
            if @sm<>nil then
            begin
              if(sm(PortType,Module) = 0)then
              begin
                @cc:= GetProcAddress(DllHandle,'Close_Com');
                if( cc()=0)then
                begin
                   @oc:=GetProcAddress(DllHandle,'Open_Com');
                   if(@oc<>nil)then
                   begin
                   if(oc(ComPort,HBaud)=0)then
                   begin
                     @rc:= GetProcAddress(DllHandle,'ReadCard');
                     if @rc<>nil then
                     begin
                        idci.Freadinfo:=rc(@idci._Name,@idci._Sex,@idci._Nation,
                            @idci._Birthday,@idci._Address,@idci._ID,@idci._Department,
                            @idci._StartDate,@idci._EndDate,@idci._Reserve,@idci._AppAddress1,
                            @idci._PhotoData);
                           showmessage('没有找到二代身份证,读取失败!');                       
                       result:=sm(PortType,0);
                       result:=cc();
                     end
                     else
                       showmessage('rc is nil');
                   end
                   else
                     showmessage('高频打开串口失败');
                   end
                   else
                     showmessage('oc is nil');
                end
                else
                  showmessage('关闭串口失败');
              end
              else
              begin
                showmessage('选择模式失败');
              end;
            end
            else
            begin
              showmessage('sm is nil');
            end;
          end
          else
            showmessage('串口打开失败!');
        end
        else
          showmessage('oc is nil');
      end
      else
        showmessage('222');
        FreeLibrary(DLLHandle);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      close;
    end;
    end.
    改造完毕,读取二代证结果正常。
    但是运行完毕
    显示不知道怎么做了?谢谢楼上的兄弟姐妹们。