阅读:3244回复:2
添加打印机安装包制作 已结贴
本人最近一直在做一打印机项目,驱动程序已经写好后,我用VC编写了安装打印机的程序,使用了addprinter和addprinterdriver函数,并成功实现添加打印机和安装打印机驱动程序的功能,但该程序有无法在没有安装VC的机子上执行操作,所以不得不考虑制作安装打印机的安装包。
我在这里看到用inno setup可以制作驱动程序安装包,然后在网上下了一个,开始用它来做,但是一直到现在没成功,现在报错:指定的端口未定义,大家帮忙分析哈,有帮助的我会给你加分,谢谢! 大家请看代码如下: [Setup] AppName=AddPrinter AppVerName=AddPrinter Uninstallable=false UpdateUninstallLogAppName=false DisableDirPage=true DisableProgramGroupPage=true DefaultDirName={pf}\AddPrinter DisableStartupPrompt=true CreateAppDir=false [_ISTool] EnableISX=true [Code] { C declaration typedef struct _PRINTER_INFO_2 { LPTSTR pServerName; LPTSTR pPrinterName; LPTSTR pShareName; LPTSTR pPortName; LPTSTR pDriverName; LPTSTR pComment; LPTSTR pLocation; LPDEVMODE pDevMode; LPTSTR pSepFile; LPTSTR pPrintProcessor; LPTSTR pDatatype; LPTSTR pParameters; PSECURITY_DESCRIPTOR pSecurityDescriptor; DWORD Attributes; DWORD Priority; DWORD DefaultPriority; DWORD StartTime; DWORD UntilTime; DWORD Status; DWORD cJobs; DWORD AveragePPM; } // PRINTER_INFO_2, *PPRINTER_INFO_2; //BOOL ClosePrinter( // HANDLE hPrinter // handle to printer object // ); // HANDLE AddPrinter( // LPTSTR *pName, // server name //DWORD Level, // printer information level //LPBYTE pPrinter // printer information buffer //); type TPrinterInfo2 = record pServerName : PChar; pPrinterName : PChar; pShareName : PChar; pPortName : PChar; pDriverName : PChar; pComment : PChar; pLocation : PChar; pDevMode : PChar; // LPDEVMODE pSepFile : PChar; pPrintProcessor : PChar; pDatatype : PChar; pParameters : PChar; pSecurityDescriptor : PChar; // PSECURITY_DESCRIPTOR Attributes : LongInt; Priority : LongInt; DefaultPriority : LongInt; StartTime : LongInt; UntilTime : LongInt; Status : LongInt; cJobs : LongInt; AveragePPM : LongInt; end; Handle = Cardinal; function ClosePrinter( pPrinter: Handle ): Boolean; external 'ClosePrinter@winspool.drv stdcall'; function AddPrinter( pName : PChar; Level: Longint; var pPrinter2: TPrinterInfo2): Handle; external 'AddPrinterA@winspool.drv stdcall'; function GetLastError() : Integer; external 'GetLastError@kernel32.dll'; function InitializeSetup: Boolean; var P2: TPrinterInfo2; hp: Handle; ercode: Integer; begin Result := true; P2.pPrinterName := 'TestPrinter'; P2.pDriverName := 'WinFax'; P2.pPrintProcessor := 'WinPrint'; P2.pPortName := 'FILE:'; P2.pComment := 'Test printer installation'; hp := AddPrinter( CastIntegerToString(0), 2, P2 ); if ( hp <> 0 ) then ClosePrinter( hp ) else begin Result := false; ercode := GetLastError(); // error codes samples // 1801 Printer Name not valid // 1802 Printer already exists // 1706 Port specified unknown // 1798 PrintProcessor unknown // 1797 PrinterDriver unkown MsgBox( 'Error ' + IntToStr(ercode) + ': ' + SysErrorMessage( ercode ), mbError, MB_OK ); end; end; 各位要多发表意见哦 |
|
沙发#
发布于:2009-11-27 06:49
竟然没人回答
还好已经完成 |
|
板凳#
发布于:2010-09-17 11:41
楼主怎么解决端口未定义这错误的呢
|
|