Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   SetDefaultPrinter call via System Plug-in (http://forums.winamp.com/showthread.php?t=267221)

TJK 5th March 2007 21:28

SetDefaultPrinter call via System Plug-in
 
Hello

I'm trying to use the System plug-in to call the SetDefaultPrinter function (which I understand is availabel on my Windows XP system), but I'm not having much success.

I found an earlier posting (here) and decided to start by copying the GetDefaultPrinter example, but when I use the following:

Quote:

System::Call 'winspool::GetDefaultPrinter(t .r0, *i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK $0
I just get an empty message box ($0=NULL).

Similarly when I try the following:

Quote:

System::Call 'winspool::SetDefaultPrinter(*t "PrinterName")'
The default printer doesn't change.

This is the first time I've use the System plug-in, and though I've read the help and tutorial I'm afraid I don't seem to be grasping it.

Any help and suggestions to point me in the right direction would be gratefully received.

TIA

Tim

cchian 6th March 2007 02:26

Here is one way to do it:

ExecWait 'rundll32 printui.dll,PrintUIEntry /y /n "HP LaserJet 4240 PCL 6"'

cchian 6th March 2007 02:48

Here is one way to do it:

ExecWait 'rundll32 printui.dll,PrintUIEntry /y /n "HP LaserJet 4240 PCL 6"'

TJK 6th March 2007 08:18

Thanks cchian

That works a lot better.

Regards

Tim

CancerFace 6th March 2007 13:00

Looking at this MSDN page I think that the correct syntax for the GetDefaultPrinter function should be:
code:
System::Call 'winspool::GetDefaultPrinterA(*t .r0,i ${NSIS_MAX_STRLEN})i.r1'
and you should get a non-zero value at $1 if the function succeeds, along with the printer name at $0. You could try adding ?e at the end to get extended error information (on $2):
code:
System::Call 'winspool::GetDefaultPrinterA(*t .r0, i ${NSIS_MAX_STRLEN})i.r1 ?e'
Pop $2

Also the SetDefaultPrinter call should like this:
code:
System::Call 'winspool::SetDefaultPrinterA(*t "PrinterName")i.r0'
and I think you would have to experiment a bit with both functions to figure out the format of PrinterName
Hope this helps ...
CF


All times are GMT. The time now is 17:31.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.