rundll32.exe调用Delphi Dll
来源:互联网 发布:洛枫网络软件公司 编辑:程序博客网 时间:2024/05/01 04:22
Microsoft Windows 95、Windows 98 和 Windows Millennium Edition (Me) 包含两个名为 Rundll.exe 和 Rundll32.exe 的命令行实用程序,通过这两个程序可调用从 16 位或 32 位 DLL 导出的函数。但是,使用 Rundll 和 Rundll32 程序并不能调用从任何 DLL 导出的任何函数。例如,不能使用这两个实用程序调用从系统 DLL 中导出的 Win32 API(应用程序编程接口)调用。这两个程序只允许您调用从 DLL 导出的、明确编写为供这两个程序调用的函数。本文详细介绍了 Rundll 和 Rundll32 程序在上面列出的 Windows 操作系统中的用法。
MIcrosoft Windows NT 4.0、Windows 2000 和 Windows XP 在发行时只附带 Rundll32。这些平台都不提供对 Rundll(Win16 实用程序)的支持。
Rundll 和 Rundll32 实用程序最初设计为仅供 Microsoft 内部使用。但是它们提供的功能非常通用,因此现在可供在一般情况下使用。请注意,Windows NT 4.0 发行时只随附 Rundll32 实用程序,并且只支持 Rundll32。
Rundll 与 Rundll32 之比较
Rundll 加载并运行 16 位 DLL,而 Rundll32 加载并运行 32 位 DLL。如果您向 Rundll 或 Rundll32 传递了错误的 DLL 类型,它可能无法运行,并且不显示任何错误信息。
//以上摘自MSDN
Rundll 命令行
Rundll 的命令行如下所示: RUNDLL.EXE <dllname>,<entrypoint> <optional arguments>
示例如下: RUNDLL32 MyDll.dll ShowVersion 1
注意: 这里函数名称是区分大小写的,不管你的dll是用BCB还是DELPHI编写的
这里的MyDll.dll是我们自己编写的一个dll,ShowVersion是其中的一个导出函数,定义形式为
void CALLBACK
EntryPointW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine,
int nCmdShow);
第三个参数就是我们输入的参数,也就是1,其他的可以不用写,直接在命令行模式下是得不到函数的返回值的,可以利用shellexecute或者winexec在代码中获取
下面分别给个Delphi和BCB的dll事例:
{$R *.res}
function ShowForm(hwnd: HWND ; hinst: LongWord;lpszCmdLine: LPSTR ; nCmdShow: Integer ):BOOL;stdcall;
begin
Form1 := TForm1.Create(nil);
Form1.Show;
MessageBox(0,PChar(lpszCmdLine),'ddddd',0);
Result := true;
end;
procedure ShowVersion();
var
info: String;
begin
info := ' ABout DLLTest.dll'+#13#13+'Version V1.0.0.0'+#13+'Build 050912 By TOmmieShi';
MessageBox(0,PChar(info),'Version',0);
end;
exports
ShowForm,
ShowVersion;
//上面的这个delphi的事例是我随手写的一个测试例子,前者接收了我们输入的参数而已显示了一个窗体,后面的那个不需要输入参数,只是简单的显示了一个 对话框
BCB的:
//------------------------------------------------------------------------------
// Demo
//------------------------------------------------------------------------------
void CALLBACK Demo()
{
DemoFrm = new TDemoFrm(NULL);
DemoFrm->ShowModal();
}
extern "C" __declspec(dllexport) void CALLBACK WtSys_Info(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
String s;
int CmdType;
s = lpszCmdLine;
CmdType = StrToIntDef(s,1);
s = "";
switch (CmdType)
{
case 1: //返回dll版本信息
s = s +char(13)+"FileName: WtSys_DLL.dll";
s = s +char(13)+"Version : V1.0.9.x"
+char(13)+"Contact : 0516-7793810-3060"
+char(13)+"Mail : siyangwind@eyou.com\r"
+char(13)+"Build By TommieShi "+BuildTime;
MessageBox(hwnd,s.c_str(),"About WtSys_DLL",0);
break;
case 2: //
Demo();break;
default: //待定
s = s +char(13)+"FileName: WtSys_DLL.dll";
s = s +char(13)+"Version : V1.0.9.x"
+char(13)+"Build 050912 By TommieShi"
+char(13)+"Contact : 0516-7793810-3060"
+char(13)+"Mail : siyangwind@eyou.com";
MessageBox(hwnd,s.c_str(),"About WtSys_DLL",0);
};
}
//---------------------------------------------------------------------------
这个BCB的dll是我实际使用的,通过输入命令行
rundll32 WtSys_DLL.dll WtSys_Info 1
我可以查看我的 关于 信息
输入 rundll32 WtSys_DLL.dll WtSys_Info 2
我可以调出dll里我所设计的demo窗体对我们的设备进行调试(我们为该公司提供的是设备和dll)
关于这个导出函数我们如果不需要为它传递参数信息的话那么我们可以随意的设计这个函数,
比如就是一个过程或者function,
感言:我觉得dll里有个这样的导出函数挺不错的,也就比平时的dll多写个函数而已,但有时能给我们带很很多便利。
rundll32还可以调用exe里的功能的,不过测试了几次没成功,大家如果有知道的可以告诉我一下,如
命令列: rundll32.exe user.exe,restartwindows
功能: 强行关闭所有程式并重启机器。
MIcrosoft Windows NT 4.0、Windows 2000 和 Windows XP 在发行时只附带 Rundll32。这些平台都不提供对 Rundll(Win16 实用程序)的支持。
Rundll 和 Rundll32 实用程序最初设计为仅供 Microsoft 内部使用。但是它们提供的功能非常通用,因此现在可供在一般情况下使用。请注意,Windows NT 4.0 发行时只随附 Rundll32 实用程序,并且只支持 Rundll32。
Rundll 与 Rundll32 之比较
Rundll 加载并运行 16 位 DLL,而 Rundll32 加载并运行 32 位 DLL。如果您向 Rundll 或 Rundll32 传递了错误的 DLL 类型,它可能无法运行,并且不显示任何错误信息。
//以上摘自MSDN
Rundll 命令行
Rundll 的命令行如下所示: RUNDLL.EXE <dllname>,<entrypoint> <optional arguments>
示例如下: RUNDLL32 MyDll.dll ShowVersion 1
注意: 这里函数名称是区分大小写的,不管你的dll是用BCB还是DELPHI编写的
这里的MyDll.dll是我们自己编写的一个dll,ShowVersion是其中的一个导出函数,定义形式为
void CALLBACK
EntryPointW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine,
int nCmdShow);
第三个参数就是我们输入的参数,也就是1,其他的可以不用写,直接在命令行模式下是得不到函数的返回值的,可以利用shellexecute或者winexec在代码中获取
下面分别给个Delphi和BCB的dll事例:
{$R *.res}
function ShowForm(hwnd: HWND ; hinst: LongWord;lpszCmdLine: LPSTR ; nCmdShow: Integer ):BOOL;stdcall;
begin
Form1 := TForm1.Create(nil);
Form1.Show;
MessageBox(0,PChar(lpszCmdLine),'ddddd',0);
Result := true;
end;
procedure ShowVersion();
var
info: String;
begin
info := ' ABout DLLTest.dll'+#13#13+'Version V1.0.0.0'+#13+'Build 050912 By TOmmieShi';
MessageBox(0,PChar(info),'Version',0);
end;
exports
ShowForm,
ShowVersion;
//上面的这个delphi的事例是我随手写的一个测试例子,前者接收了我们输入的参数而已显示了一个窗体,后面的那个不需要输入参数,只是简单的显示了一个 对话框
BCB的:
//------------------------------------------------------------------------------
// Demo
//------------------------------------------------------------------------------
void CALLBACK Demo()
{
DemoFrm = new TDemoFrm(NULL);
DemoFrm->ShowModal();
}
extern "C" __declspec(dllexport) void CALLBACK WtSys_Info(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
String s;
int CmdType;
s = lpszCmdLine;
CmdType = StrToIntDef(s,1);
s = "";
switch (CmdType)
{
case 1: //返回dll版本信息
s = s +char(13)+"FileName: WtSys_DLL.dll";
s = s +char(13)+"Version : V1.0.9.x"
+char(13)+"Contact : 0516-7793810-3060"
+char(13)+"Mail : siyangwind@eyou.com\r"
+char(13)+"Build By TommieShi "+BuildTime;
MessageBox(hwnd,s.c_str(),"About WtSys_DLL",0);
break;
case 2: //
Demo();break;
default: //待定
s = s +char(13)+"FileName: WtSys_DLL.dll";
s = s +char(13)+"Version : V1.0.9.x"
+char(13)+"Build 050912 By TommieShi"
+char(13)+"Contact : 0516-7793810-3060"
+char(13)+"Mail : siyangwind@eyou.com";
MessageBox(hwnd,s.c_str(),"About WtSys_DLL",0);
};
}
//---------------------------------------------------------------------------
这个BCB的dll是我实际使用的,通过输入命令行
rundll32 WtSys_DLL.dll WtSys_Info 1
我可以查看我的 关于 信息
输入 rundll32 WtSys_DLL.dll WtSys_Info 2
我可以调出dll里我所设计的demo窗体对我们的设备进行调试(我们为该公司提供的是设备和dll)
关于这个导出函数我们如果不需要为它传递参数信息的话那么我们可以随意的设计这个函数,
比如就是一个过程或者function,
感言:我觉得dll里有个这样的导出函数挺不错的,也就比平时的dll多写个函数而已,但有时能给我们带很很多便利。
rundll32还可以调用exe里的功能的,不过测试了几次没成功,大家如果有知道的可以告诉我一下,如
命令列: rundll32.exe user.exe,restartwindows
功能: 强行关闭所有程式并重启机器。
0 0
- rundll32.exe调用Delphi Dll
- Rundll32.exe 调用DLL自定义导出函数
- rundll32.exe加载dll
- 使用rundll32.exe运行dll函数
- 使用rundll32.exe运行dll函数
- 使用rundll32.exe运行dll函数
- 使用rundll32.exe运行dll函数
- 用rundll32调用shell32.dll的资源
- rundll32.exe
- rundll32.exe
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 利用rundll32.exe来运行自定义的dll导出函数
- 通过调用rundll32.exe来打开一些系统特定文件
- delphi调用外部EXE
- delphi dll 调用技巧
- delphi 调用dll窗体
- 在 BAT 做三年,普通程序员能拿多少工资?
- HttpRequest 获取数据
- 自定义 RecyclerView.ItemDecoration
- Reachability实时准确监听网络状态
- Android 中如何计算 App 的启动时间?
- rundll32.exe调用Delphi Dll
- STM32经keil mdk编译产生的.map文件分析
- 使用MFC的CListCtrl的排序功能
- 归来的微软
- 测试一下分类
- SLAM:使用G2O-ORB-SLAM(编译)
- Unable to destroy activity did not call through to super.onDestroy()
- dubbo开发异常总结
- CDH Hadoop CM方式安装