Environment: Windows NT4 SP3; Developed with Visual C++ 6 SP3
SetPrinter is a simple DLL COM that enables you to programmatically set the default printer: * The problem that I faced is that if you attempt to specify the default printer from an application, that printer is not actually realized as the default printer by Windows immediately.
You can resolve this problem by doing the following: * First, install the driver printer on your machine; * If you work on Windows 2000, you must use 'SetDefaultPrinter' followed by the printer's name. * If you work on Windows 98 or Windows NT 4 you must first call the OpenPrinter function in order to retrieve the printer handle. Then you need to call the GetPrinter function twice in order to obtain the printer informations. You then need to call the WriteProfileString function (Windows NT) * Finally, you must notify all windows of this new Windows setting as follows: lResult = SendMessageTimeout(HWND_BR
Or instead of going through all of that, you can use my COM component and its DPSetDefaultPrinter method. Here is the code for that method so that you can see all that needs to take place to perform a seemingly very simple task. STDMETHODIMP CCustomPrinter::DPSetDefau
Installation
* On each machine where you want to use the SetPrinter component, you must register the DLL as follows: regsvr32 ...
Main Topics
Browse All Topics





by: naspinskiPosted on 2009-09-27 at 00:06:42ID: 25433009
hmm, well here is the c# version... it won't be as clean in VB without lambdas, but I will try and figure it out
Select allOpen in new window