1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228:
| library CAPI2032; //CAPI Wrapper //Benennen Sie die auf Ihrem System vorhandene CAPI2032.DLL in CAPRI2032.DLL um //erzeugen sie die neue CAPI2032.DLL und kopieren sie dieses in Ihr entsprechendes Systemverzeichnis. //danach wird das Messaging zwischen Applikation und CAPI in der Datei c:\capi.log protokolliert.
uses SysUtils, Classes, windows;
type T_CAPI_INSTALLED=function:DWord;stdcall; type T_CAPI_GET_MANUFACTURER = Procedure(SzBuffer:pchar);stdcall; type T_CAPI_GET_SERIAL_NUMBER=function(SzBuffer:PChar):dword;stdcall; type T_CAPI_GET_VERSION=function(pCapiMajor,pCAPIMinor,pManufacturerMajor,pManufacturerMinor:pointer):dword;stdcall; type T_CAPI_GET_PROFILE=function(SzBuffer:pointer;ctrlnr:DWord):DWord;stdcall;
type T_CAPI_REGISTER= function(MessageBufferSize,maxlogicalconnection,maxBDataBlocs,maxBdataLen:Dword;papplID:pointer):DWord;stdcall; type T_CAPI_RELEASE= function(ApplID:DWORD):DWord;stdcall; type T_CAPI_WAIT_FOR_SIGNAL= function(ApplID:DWORD):DWord;stdcall; type T_CAPI_PUT_MESSAGE=function(applid:dword;pCAPIMessage:pointer):DWORD;stdcall; type T_CAPI_GET_MESSAGE=function(applid:dword;pCAPIMessage:Pointer):DWORD;stdcall;
{$R *.RES}
var
WCAPI_GET_MANUFACTURER:T_CAPI_GET_MANUFACTURER; WCAPI_REGISTER:T_CAPI_REGISTER; WCAPI_RELEASE:T_CAPI_RELEASE; WCAPI_PUT_MESSAGE:T_CAPI_PUT_MESSAGE; WCAPI_WAIT_FOR_SIGNAL:T_CAPI_WAIT_FOR_SIGNAL; WCAPI_GET_MESSAGE:T_CAPI_GET_MESSAGE; WCAPI_GET_PROFILE:T_CAPI_GET_PROFILE; WCAPI_INSTALLED:T_CAPI_INSTALLED; WCAPI_GET_VERSION:T_CAPI_GET_VERSION; WCAPI_GET_SERIAL_NUMBER:T_CAPI_GET_SERIAL_NUMBER;
capihandle:THandle;
procedure logmessage(messagetext:string); var logfile:Textfile; begin
assign(logfile,'c:\capi.log'); if fileexists('c:\capi.log') then append(logfile) else rewrite(logfile); writeln(logfile,messagetext); closefile(logfile); end;
procedure logcapimessage(capimessage:pchar;mode:integer); var i:integer; length:word; line:string; logfile:Textfile; begin
assign(logfile,'c:\capi.log');
if fileexists('c:\capi.log') then append(logfile) else rewrite(logfile);
writeln(logfile,'Message Begin'); if mode=1 then writeln(logfile,'CAPI_GET_MESSAGE'); if mode=0 then writeln(logfile,'CAPI_PUT_MESSAGE'); length:=byte(capimessage^)+256*byte((capimessage+1)^);
line:=''; for i:=0 to length-1 do begin if (i mod 16=0) and (i<>0) then begin writeln(logfile,line);
line:=''; end; line:=line+inttohex(byte((capimessage+i)^),2)+' ';
end; if line<>'' then writeln(logfile,line); writeln(logfile,'Message End'); writeln(logfile);
closefile(logfile);
end;
procedure logcapimessagep(pcapimessage:pointer;mode:integer); var capimessage:pchar; begin
capimessage:=pointer(pcapimessage^);
if capimessage=nil then exit; logcapimessage(capimessage,mode);
end;
function CAPI_INSTALLED:DWord;stdcall; begin logmessage('CAPI_INSTALLED'); result:=WCAPI_INSTALLED; end;
procedure CAPI_GET_MANUFACTURER(SzBuffer:Pchar);stdcall; begin logmessage('CAPI_GET_MANUFACTURER');
WCAPI_GET_MANUFACTURER(SzBuffer); end;
function CAPI_GET_SERIAL_NUMBER(SzBuffer:pointer):dword;stdcall; begin logmessage('CAPI_GET_SERIAL_NUMBER'); result:=WCAPI_GET_SERIAL_NUMBER(szbuffer); end;
function CAPI_GET_VERSION(pCapiMajor,pCAPIMinor,pManufacturerMajor,pManufacturerMinor:pointer):dword;stdcall; begin logmessage('CAPI_GET_VERSION');
result:=WCAPI_GET_VERSION(pCapiMajor,pCAPIMinor,pManufacturerMajor,pManufacturerMinor); end;
function CAPI_GET_PROFILE(SzBuffer:pointer;ctrlnr:DWord):DWord;stdcall; begin logmessage('CAPI_GET_PROFILE');
result:=WCAPI_GET_PROFILE(SzBuffer,ctrlnr); end;
function CAPI_REGISTER(MessageBufferSize,maxlogicalconnection,maxBDataBlocs,maxBdataLen:Dword;papplID:pointer):DWord;stdcall; begin logmessage('CAPI_REGISTER');
result:=WCAPI_REGISTER(MessageBufferSize,maxlogicalconnection,maxBDataBlocs,maxBdataLen,papplID); end;
function CAPI_RELEASE(ApplID:DWORD):DWord;stdcall; begin logmessage('CAPI_RELEASE');
result:=WCAPI_RELEASE(ApplID); end;
function CAPI_WAIT_FOR_SIGNAL(ApplID:DWORD):DWord;stdcall; begin logmessage('CAPI_WAIT_FOR_SIGNAL');
result:=WCAPI_WAIT_FOR_SIGNAL(applid); end;
function CAPI_PUT_MESSAGE(applid:dword;pCAPIMessage:pointer):DWORD;stdcall; begin logmessage('CAPI_PUT_MESSAGE');
result:=WCAPI_PUT_MESSAGE(applid,pCAPIMessage); if result=0 then if pcapimessage<> nil then logcapimessage(pcapimessage,0);
end;
function CAPI_GET_MESSAGE(applid:dword;pCAPIMessage:Pointer):DWORD;stdcall; begin logmessage('CAPI_GET_MESSAGE');
result:=WCAPI_GET_MESSAGE(applid,pCAPIMessage); if result=0 then if pcapimessage<>nil then logcapimessagep(pcapimessage,1);
end;
exports CAPI_REGISTER index 1; exports CAPI_RELEASE index 2; exports CAPI_PUT_MESSAGE index 3; exports CAPI_GET_MESSAGE index 4; exports CAPI_WAIT_FOR_SIGNAL index 5; exports CAPI_GET_MANUFACTURER index 6; exports CAPI_GET_VERSION index 7; exports CAPI_GET_SERIAL_NUMBER index 8; exports CAPI_GET_PROFILE index 9; exports CAPI_INSTALLED index 10;
begin
capihandle:=loadlibrary('CAPRI2032.dll'); if capihandle=0 then raise exception.create('CAPI konnte nicht geladen werden.');
@WCAPI_GET_MANUFACTURER:=getprocaddress(capihandle,'CAPI_GET_MANUFACTURER'); @WCAPI_REGISTER:=getprocaddress(capihandle,'CAPI_REGISTER'); @WCAPI_RELEASE:=getprocaddress(capihandle,'CAPI_RELEASE'); @WCAPI_WAIT_FOR_SIGNAL:=getprocaddress(capihandle,'CAPI_WAIT_FOR_SIGNAL'); @WCAPI_PUT_MESSAGE:=getprocaddress(capihandle,'CAPI_PUT_MESSAGE'); @WCAPI_GET_MESSAGE:=getprocaddress(capihandle,'CAPI_GET_MESSAGE'); @WCAPI_GET_PROFILE:=getprocaddress(capihandle,'CAPI_GET_PROFILE'); @WCAPI_GET_VERSION:=getprocaddress(capihandle,'CAPI_GET_VERSION'); @WCAPI_INSTALLED:=getprocaddress(capihandle,'CAPI_INSTALLED'); @WCAPI_GET_SERIAL_NUMBER:=getprocaddress(capihandle,'CAPI_GET_SERIAL_NUMBER');
end. |