使用打印机;
{$IFNDEF WIN32}
常量 MAX_PATH = 144;
{$ENDIF}
过程 TForm1.Button1Click(发件人: TObject);
变量
pDevice:pChar;
pDriver:pChar;
p端口:pChar;
hDMode:THandle;
开始
如果 PrintDialog1.Execute 然后开始
GetMem(pDevice, cchDeviceName);
GetMem(pDriver, MAX_PATH);
GetMem(pPort, MAX_PATH);
Printer.GetPrinter(pDevice, pDriver, pPort, hDMode);
如果 lStrLen(pDriver) = 0 则开始
GetProfileString('设备', pDevice, ', pDriver, MAX_PATH);
pDriver[pos(',', pDriver) - 1] := #0;
结尾;
如果 lStrLen(pPort) = 0 则开始
GetProfileString('设备', pDevice, ', pPort, MAX_PATH);
lStrCpy(pPort,@pPort[lStrLen(pPort)+2]);
结尾;
Memo1.Lines.Add('设备:='+StrPas(pDevice));
Memo1.Lines.Add('驱动程序:= ' + StrPas(pDriver));
Memo1.Lines.Add('端口 := ' + StrPas(pPort));
FreeMem(pDevice, cchDeviceName);
FreeMem(pDriver, MAX_PATH);
FreeMem(pPort, MAX_PATH);
结尾;
结尾;