Using RUNDLL32.exe to call a function within a DLL
Rundll32 is a utility included with Windows This allows you to execute a exported dll-function from a command line.
Consider the following (exported) function in a DLL:
#include <windows.h>
extern "C" __declspec (dllexport) void __cdecl RDL (
HWND hwnd,//Handle to owner window
HINSTANCE hinst,//instance handle for the DLL
LPTSTR lpCmdLine,//String the DLL would parse
int nCmdShow//show State
)
{
:: MessageBox (0,lpcmdline,0,0);
}
BOOL apientry DllMain (HANDLE hmodule,
DWORD Ul_reason_for_call,
LPVOID lpreserved)
{
return TRUE;
}
The function RDL within the DLL can now be called using rundll32:
rundll32 C:\path\to\dll\rdl.dll,rdl Hallo
note:the function RDL is specified with __declspec (dllexport). This was needed in order to export the function such, its address can gotten with GetProcAddress. Rundll32 used GetProcAddress. Also, the function RDL is specified with extern "C" and __cdecl so the RDL are not name-mangled (in case it is compiled WI Th a C + + compiler).
Printing an HTML document
rundll32.exe%windir%\system32\mshtml.dll,printhtml "C:\x.html"
Note, the document name (at least of the My system) needs to is enclosed in quotes.
Using RUNDLL32.exe to call a function within a DLL