S
seasnake
Unregistered / Unconfirmed
GUEST, unregistred user!
用的是这段程序:
procedure TprintSelForm.GetPrinterInfo;
var
pDevice: pChar;
pDriver: pChar;
pPort: pChar;
hDMode: THandle;
begin
GetMem(pDevice, cchDeviceName);
GetMem(pDriver, MAX_PATH);
GetMem(pPort, MAX_PATH);
try
Printer.GetPrinter(pDevice, pDriver, pPort, hDMode);
// label1.Caption := '打印机:' + StrPas(pDevice);
if lStrLen(pDriver) = 0 then
begin
GetProfileString('Devices', pDevice, '', pDriver, MAX_PATH);
pDriver[pos(',', pDriver) - 1] := #0;
end;
if lStrLen(pPort) = 0 then
label2.Caption := '端 口:' + GetPortName(StrPas(pDevice))
// GetProfileString('Devices', pDevice, '', pPort, MAX_PATH);
// lStrCpy(pPort, @pPort[lStrLen(pPort) + 2]);
else
label2.Caption := '端 口:' + StrPas(pPort);
//label2.Caption := 'Driver := ' + StrPas(pDriver);
except
label1.Caption := '打印机:没有安装打印机';
label2.Caption := '端 口:没有安装打钱机';
end;
FreeMem(pDevice, cchDeviceName);
FreeMem(pDriver, MAX_PATH);
FreeMem(pPort, MAX_PATH);
end;
是取出的pDevice有问题!
procedure TprintSelForm.GetPrinterInfo;
var
pDevice: pChar;
pDriver: pChar;
pPort: pChar;
hDMode: THandle;
begin
GetMem(pDevice, cchDeviceName);
GetMem(pDriver, MAX_PATH);
GetMem(pPort, MAX_PATH);
try
Printer.GetPrinter(pDevice, pDriver, pPort, hDMode);
// label1.Caption := '打印机:' + StrPas(pDevice);
if lStrLen(pDriver) = 0 then
begin
GetProfileString('Devices', pDevice, '', pDriver, MAX_PATH);
pDriver[pos(',', pDriver) - 1] := #0;
end;
if lStrLen(pPort) = 0 then
label2.Caption := '端 口:' + GetPortName(StrPas(pDevice))
// GetProfileString('Devices', pDevice, '', pPort, MAX_PATH);
// lStrCpy(pPort, @pPort[lStrLen(pPort) + 2]);
else
label2.Caption := '端 口:' + StrPas(pPort);
//label2.Caption := 'Driver := ' + StrPas(pDriver);
except
label1.Caption := '打印机:没有安装打印机';
label2.Caption := '端 口:没有安装打钱机';
end;
FreeMem(pDevice, cchDeviceName);
FreeMem(pDriver, MAX_PATH);
FreeMem(pPort, MAX_PATH);
end;
是取出的pDevice有问题!