Rundll32.exe dll의 함수를 어떻게 실행합니까

3654 단어 VC++Windows
1. 개요
winddows의 DLL 함수는 Rundll32를 직접 사용할 수 있습니다.exe가 실행했습니다.그러나 dll 내보내기 함수는 일정한 형식에 부합되어야 합니다.
영어 원본은 다음과 같습니다.
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.

 
번역문: (인터넷에서 찾은)
Rundll32
    DLL     (Rundll32.exe)    Windows  ,          32 DLL      。                    :

void CALLBACK EntryPoint(
  HWND hwnd,        //       
  HINSTANCE hinst,  // DLL     
  LPTSTR lpCmdLine, // DLL        
  int nCmdShow      //     
);
     EntryPoint                    。            ,   WinMain。

   Rundll32        :
rundll32 DllName,FunctionName [Arguments]
DllName 
    DLL   。          ,  ,   。        LoadLibrary    ,                   DLL。  ,    DLL,                  。
FunctionName 
     DllName          。   DllName FunctionName       (      )。
Arguments 
  FunctionName     。
Rundll32  LoadLibrary        DLL,  GetProcAddress         ,           (         )     。        ,Rundll32     DLL   。

Windows NT/2000:         Unicode      。Rundll32            EntryPointW   。         ,      EntryPointA,    EntryPoint。       Windows 95/98/Me   ANSI Unicode DLL,        :EntryPointW EntryPoint。

 
호출 방법
명령줄에서rundll32.exe projectname.dll, dllfun
 
예: (인터넷에서 찾은)
// dllmain.cpp : Defines the entry point for the DLL application.

#include "stdafx.h"
#include 
#include "fun.h"
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)


{


// MessageBox(NULL,L"lll",L"lllkk",MB_OK);
StartWork(NULL);


return;


}


좋은 웹페이지 즐겨찾기