display | more...
A dynamic link library provided by Microsoft in all 32-bit based Windows operating systems. rundll32, which is the 32-bit analog of rundll, allows programs to export functions from the Windows API. With the extinction of Windows 3.1 and the 16-bit technology, rundll32 has taken a prominent role in Windows programming.

According to http://www.mvps.org, the steps in the functioning of rundll32 are:

1. It parses the command line.

2. It loads the specified DLL via LoadLibrary().

3. It obtains the address of the function via GetProcAddress().

4. It calls the function, passing the command line tail which is the .

5. When the function returns, Rundll.exe unloads the DLL and exits.

rundll32 is a small program (not a DLL) that comes with Microsoft Windows 95, 98, NT, 2000 etc. It is used to load a dynamic link library (DLL) and call an exported function (entry point) in the DLL.

The function to be called in the DLL must be written for this purpose. It is not possible to call the Windows API functions in the system DLL:s (kernel32, GDI32, user32 etc). The exception is shell32.dll, which exports some functions that can be called by rundll32.

More specifically, the function must have this prototype:

void CALLBACK EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
void CALLBACK EntryPointW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow);
(NT/2000 only)


rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl

Executing this example will open the "Sound and Multimedia properties" control panel applet. shell32.dll is the DLL that is loaded, Control_RunDLL the function that is called and mmsys.cpl is an argument that is passed to the function (in the lpszCmdLine parameter).

rundll32.exe shell32.dll,SHFormatDrive

This will start the Format A:\ utility that is normally accessed by right-clicking the floppy drive icon. (It will not start formatting without asking...)

rundll32 is used a lot by the Windows shell (Explorer). Just open Regedit and search for "rundll32" for some more examples. It is mostly used when double-clicking certain files.

For more information, see the article Q164787 in the Microsoft Knowledge Base.

Log in or register to write something here or to contact authors.