INT Rcard(CHAR *SET,CHAR *RDATA,INT TRACK)
改为 delphi 的该如何写

解决方案 »

  1.   

    function Rcard(SET, RDATA: PChar; TRACK: integer): integer;
      

  2.   

    function Rcard (Set,RData:PChar;Track:Integer):Integer;
      

  3.   

    具体的是一个磁卡读写器的操作(读取磁道信息)函数
    可是我调用的时候有问题
    我感觉应该写成 
    function Rcard (SetCMD: pcahr; var RData:PChar;Track:Integer):Integer;请各位看看以下为厂家提供的原文: INT Rcard(CHAR *SET,CHAR *RDATA,INT TRACK)功能:控制sLe353b进行读磁卡操作,按ESC键可退出.返回: 整型
       =  1:    读卡正确,
         -1:    所选串行口打不开
         -2:    与磁卡读写机通信失败(磁卡机没有与主机连接或连接不正确)     
         -3:    串口设置错误
         -4:    读卡错误
         -5:    用户 ESC 退出参数:
     SET:  字符串,用来设置串口.
           格式:"1,9600,N,8,1" ------ (1=com1或2=com2),
    (9600=baud9600或4800=baud4800
     或2400=baud2400或1200=baud1200),
    (N=无校验或O=奇校验或N=偶校验),
    (8=8个数据位或7=7个数据位),
    (1=1个停止位或2=2个停止位).
           如:"2,9600,O,7,1" 表示串口2,波特率9600.奇校验,7个数据位,1个停止位. TRACK: 需要进行写卡操作的磁道选择号(具体定义如下:)           
                --------  1:选择第1磁轨 
                    2:选择第2磁轨
            3:选择第3磁轨
            4:选择第2和第1磁轨
            5:选择第2和第3磁轨  RDATA: 读卡数据输出缓冲区(用于存放读卡成功后的返回数据)
    字符串,长度不少于300字节.
         
    读卡成功返回格式: 
         RDATA = "磁道1数据"       ------- 返回磁道1数据(此时 TRACK 为1)
         RDATA = "磁道2数据"             ------- 返回磁道2数据(此时 TRACK 为2)           
         RDATA = "磁道3数据"             ------- 返回磁道3数据(此时 TRACK 为3)
         RDATA = "磁道2数据a磁道1数据"   ------- 返回磁道2数据和磁道1数据(此时 TRACK 为4)
         RDATA = "磁道2数据a磁道3数据"   ------- 返回磁道2数据和磁道3数据(此时 TRACK 为5)
         
        读卡错误: Rcard函数返回值为-4
           
           其中: 小写字符a为磁道2与磁道1(或磁道2与磁道3)的数据的分隔符
                 1道数据可为字母或数字,最多76个
                 2道数据只可为数字,最多37个 
                 3数据只可为数字,最多104个
                 
           如:
                 Rcard("1,9600,N,8,1",RDATA,1)
                           -------- 表示通过串行口1以波特率9600BPS,8位数据位,1位停止位,
                                         无校验的方式从第1磁轨中读取数据(存放在RDATA中)
                                         
                 Rcard("1,9600,N,8,1",RDATA,2)
                           -------- 表示通过串行口1以波特率9600BPS,8位数据位,1位停止位,
                                         无校验的方式从第2磁轨中读取数据(存放在RDATA中)     
                                                 
                 Rcard("1,9600,N,8,1",RDATA,3)
                           -------- 表示通过串行口1以波特率9600BPS,8位数据位,1位停止位,
                                         无校验的方式从第3磁轨中读取数据(存放在RDATA中) 
                                         
                 Rcard("1,9600,N,8,1",RDATA,4)
                           -------- 表示通过串行口1以波特率9600BPS,8位数据位,1位停止位,
                                         无校验的方式从第2磁轨和第1磁轨中读取数据
                                         (存放在RDATA中,中间以小写字符a作间隔)    
                                         
                 Rcard("1,9600,N,8,1",RDATA,5)
                           -------- 表示通过串行口1以波特率9600BPS,8位数据位,1位停止位,
                                         无校验的方式从第2磁轨和第3磁轨中读取数据
                                         (存放在RDATA中,中间以小写字符a作间隔)
      

  4.   

    根据说明这个是正确的
    function Rcard (SetCMD: pcahr; var RData:PChar;Track:Integer):Integer;Here is an example of a procedure declaration:procedure NumString(N: Integer; var S: string);
    var
      V: Integer;
    begin
      V := Abs(N);
      S := '';
      repeat
        S := Chr(V mod 10 + Ord('0')) + S;
        V := V div 10;
      until V = 0;
      if N < 0 then S := '-' + S;
    end;Given this declaration, you can call the NumString procedure like this:NumString(17, MyString);This procedure call assigns the value "17" to MyString (which must be a string variable).Within a procedure's statement block, you can use variables and other identifiers declared in the localDeclarations part of the procedure. You can also use the parameter names from the parameter list (like N and S in the previous example); the parameter list defines a set of local variables, so don't try to redeclare the parameter names in the localDeclarations section. Finally, you can use any identifiers within whose scope the procedure declaration falls.
      

  5.   

    如果要定义成var RData:PChar;那么vc函数的原型必然是(CHAR *)*RDATA;别把电脑当成人脑了. 它可读不懂你文档中是怎么写的.如果一定要用var, 可以直接定义成var RData; 使用时可以通过强制类型转换将RData转成任何指针然后使用
      

  6.   

    to Idle_(阿呆)
    就这个问题,你怎么作?
      

  7.   

    我已经解决了
    自定义了一个格式     TArrayChar = array [0..350] of Char;function Rcard(SetCMD: Pchar; var RData: TArrayChar;  Track: Integer):LongInt; stdcall; 'KeyCard.dll';
      

  8.   

    厂商它提供的接口函数远行就是 INT Rcard(CHAR *SET,CHAR *RDATA,INT TRACK),