Question

I'm trying to programmatically add a program to the Excluded Application List so that if it crashes, I don't receive the 'Debug/ Close Program' dialog box. It needs to be in vba as it will be part of a larger program written in vba.

Below is my attempt to convert the C++ code found here to vba

Private Declare PtrSafe Function WerAddExcludedApplication Lib "User32" _
        (ByVal pwzExeName As String, ByVal bAllUsers As Long) As Long

Sub test()
    WerAddExcludedApplication "MyApp.exe", 1
End Sub

Any anyone help me with this?

Thanks.

abousetta

Was it helpful?

Solution

You should check declarations. This API is not exported by user32.dll.

Reference said library is wer.dll.

And this function needs Unicode string. So, you have to pass it. Like below

s = "myapp.exe"
s = StrConv(s, vbUnicode)
WerAddExcludedApplication(s, 1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top