2

我正在使用 C# winforms 应用程序我是我的项目中的 dll,当从该 dll 调用该函数时,我从中得到了不需要的 MessageBox。是否可以阻止该 MessageBox?

4

4 回答 4

2

如果迫在眉睫,您可以启动一个线程,使用 WinAPI 或库按标题杀死任何打开的窗口。

我会求助于不那么苛刻的机制,比如首先更改 dll 或将更改请求发送给合适的人。

于 2011-01-11T12:32:32.070 回答
1

如果这是第三方 dll,则没有摆脱消息框的好选择。

但是,当 C# 编译为 IL 时,您可以查看字节码并删除对 的调用MessageBox.Show或将其替换为对Trace.WriteLine. 您可以使用SDK 附带的ildasm.exe/工具来执行此操作。ilasm.exe

于 2011-01-11T12:33:32.133 回答
0

You can study that dll with hex-editor, debugger or some resource viewer to find out how dialog box is created and then subscribe to that Windows event (Like OnCreate - surf WinAPI docs for info on Windows creation functions). In your event handler try to suppress dialog box and see if dll function is happy about the fact that dialog wasn't shown

于 2011-01-11T12:39:35.383 回答
0

如果您的 dll 是托管代码,您可以反编译它并删除 MessageBox 调用,如建议的 0xA3。如果您的 dll 是本机的,您可以使用API hooking。您可以在此处找到 WinAPI 挂钩示例。它在 C++ 中,但可以很容易地转换为 C#。

于 2011-01-11T12:52:47.830 回答