문제

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

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top