Главная страница | назад





Article #17493: How do I change the default Windows printer?

 Question and Answer Database
FAQ2493C.txt How do I change the default Windows printer?
Category :Windows API
Platform :All
Product :C++Builder 3.x
Question:
How do I change the default Windows printer?
Answer:
You need to change the printer, driver, and port as listed in the
device key of the Windows section in the Windows.ini file, then
broadcast a system wide WM_WININICHANGE message.
Example:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char WinIniFileName[128];
TRegIniFile *x = new TRegIniFile(*WinIniFileName);
char S[64];
GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
StrCat(WinIniFileName, "\\win.ini");
x->CreateKey(WinIniFileName);
x->WriteString("windows","device","HP LaserJet Series II,HPPCL,LPT1:");
x->Free();
StrCopy(S, "windows");
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, &S);
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99