Q&A

  • 파워빌더 바코드 출력 부분을 델파이로 변환.(오류사항을 알켜주세요)
파워 빌더 바코드 프린터 소스를 델파이로 변환 했는데 잘 안되네요..
파워 빌더와 델파이를 동시에 잘 아시는 분 부탁합니다..
win api 함수를 사용했는데 파워빌더로 한거는 잘되는데 왜..
델파이로 한건 왜 안되는지 아시는분 꼭좀 답해주세요.....
잘못 된곳이 있으면..제발좀.......콕...알켜주세요...!!!!!!!!!!
////////////////파워빌더 소스 입니다./////////////////////////////////////////////////////////////////////////
<< Global External Functions >>
/* To Create a File */
Function long CreateFileA( ref String lpszName, long fdwAccess, long fdwShareMode, long lpsa, long fdwCreate, long fdwAttrsAndFlags, long hTemplateFile) library "kernel32.dll"
/* To write to the file */
Function boolean WriteFile( long hFile, ref string lpBuffer, long nNumberOfBytesToWrite, ref long lpNumberOfBytesWritten, st_overlapped lpOverlapped) library "kernel32.dll"
/* To write to the file */
Function long GetLastError() library "kernel32.dll"
/* To get error information */
Function boolean CloseHandle(long hObject) library "kernel32.dll"
/* 구조체 선언부분*/
/*long internal*/
/*long internalhigh*/
/*long offset*/
/*long offsethigh*/
/*long hevent*/

<< Instance Variables >>
LONG        ll_Comid, lnull, ll_written
LONG        GENERAL_WRITE = 1073741824
LONG        SHARE_MODE = 0
LONG        OPEN_EXISTING = 3
LONG        FILE_FLAG_OVERLAPPED = 1073741824
INT        SERCONT = -1
st_overlapped lst_overlap

<< Window Open Event >>
INT                ret, len = 101, idx
STRING        sPort

sPort = "COM1"
setnull(lnull)

ll_comid = CreateFileA(sPort, GENERAL_WRITE, SHARE_MODE, lnull, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, lnull)

IF ll_ComId < 0 THEN        MessageBox(String(ll_ComId), Getlasterror())



<< Button Clicked Event >>
STRING        sBar[11]
INTEGER        i, j

sBar[1] = "EST(128)"
sBar[2] = "FMT(1, 75, 23, 2, 0, 1)"
sBar[3] = "LMG(0)"
sBar[4] = "SFM(1)"
sBar[5] = "PIT(-60d)"
sBar[6] = "BFL(1, 2, 1, 1, 1, 9)"
sBar[7] = "CFL(2, 4, 11, 45, 4, 4)"
sBar[8] = "ACL()"
sBar[9] = "DAT(1,*" + Trim(sle_tape.Text) + "*)"
sBar[10] = "DAT(2," + Trim(sle_tape.Text) + ")"
sBar[11] = "PRT(1, 1, 1)"

FOR i = 1 To 11
        IF ll_Comid >= 0 THEN
                WriteFile(ll_Comid, sBar[i], Len(sBar[i]), ll_Written, lst_overlap)
        END IF
        
        Time(2)
NEXT
////////////////파워빌더 소스 입니다.///////////////////////////////////////////////////////////////////////
파워 빌더 바코드 프린터 소스를 델파이로 변환 했는데 잘 안되네요..
파워 빌더와 델파이를 동시에 잘 아시는 분 부탁합니다..
////////////////////델파이 소스 입니다./////////////////////////////////////////////////////////////////////
잘못 된곳이 있으면..제발좀.......콕...알켜주세요...!!!!!!!!!!
var
  Form1: TForm1;

implementation

{$R *.dfm}


function WriteFile(hFile:THandle;Var Buf;Count:DWORD;Var NumWrite:DWORD;
                  Lap:POverlapped):BOOL;stdcall external 'kernel32.dll';
function CreateFileA(lpFileName: PAnsiChar; dwDesiredAccess, dwShareMode: DWORD;
  lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD;
  hTemplateFile: THandle): THandle; stdcall external 'kernel32.dll';

var
     ll_Comid : LONGINT;
     ll_written,GENERAL_WRITE,FILE_FLAG_OVERLAPPED :DWORD;
     SHARE_MODE :DWORD;
     lnull :THANDLE;
     OPEN_EXISTING :DWORD;
     SERCONT :integer  ;
     sPort :STRING;
     sBar    : array[1..11] of string;
     j   :integer;
     lst_overlap :POverlapped ;


procedure TForm1.FormCreate(Sender: TObject);
begin
  GENERAL_WRITE := 1073741824 ;
  SHARE_MODE := 0 ;
  OPEN_EXISTING := 3  ;
  FILE_FLAG_OVERLAPPED := 1073741824 ;
  SERCONT := -1 ;


  sPort := 'COM1' ;
  lnull := 0 ;

  ll_comid := CreateFileA(PChar(sPort), GENERAL_WRITE, SHARE_MODE, nil,OPEN_EXISTING, FILE_FLAG_OVERLAPPED, lnull);

  IF ll_ComId < 0 THEN
     MessageBox(0,pchar('포트 개방 오류입니다.'),pchar('확인'), MB_OK)

end;

procedure TForm1.Button1Click(Sender: TObject);
//var lemp :  st_overlapped;
var
   i ,j: Integer;
begin
    sBar[1] := 'EST(128)' ;
    sBar[2] := 'FMT(1, 75, 23, 2, 0, 1)'  ;
    sBar[3] := 'LMG(0)'            ;
    sBar[4] := 'SFM(1)'      ;
    sBar[5] := 'PIT(-60d)'     ;
    sBar[6] := 'BFL(1, 2, 1, 1, 1, 9)'  ;
    sBar[7] := 'CFL(2, 4, 11, 45, 4, 4)'  ;
    sBar[8] := 'ACL()'                 ;
    sBar[9] := 'DAT(1,*' + Trim(Edit1.Text) + '*)'   ;
    sBar[10] := 'DAT(2,' + Trim(Edit1.Text) + ')' ;
    sBar[11] := 'PRT(1, 1, 1)';
    //lemp := lst_overlap ;
    FOR i := 1 To 11  do
    begin
            IF ll_Comid >= 0 THEN
            begin
                WriteFile(ll_Comid, sBar[i], sizeof(sBar[i]), ll_Written, lst_overlap) ;
            END ;
            for j := 0 to  200 do
            begin
            end;

    end;

end;
0  COMMENTS