我有来自第三方的Inproc COM服务器.如果它捕获特定类型的错误,我调用的函数之一将显示错误消息对话框.问题是我正在尝试批量处理数据,而我使用的数据源导致错误对话框弹出很多.如果它生成了1000个对话框,这不会成为问题,而是它会阻塞,直到您按OK才会返回该功能.

如何禁止显示对话框,或以编程方式按OK?
这是一个调用堆栈的副本,因为它正在等待我按OK
[Managed to Native Transition]
> System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Line 2198 + 0x1e bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Line 3422 + 0x1b bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3306 + 0xc bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Line 1495 + 0x31 bytes C#
UniversalDataImporter.exe!UniversalDataImporter.Program.Main() Line 18 + 0x1d bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) Line 2023 + 0x18 bytes C#
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x27 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object … 我试图使用Winapi检索Calculator(calc.exe)上的按钮文本.我已挂钩WH_CALLWNDPROC并且钩子工作正常.但是我无法检索任何按钮的文本(比如数字7).我正在使用GetDlgItemText:
TCHAR text[256];
GetDlgItemText((HWND)0x7068c, 0x89, text, strlen(text));
Run Code Online (Sandbox Code Playgroud)
这里0x7068c是数字7按钮的父窗口句柄,而0x89是它的控件ID.虽然我能够以编程方式单击它,但不会返回任何文本.
我究竟做错了什么?我尝试将SendMessage与WM_GETTEXT一起使用,但它仍然无效.我想采用这种方法并从其他应用程序中的按钮,文本框中检索文本.