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
|
procedure TForm1.test(dll: PChar);
var
h: THandle;
p: function (pRegistryRoot: PWideChar): PMonitorEx; stdcall;
m: PMonitorEx;
e: Bool;
need, count: Cardinal;
buf:array[0..500] of Char;
w: PWideChar;
begin
h := LoadLibrary(dll);
p := GetProcAddress(h, 'InitializePrintMonitor');
m := p('System\CurrentControlSet\Control\Print\Monitors\ImagePrinter Port');
e := m.Monitor.pfnEnumPorts(nil, 2, nil, 0, @need, @count);
Memo1.Lines.add(Format('EnumPorts = %d, need = %d, count = %d, %d',[Ord(e), need, count, GetLastError]));
FillChar(buf, SizeOf(buf), 0);
e := m.Monitor.pfnEnumPorts(nil, 2, @buf, SizeOf(buf), @need, @count);
Memo1.Lines.add(Format('EnumPorts = %d, need = %d, count = %d, %d',[Ord(e), need, count, GetLastError]));
Memo1.Lines.add(IntToHex(cardinal(@buf), 4));
Move(buf[0], w, SizeOf(w));
if w = nil then
Memo1.Lines.Add('nil')
else
Memo1.Lines.add(string(w));
Move(buf[4], w, SizeOf(w));
if w = nil then
Memo1.Lines.Add('nil')
else
Memo1.Lines.add(string(w));
Move(buf[8], w, SizeOf(w));
if w = nil then
Memo1.Lines.Add('nil')
else
Memo1.Lines.add(string(w));
Move(buf[12], w, SizeOf(w));
if w = nil then
Memo1.Lines.Add('nil')
else
Memo1.Lines.add(string(w));
Dump(buf, need);
FreeLibrary(h);
end; |
Partager