Jump to content

Recommended Posts

Posted

I've got the following call:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /?

How would I call this using DllCall?

DllCall('printui.dll', 'int', 'PrintUIEntry', 'str', '/?') does not seem to work

Posted

Having a quick look at the DLL on XP Pro SP2, there isn't an entry named "PrintUIEntry", instead, its "PrintUIEntryW". However, running that causes the DLL to give me an error (Not a crash, just an error message) saying the operation couldn't be completed.

DllCall('printui.dll', 'int', 'PrintUIEntryW', 'str', '/?')
  • Administrators
Posted

Having a quick look at the DLL on XP Pro SP2, there isn't an entry named "PrintUIEntry", instead, its "PrintUIEntryW".  However, running that causes the DLL to give me an error (Not a crash, just an error message) saying the operation couldn't be completed.

DllCall('printui.dll', 'int', 'PrintUIEntryW', 'str', '/?')

W is the wide (unicode) version of the DLL. A is the ANSI version. The DLLCall in autoIt automatically tries FunctionName and FunctionNameA. But if there is only a unicode version then it will fail. Maybe a wstr parameter type is required that does the conversion.


 

  • Administrators
Posted

So I guess this wont work unless AutoIt has unicode support or a function to translate the strings?

Correct. Should be an easy change though, I'll have a quick look at it.


 

  • Administrators
Posted

Heh, not quite so simple. DLLs that RunDLL can call have to be passed certain parameters. The unicode bit (which I've almost done) is but one part of it:

The platform SDK has this to say about rundll32:

<quote>

The Run DLL utility (Rundll32.exe) included in Windows enables you to call

functions exported from a 32-bit DLL. These functions must have the following

syntax:

void CALLBACK EntryPoint(

HWND hwnd,        // handle to owner window

HINSTANCE hinst, // instance handle for the DLL

LPTSTR lpCmdLine, // string the DLL will parse

int nCmdShow      // show state

);

</quote>

So the prototype declaration would be

Procedure PrintUIEntryW( wnd: HWND;

                        inst: HMODULE;

                        lpCmdLine: PWideChar;

                        nCmdShow: Integer ); stdcall;

external 'printUI.dll';

Anything you would pass to rundll32 after the procedure name, excluding the

first blank, would be passed as a single widestring in lpCmdLine, with

parameters that contain blanks themselves enclosed in double quotes.

As to *what* to pass for the parameters, well, wnd should be the window

handle of your applications main window, or 0 if you don't have a window.

inst should probably be the module handle of printUI.DLL (you can get that

using GetModuleHandle), but i was unable to find any specific info about

that. What to pass for lpCmdLine is of course specific to the function

itself. I was unable to find any mention of PrintUI or PrintUIEntry in the

latest MSDN library, so no help here. nCmdShow is one of the show states

documented for the ShowWindow API, e.g SW_SHOWNORMAL.


 

  • Administrators
Posted

This brings up the /? dialog at least. I'll upload the code in a while, just have to do the conversion back from unicode to ansi for those functions that return strings.

DllCall('printui.dll', 'none', 'PrintUIEntryW', 'hwnd', 0, 'ptr', 0, 'wstr', '/?', 'int', @SW_SHOWNORMAL)


 

Posted

Well, take it easy. It's not urgent. I've just used Run('rundll32 ...').

Besides I'm on holidays in a few minutes.

  • Administrators
Posted

Well, take it easy. It's not urgent. I've just used Run('rundll32 ...').

Besides I'm on holidays in a few minutes.

Done and uploaded.

I don't intend to do anything either for a few days. Have to make the trip to see the parents tomorrow.......


 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...