使用印表機;
{$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);
結尾;
結尾;