Q&A

  • 카드승인시 통신dll 호출 할때 오류가 납니다.ㅠ.ㅠ
매일 질문만 드립니다..
두개의 질문을 드립니다..

1. van 사에서 제공한 vc++로 제작된 dll을 호출하는 부분에서 오류가 납니다..
    아무래도..함수호출 시 매개변수의 type 을 잘못 준거 같은데..모르겠네여...ㅠ.ㅠ
    dll에서 함수를 두개 쓰는데...매개변수 던지는 함수호출시만 access viiolation 나고 변수없는 함수 호출
    때는 오류가 나지 않는 걸로 봐서는 dll이 메모리에 로드가 잘된것 같은데여....

    예시로 제공된 VB소스를 보면 STRING 변수를 유니코드 값으로 변환해서 던지는데 델파이에서 어떤식으로
    코딩해야 할까여....ㅠ.ㅠ 초보다 보니까..이해 부탁 드립니다.

아무래도 변수 선언과 호출시 응답 받는 부분을 부탁 드립니다..이놈때문에 며칠동안 고생하고 있습니다.

**************제공된 DLL설명****************

typedef long (__stdcall *Pos_Send)( char *IP, long PORT, char *send_data, char *recv_data);
-        전문 송/수신 함수
-        IP : 나이스 서버 IP
-        PORT : 나이스 서버 포트
-        send_data : 요청전문(250 byte)
-        recv_data : 응답전문(450 byte)
-        return value : 정상 1, 0 보다 작은 값(음수)
typedef long (__stdcall *Pos_Ack)();
-        정상 응답 ACK
-        return value : 정상 1, 0 보다 작은 값(음수)




  ************ 에러델파이 소스 **************

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

function  Pos_Send(IP: PChar; Port: Integer; SendData: PChar; RecvData: PChar):integer; stdcall; external 'NicePosV100.dll' ;

function  Pos_Ack():Integer; stdcall; external 'NicePosV100.dll' ;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  RetCode : integer;
  PSendData,PRecvData: PChar;
  
begin      
                                                                                                        ';
  Ws :='0240TAXTEST0003            020010H1          9999999999@379410472589785100=0506                00000000000000000000000000010                          00000000001234567                                                                        ';


  RetCode := Pos_Send('211.133.126.2';,      //이 함수 호출시만 오류입니다.                    
                                       4099,                      
                                        PSendData,               //요청전문
                                       PRecvData                    //응답전문
                                        );

  RetCode :=  Pos_Ack();   //이 함수 호출시는 에러가 없습니다.
end;


*******에러없는 VB 소스************************
Private Declare Function Pos_Send Lib "NicePosV100.dll" (ByRef strNiceIP As Byte, ByVal lngNicePort As Long, ByRef strSendData As Byte, ByRef strReceveData As Byte) As Long
Private Declare Function Pos_Ack Lib "NicePosV100.dll" () As Long

Private Sub Command1_Click()

    Dim retVal As Long              ' 전문 송/수신 결과
    Dim retAck As Long              ' ACK 전문 송/수신 결과
    Dim strInBuffer As String       ' 응답 받는 전문
    Dim strOutBuffer As String      '  송신할 전문
    Dim strIP As String             ' 서버주소
    Dim respcode As String          ' 응답코드
    Dim msg As String               ' 메시지 변수
    
    
    Dim bIP() As Byte
    Dim bSendData() As Byte
    Dim bReceData(500) As Byte
    
'
    strIP = "211.133.126.2"
    
    strOutBuffer = Text1.Text
    strInBuffer = ""
    
    retVal = 0
    retAck = 0
    
    bIP = StrConv(strIP, vbFromUnicode)
    bSendData = StrConv(strOutBuffer, vbFromUnicode)
    
    retVal = Pos_Send(bIP(0), 4099, bSendData(0), bReceData(0))
    
    strInBuffer = StrConv(bReceData, vbUnicode)
    respcode = Mid(strInBuffer, 56, 4)
    
    If (retVal < 0) Then
        MsgBox ("망상취소 보내세요.")
    
    End If
    
    Text2.Text = strInBuffer
    
End Sub
  
    



2. 영수증 출력기에서 이미지를 출력 할 수 있을까요..? 영수증 출력기 COMMAND 에 보면 IMAGE 부분이 있
는것 같던데..구현방법을 모르겠습니다...ㅎㅎ


ESC *m nL nH [d1...dk]
[Name]        Select bit-image mode
[Format]        ASCII   ESC  * m nL nH[d1...dk]
                  Hex    1B    2A m nL nH[d1...dk]
[Range]        m = 0, 1, 32, 33
                0≤nL ≤255
                0≤nH ≤3
                0≤d ≤255
[Description]        Selects bit-image mode using m for the number of dots specified by
                               (nL+ nH,x256).
                               This command is used to print a predefined picture or logo.
                               The modes selectable by m are follows;
  
m         Mode                    Vertical  Direction                                 Horizontal Direction
                      NO. of Dots        Dot Density   DotDensity  Number of (Data(K)
0         8-dot
          single-density         8         60 DPI                90 DPI      nL + nH x 256
1         8-dot double-density         8                60 DPI      180 DPI  nL + nH x 256
32         24-dot single-density         24                180 DPI    90 DPI         (nL + nH x 256) x 3
33         24-dot double-density         24         180 DPI         180 DPI         (nL + nH x 256) x 3

[Notes]        The nL and nH indicate the number of dots of the bit image in the horizontal direction. The number of dots is calculated by nL + nH x 256. If the bit-image data input exceeds the number of dots to be printed on a line, the excess data is ignored. d indicates the bit-image data. Set a corresponding bit of 1 to print a dot or to 0 to not print a dot. If the value of m is out of the specified range, nL and data following are processed as normal data. If the width of the printing area set by “GS L” and “GS W” less than the width required by the data sent with the “ESC *” command the following will be performed on the line in question (but the printing cannot exceed the maximum printable area) : ① The width of the printing area is extended to the right to accommodate the amount of data. ② If step ① does not provide sufficient width for the data, the left margin is reduced to accommodate the data.For each bit of data in single-density mode, the printer prints two dots : for each bit of data in double-density mode, the printer prints one dot.This must be considered in calculating the amount of data that can be printed in one line. After printing a bit images the printer returns to normal data processing mode.This command is not affected by print modes (emphasized, double-strike, and underline etc.), except upside-down mode.The relationship between the image data and the dots to be printed is as follows.


    
1  COMMENTS
  • Profile
    프리김 2006.01.19 19:47
    1번만 답해드리고, 2번은 답변달지 않겠습니다.

    SendData : array [0..249] of char;
    RecvData : array[0..449] of char;
    이런식으로 선언하고, 초기화작업도 하신후 함수를 호출하면 됩니다.