devicehelper.vb的问题

时间:2011-11-30 12:36:31

标签: vb.net

有没有人知道为什么我在运行下面的代码时会收到错误“DirectCast(错误,SetupApiError)= InWow64 {-536870347}”?我在行上调用SetupDiCallClassInstaller方法时遇到此错误:Case SetupApiError.NoAssociatedClass To SetupApiError.OnlyValidateViaAuthenticode

Throw New Win32Exception("SetupAPI error: " & DirectCast(err, SetupApiError).ToString)

Dim result As Boolean = SetupDiSetClassInstallParams(handle, diData, params, Marshal.SizeOf(params))
    If result = False Then Throw New Win32Exception
    result = SetupDiCallClassInstaller(DiFunction.PropertyChange, handle, diData)
    If result = False Then
        Dim err As Integer = Marshal.GetLastWin32Error
        Select Case err
            Case Is = SetupApiError.NotDisableable
                Throw New ArgumentException("That device can't be disabled! Look in the device manager!")
            Case SetupApiError.NoAssociatedClass To SetupApiError.OnlyValidateViaAuthenticode
                Throw New Win32Exception("SetupAPI error: " & DirectCast(err, SetupApiError).ToString)
            Case Else
                Throw New Win32Exception
        End Select
    End If

1 个答案:

答案 0 :(得分:2)

从64位版本的Windows上运行的32位进程调用SetupDiCallClassInstaller()会很不高兴。这很容易在托管程序中修复。右键单击EXE项目,“属性”,“编译”选项卡,向下滚动,“高级编译选项”按钮。将目标CPU设置从x86更改为AnyCPU。