In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Get the default printer name:
Function TForm1.GetDefaultPrinterName: string;var iSize: Integer; sIniFile, sSection, sKeyName: PChar;begin iSize: = 256; sIniFile: = 'win.ini'; sSection: =' windows'; sKeyName: = 'device'; SetLength (Result, iSize); GetPrivateProfileString (sSection, sKeyName, nil, PChar (Result), iSize, sIniFile); Result: = Copy (Result, 0, Pos (',', Result)-1); end
Change the default printer: Uses WinSpool required
Procedure ChangeDefaultPrinter (const Name: string); var W2KSDP: function (pszPrinter: PChar): Boolean; stdcall; H: THandle; Size, Dummy: Cardinal; PI: PPrinterInfo2;begin if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > = 5) then begin @ W2KSDP: = GetProcAddress (GetModuleHandle (winspl), 'SetDefaultPrinterA'); if @ W2KSDP = nil then RaiseLastOSError; if not W2KSDP (PChar (Name)) then RaiseLastOSError; end else begin if not OpenPrinter (PChar (Name), H, nil) then RaiseLastOSError Try GetPrinter (H, 2, nil, 0, @ Size); if GetLastError ERROR_INSUFFICIENT_BUFFER then RaiseLastOSError; GetMem (PI, Size); try if not GetPrinter (H, 2, PI, Size, @ Dummy) then RaiseLastOSError; Pi ^ .Attributes: = Pi ^ .Attributes or PRINTER_ATTRIBUTE_DEFAULT; if not SetPrinter (H, 2, PI, PRINTER_CONTROL_SET_STATUS) then RaiseLastOSError; finally FreeMem (PI); end Finally ClosePrinter (H); end;end; end; / / ChangeDefaultPrinterChangeDefaultPrinter function uses SetDefaultPrinterA under D7 and SetDefaultPrinterWprocedure TDM.ChangeDefaultPrinter (const Name: string) above Delphi2010; var Device: array [0.255] of Char; Driver: array [0.255] of char; Port: array [0.255] of char; s: array [0.255] of Char; hDeviceMode: THandle; I: Integer Begin for I: = 0 to Printer.Printers.Count-1 do if Printer.Printers.Strings [I] = name then begin Printer.PrinterIndex: = I; Break; end; Printer.GetPrinter (Device, Driver, Port, hDeviceMode); StrCopy (s, Device); StrCat (s,','); StrCat (s, Driver); StrCat (s,','); StrCat (s, Port); WriteProfileString ('windows',' device', 's) StrCopy (s, 'windows'); SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt (@ s)); end;// this function can also change the printer, the effect is not as good as above
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.