本文介绍了WM 5.0 InternetErrorDlg返回ERROR_INVALID_HANDLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个WM 5.0 CF 3.5 vb.net应用程序,试图将Internet错误列表显示为用于对Web服务进行身份验证的证书列表。 I 收到错误ERROR_INVALID_HANDLE。 我将hWnd参数设置为Null,WinForm的Handle属性,或者使用coredll.dll中的GetDesktopWindow获取句柄,我得到此错误。 

我的代码如下。 任何帮助将不胜感激

I have written a WM 5.0 CF 3.5 vb.net app that tries to pinvoke InternetErrorDlg to display a list of certificates to use for authentication
to a web service. I  getting the error ERROR_INVALID_HANDLE.  I get this error whether set the hWnd parameter to Null, the Handle property of the WinForm, or I use GetDesktopWindow from coredll.dll to obtain the handle. 

My is code is below.  Any help would be greatly appreciated

  < DllImport("WinInet.dll",_
   EntryPoint:="InternetErrorDlg",_
   CharSet:= CharSet.Unicode,SetLastError:= True)> _
  私人共享功能InternetErrorDlg显示(_
&NBSP;&NBSP; BYVAL的hWnd作为IntPtr的,_
&NBSP;&NBSP;为ByRef hRequest作为IntPtr的,_
&NBSP;&NBSP; BYVAL dwError作为的Int32,_
   ByVal dwFlags作为Int32,_
   ByRef lpdwIndex As IntPtr)作为Int32
   结束函数

  <DllImport("WinInet.dll", _
   EntryPoint:="InternetErrorDlg", _
   CharSet:=CharSet.Unicode, SetLastError:=True)> _
   Private Shared Function InternetErrorDlg( _
   ByVal hWnd As IntPtr, _
   ByRef hRequest As IntPtr, _
   ByVal dwError As Int32, _
   ByVal dwFlags As Int32, _
   ByRef lpdwIndex As IntPtr) As Int32
    End Function

iFlags = FLAGS_ERROR_UI_FLAGS_GENERATE_DATA + FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS
lppvData = IntPtr.Zero
hWnd = GetDesktopWindow()
  iResult = InternetErrorDlg(hWnd,m_Request, iError,iFlags,lppvData)

 选择案例iResult

iFlags = FLAGS_ERROR_UI_FLAGS_GENERATE_DATA + FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS
lppvData = IntPtr.Zero
hWnd = GetDesktopWindow()
 iResult = InternetErrorDlg(hWnd, m_Request, iError, iFlags, lppvData)

 Select Case iResult

          案例ERROR_SUCCESS

          Case ERROR_SUCCESS

          情况下ERROR_CANCELLED
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; m_ErrorMessage ="的功能是&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;病例ERROR_INTERNET_FORCE_RETRY
&NBSP;&NBSP;&NBSP;&NBSP由用户"

           Case ERROR_CANCELLED
                   m_ErrorMessage = "The function was canceled by the user"

&NBSP取消;                m_ErrorMessage ="功能需要重做其请求"

          Case ERROR_INTERNET_FORCE_RETRY
                  m_ErrorMessage = "Function needs to redo its request"

  ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;病例ERROR_INVALID_HANDLE
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; m_ErrorMessage = "InternetErrorDlg显示:句柄到父窗口无效"
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;病例否则
&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; m_ErrorMessage = "InternetErrorDlg显示:错误#" + iResult.ToString()
结束Se lect

         Case ERROR_INVALID_HANDLE
                m_ErrorMessage = "InternetErrorDlg: The handle to the parent window is invalid"
          Case Else
                 m_ErrorMessage = "InternetErrorDlg: Error #" + iResult.ToString()
End Select

 

推荐答案


这篇关于WM 5.0 InternetErrorDlg返回ERROR_INVALID_HANDLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 11:27