如果你想要改變Windows的缺省打印機,你必須在Windows的WIN.INI中改變設備鍵。
發送一條 WM_WININICHANGE 消息:
var
strIni: array[0..MAX_PATH] of Char;
arrWindows: array[0..64] of Char;
begin
GetWindowsDirectory(strIni, SizeOf(strIni));
StrCat(strIni, 'win.ini');
with TIniFile.Create(strIni) do
try
WriteString('Windows', 'device', 'HP LaserJet 4 Plus,HPPCL5MS,LPT1:');
finally
Free;
end;
StrCopy(arrWindows, 'Windows');
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@arrWindows));
end;