Delphi 2007
Windows Vista SP1
の環境で
デフォルトプリンタを変更したいのですが
どのようにすればいいのでしょうか?
これでできましたが、XPでしか確認してません。
Vista環境がないので。。。
procedure ChangeDefaultPrinter;
var
DevMode: THandle;
Device,Driver,Port: array[0..79] of Char;
s: String;
begin
Printer.PrinterIndex := 0; //変更したいプリンタのインデックス(Printer.Printersのインデックス)
Printer.GetPrinter(Device,Driver,Port,DevMode);
s := StrPas(Device) + ',' + StrPas(Driver) + ',' + StrPas(Port);
WriteProfileString('windows','device',PChar(s));
SendMessage(HWND_BROADCAST,WM_WININICHANGE,0,Longint(PChar('windows')));
end;
usesにPrintersを追加してください。
Delphi2009
たぬ吉さん、早速のご回答ありがとうございます。
試したところVista環境でも変更できました。
今後ともよろしくお願い致します。
ツイート | ![]() |