Googling "rundll32", the third hit was a link to the documentation,
http://support.microsoft.com/kb/164787
According to this documentation, rundll32 calls a user-specified function with a signature of type wWinMain (in addition to the first argument, a window handle is used here instead of an instance handle),
void CALLBACK EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
So try this:
// File [foo.cpp]
Create and run:
[d: \ dev \ test]
> cl foo.cpp foo.def user32.lib / MD / LD / D _CRT_SECURE_NO_WARNINGS
foo.cpp
Creating library foo.lib and object foo.exp
[d: \ dev \ test]
> rundll32 foo.dll, sayHello
[d: \ dev \ test]
> _
The output is presented in the own console window created using AllocConsole , which is usually necessary, since rundll32 is a GUI subsystem program (this also causes freopen calls).
To present the output in an existing console window, you can simply omit calls to AllocConsole and freopen and redirect standard rundll32 output to the channel. For instance. standard output can be connected via Windows & rsquo; more when the output is just a few lines, or through some * nix cat utility for more lines. However, in the standard shell [cmd.exe], it does not work to simply redirect the output to con .
source share