Rundll32
Rundll32
這個(gè)運(yùn)行DLL的實(shí)用工具(Rundll32.exe)是包含在Windows中的,它能讓你去調(diào)用從一個(gè)32位DLL中導(dǎo)出的函數(shù)。但是那些被調(diào)用的函數(shù)必須遵循以下語法規(guī)則:
void CALLBACK EntryPoint(
? HWND hwnd,??????? // 父窗口的句柄
? HINSTANCE hinst,? // DLL的實(shí)例句柄
? LPTSTR lpCmdLine, // DLL將要解析的字符串
? int nCmdShow????? // 顯示狀態(tài)
);
請注意那個(gè)EntryPoint僅僅是一個(gè)為了表示真實(shí)函數(shù)名的一個(gè)占位符。對于一系列可能的顯示狀態(tài),請參見WinMain。
下面是Rundll32在命令行下的語法:
rundll32 DllName,FunctionName [Arguments]
DllName?
指定這個(gè)DLL的名字。這個(gè)名字不能包含空格,逗號,或引號。這個(gè)實(shí)用工具為了LoadLibrary這個(gè)函數(shù),將會(huì)用搜索標(biāo)準(zhǔn)文件記錄的方式來搜索這個(gè)DLL。因此,對于這個(gè)DLL,最好使用短文件名并且提供一個(gè)完整路徑。
FunctionName?
指定這個(gè)在DllName中被調(diào)用的函數(shù)的名字。要求在DllName和FunctionName之間有一個(gè)逗號(不帶任何空格)。
Arguments?
對于FunctionName的可選參數(shù)。
Rundll32使用LoadLibrary來載入這個(gè)指定的DLL,使用GetProcAddress函數(shù)來獲取函數(shù)地址,然后帶著這個(gè)指定的參數(shù)(如果有這個(gè)參數(shù)的話)去調(diào)用函數(shù)。當(dāng)這個(gè)函數(shù)返回時(shí),Rundll32將卸載這個(gè)DLL并退出。
Windows NT/2000:為這個(gè)函數(shù)創(chuàng)建一個(gè)Unicode版本是可能的。Rundll32首先嘗試去查找一個(gè)命名為EntryPointW的函數(shù)。如果無法找到該函數(shù),則會(huì)接著嘗試EntryPointA,再然后是EntryPoint。為了創(chuàng)建一個(gè)在Windows 95/98/Me上支持ANSI和Unicode的DLL,需要導(dǎo)出兩個(gè)函數(shù):EntryPointW和EntryPoint。
?
---------------------------------------------------以下是原文---------------------------------------------------
?
Rundll32
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
);
Note that EntryPoint is a placeholder for the actual function name. For a list of possible show states, see WinMain.
The following is the command-line syntax for Rundll32:
rundll32 DllName,FunctionName [Arguments]
DllName?
Specifies the name of the DLL. The name cannot contain spaces, commas, or quotation marks. The utility searches for the DLL using the search criteria documented for the LoadLibrary function. Therefore, it is best to use the short name and provide a full path for the DLL.?
FunctionName?
Specifies the name of the function to call in DllName. Requires a comma (without no spaces) between DllName and FunctionName.?
Arguments?
Optional arguments for FunctionName.?
Rundll32 loads the specified DLL using LoadLibrary, obtains the address of the function using the GetProcAddress function, and calls the function with the specified arguments, if any. When the function returns, Rundll32 unloads the DLL and exits.
Windows NT/2000: It is possible to create a Unicode version of the function. Rundll32 first tries to find a function named EntryPointW. If it cannot find this function, it tries EntryPointA, then EntryPoint. To create a DLL that supports ANSI on Windows 95/98/Me and Unicode otherwise, export two functions: EntryPointW and EntryPoint.
?
總結(jié)
- 上一篇: 李开复:如何设计你的年度计划
- 下一篇: 统计学基础--假设检验