unit GSDLL32;
{"Dynamische" Version der GSDLL32-Anbindung
Die Initialisierung erfolgt durch Aufruf von LoadGSDLL mit Angabe des
kompletten Pfades.
Der Zugriff erfolgt wie in DLL.htm angegeben, mit einem "." statt "_", also
gsdll_init() -> gsdll.init() usw.
Dies war erforderlich, um die Funktionszeiger schön hintereinander
zu halten, was den dynamischen Import stark vereinfacht.}
interface
uses Windows,WUtils32;
type
TGSDLL_Callback=Function(Msg:Integer; str:PChar; Count:UInt):Integer; cdecl;
const
GSDLL_stdin=1; {get count characters to str from stdin,
return number of characters read}
GSDLL_stdout=2; {put count characters from str to stdout,
return number of characters written}
GSDLL_DEVICE=3; {device str has been opened if count = 1,
closed if count = 0}
GSDLL_SYNC=4; {sync_output for device str}
GSDLL_PAGE=5; {output_page for device str}
GSDLL_SIZE=6; {resize for device str: LOWORD(count) is new xsize,
HIWORD(count) is new ysize}
GSDLL_POLL=7; {Called from gp_check_interrupt()
Can be used by the caller to poll the message queue.
Normally returns 0. To abort gsdll_execute_cont(), return a
non-zero error code until gsdll_execute_cont() returns.}
type
TGSDLL=record
case Integer of
1:( {Benannte Funktionszeiger}
revision: Function(product,copyright:PPChar; gs_revision:PLongInt; gs_revisiondate:PLongInt):Integer; stdcall;
init: Function(callback:TGSDLL_Callback; Wnd:HWnd;argc:Integer;argv:PPChar):Integer; stdcall;
execute_begin: Function:Integer; stdcall;
execute_cont: Function(str:PChar; len:Integer):Integer; stdcall;
execute_end: Function:Integer; stdcall;
exit: Function:Integer; stdcall;
lock_device: Function(device:PChar; flag:UInt):Integer; stdcall;
//Nur-Windows-Funktionen
copy_dib: Function(device:PChar):HGlobal; stdcall;
copy_palette: Function(device:PChar):HPalette; stdcall;
draw: Procedure(device:PChar; dc:HDC; dest,src:PRect); stdcall;
get_bitmap_row: Function(device:PChar; pbmih:PBitmapInfoHeader;
prgbquad:PRgbQuad; ppbyte:PPChar; row:UInt):Integer; stdcall;);
2:(procs: array[0..10] of TFarProc); {Funktionszeiger hintereinander}
3:(names: array[0..10] of PChar); {hier: unnötig!}
4:(ordinals: array[0..10] of UInt); {hier: unnötig!}
end;
const
gsdll: TGSDLL {Import durch Namen ist freundlicherweise unnötig,
weil die Nummerierung regelmäßig ist! Sonst
wäre ein CONST statt VAR mit Namen oder Nummern
erforderlich gewesen.}
=(names:(
'gsdll_revision',
'gsdll_init',
'gsdll_execute_begin',
'gsdll_execute_cont',
'gsdll_execute_end',
'gsdll_exit',
'gsdll_lock_device',
'gsdll_copy_dib',
'gsdll_copy_palette',
'gsdll_draw',
'gsdll_get_bitmap_row'));
var
hLib: THandle;
function LoadGSDLL(s:PChar):Boolean;
implementation
function LoadGSDLL(s:PChar):Boolean;
var
i:Integer;
begin
Result:=true;
if hLib>32 then exit;
hLib:=LoadLibrary(s);
if hLib<=32 then begin Result:=false; exit; end;
for i:=0 to HIGH(gsdll.names) do begin
gsdll.procs[i]:=GetProcAddress(hLib,gsdll.names[i]);
end;
end;
end.
Detected encoding: OEM (CP437) | 1
|
|