如何运行.dll程序?
我想使用 BASIC 语言使用 Run("someProgram.exe")
命令。这将打开第三个应用程序。
如果该程序使用 .dll(不确定是否可能)而不是 .exe 运行,我该如何编码?
提前致谢。
I want to use Run("someProgram.exe")
command using BASIC language. This will open the 3rd application program.
If that program running using .dll(not sure if it possible) not .exe, how can i code that?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果要从命令行执行 DLL 函数,请使用: Rundll.exe
请注意您导出的函数需要与 (C) 签名完全匹配:
如果不匹配,则未定义将发生什么,但您可能会崩溃。从 VB 类中的 dll 调用任意函数的正常例程是使用 声明声明。您必须知道要在编译时调用的函数的签名。
例如:
此代码从 advapi32.dll 调用“GetUserNameA”函数。有许多站点专门列出任意 Windows 函数的
Declare
语法,因此通常不难找到正确的语法。If you want to execute a DLL function from the command line, use: Rundll.exe
Note that your exported function is required to match exactly the (C) signature:
If it does not, it is undefined as to what will happen, but you will probably crash. The normal routine for calling arbitrary functions from dlls in class VB is to use the Declare statement. You must know the signature of the function you want to call at compile time.
For example:
This code calls the "GetUserNameA" function from advapi32.dll. There are many sites devoted to listing the
Declare
syntax for arbitrary windows functions, so it is not typically difficult to find the correct one.如果不了解 .dll 的性质,就很难回答。当然,没有办法简单地将 dll 放入某个工具中并期望它能够运行。它必须是一个 exe 文件。您可以创建自己的 shell/wrapper exe,它仅充当具有入口点的进程主机,然后触发 dll 上的方法。
我不确定这是否适合您的模型,但如果您处于可以要求这些 dll 包含实现接口的类的位置。假设 IRunnable 包含一个 Run() 方法。您可以创建一个 exe,它接收 dll 作为命令行参数,使用反射来查找 IRunnable,然后加载该类并调用 Run()。
Its hard to answer without understanding the nature of your .dll. Of course, there is no way to simply pop your dll into some harness and expect it to just run. It would have to be an exe for that. You could create your own shell/wrapper exe that simply acts as a process host with an entry point and then fires methods on the dll.
I'm not sure if this would fit your model but if you were in the position where you can require these dlls contain a class that implements an interface. Say IRunnable that contains a single Run() method. You could create an exe that that receives the dll as a command line argument, uses reflection to find IRunnable and then loads that class and calls Run().