您的位置:首页 > 数码 > MP3 > WinSpool-GetPrinterDriverDirectory、AddPrinterDriver、AddPrint

WinSpool-GetPrinterDriverDirectory、AddPrinterDriver、AddPrint

luyued 发布于 2011-02-20 08:42   浏览 N 次  

{$R *.dfm}

uses WinSpool,Printers;

procedure TForm1.Button3Click(Sender: TObject);

var pPrinter:PPrinterInfo2;

// _PRINTER_INFO_2W = record

// pServerName: PWideChar;

// pPrinterName: PWideChar;

// pShareName: PWideChar;

// pPortName: PWideChar;

// pDriverName: PWideChar;

// pComment: PWideChar;

// pLocation: PWideChar;

// pDevMode: PDeviceModeW;

// pSepFile: PWideChar;

// pPrintProcessor: PWideChar;

// pDatatype: PWideChar;

// pParameters: PWideChar;

// pSecurityDescriptor: PSecurityDescriptor;

// Attributes: DWORD;

// Priority: DWORD;

// DefaultPriority: DWORD;

// StartTime: DWORD;

// UntilTime: DWORD;

// Status: DWORD;

// cJobs: DWORD;

// AveragePPM: DWORD;

// end;

pName:PChar;

Level:DWord;

pDriver:PDriverInfo3;

// _DRIVER_INFO_3W = record

// cVersion: DWORD;

// pName: PWideChar; { QMS 810 }

// pEnvironment: PWideChar; { Win32 x86 }

// pDriverPath: PWideChar; { c:\drivers\pscript.dll }

// pDataFile: PWideChar; { c:\drivers\QMS810.PPD }

// pConfigFile: PWideChar; { c:\drivers\PSCRPTUI.DLL }

// pHelpFile: PWideChar; { c:\drivers\PSCRPTUI.HLP }

// pDependentFiles: PWideChar; { PSCRIPT.DLL\0QMS810.PPD\0PSCRIPTUI.DLL\0PSCRIPTUI.HLP\0PSTEST.TXT\0\0 }

// pMonitorName: PWideChar; { "PJL monitor" }

// pDefaultDataType: PWideChar; { "EMF" }

// end;

hPrinter:Thandle;

PrinterDriverPath:PChar;

dwNeeded:DWord;

begin

//AddPrinterDriver调用以前,驱动程序所需要的所有文件必须要拷贝到GetPrinterDriverDirectory指定的目录下

//CopyBOOL GetPrinterDriverDirectory(

// __in LPTSTR pName, {服务器的名字,nil表示使用本地系统}

// __in LPTSTR pEnvironment, {环境,nil表示使用当前系统环境 }

// __in DWORD Level, {必须为1}

// __out LPBYTE pDriverDirectory, {指定一个缓冲区}

// __in DWORD cbBuf, {缓冲区大小}

// __out LPDWORD pcbNeeded {实际读入的字节数}

//);

GetPrinterDriverDirectory(nil,nil,1,PrinterDriverPath,0,dwNeeded);

System.GetMem(PrinterDriverPath,dwNeeded);

GetPrinterDriverDirectory(nil,nil,1,PrinterDriverPath,dwNeeded,dwNeeded);

//Showmessage(PrinterDriverPath);

Edit1.Text:=PrinterDriverPath; {C:\WINDOWS\System32\spool\DRIVERS\W32X86}

System.New(pDriver);

try

pDriver^.cVersion:=3; //版本

pDriver^.pName:='HP DeskJet 420'; //名称

pDri

广告赞助商