zoukankan      html  css  js  c++  java
  • Using RUNDLL32.exe to call a function within a dll

    Using RUNDLL32.exe to call a function within a dll
            
    Rundll32 is a utility included with Windows that allows you to execute an 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 will 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 odll dl.dll,rdl hallo

    Note: the function rdl is specified with __declspec (dllexport). This is needed in order to export the function such that its address can be gotten with GetProcAddress. rundll32 used GetProcAddress. Also, the function rdl is specified with extern "C" and __cdecl so that rdl is not name-mangled (in case it is compiled with a c++ compiler).
    Printing an HTML document

    rundll32.exe %windir%system32mshtml.dll,PrintHTML "C:x.html"

    Note, the document name (at least on my system) needs to be enclosed in quotes.

  • 相关阅读:
    Java实现web页面内容抓取
    Java写入文件的几种方法及性能对比
    Java实现导出excel
    win10系统安装VMware虚拟机软件以及linux系统
    oracle11g安装教程
    oracle怎么建立本地连接
    工厂模式
    计算一个字符串中每个字符出现的次数
    MySql多表查询
    如何查看MySql的sql语句性能
  • 原文地址:https://www.cnblogs.com/honeynm/p/4695885.html
Copyright © 2011-2022 走看看