VB.NET: Implementing RasGetErrorString

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bhc

    #1

    VB.NET: Implementing RasGetErrorString

    i'm trying to wrap a RAS library, and i've found pretty solid examples
    for most RAS API calls...except for RasGetErrorStri ng. i've seen a C#
    example, but can't seem to get the right declaration and use in VB.NET.
    the current attempt is:
    ---
    Private Declare Auto Function RasGetErrorStri ng Lib "rasapi32.d ll"
    ( _
    ByVal ErrorValue As Integer, _
    ByRef ErrorString As String, _
    ByVal BufferSize As Integer _
    ) As Integer

    'And then in a button click somewhere...
    Dim errstr As String
    Dim err As Integer = 639
    Dim lbuff As Integer = 256

    Debug.WriteLine (RasGetErrorStr ing(err, errstr, lbuff))
    Debug.WriteLine (errstr)
    ---

    the call to RasGetErrorStri ng fails with an unhandled
    System.Executio nEngineExceptio n - even if i trap it in a Try...Catch
    block (?). any help would be appreciated...

  • bhc

    #2
    Re: VB.NET: Implementing RasGetErrorStri ng

    nevermind, i got it (sorry, just impatient i guess :).

    Private Declare Auto Function RasGetErrorStri ng Lib "rasapi32.d ll"
    ( _
    ByVal uErrorValue As Integer, _
    ByVal lpszErrorString As IntPtr, _
    ByVal cBufSize As Integer _
    ) As Integer

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: VB.NET: Implementing RasGetErrorStri ng

      "bhc" <bchorney@gmail .com> schrieb:[color=blue]
      > i'm trying to wrap a RAS library, and i've found pretty solid examples
      > for most RAS API calls...except for RasGetErrorStri ng. i've seen a C#
      > example, but can't seem to get the right declaration and use in VB.NET.
      > the current attempt is:
      > ---
      > Private Declare Auto Function RasGetErrorStri ng Lib "rasapi32.d ll"
      > ( _
      > ByVal ErrorValue As Integer, _
      > ByRef ErrorString As String, _
      > ByVal BufferSize As Integer _
      > ) As Integer
      >
      > 'And then in a button click somewhere...
      > Dim errstr As String
      > Dim err As Integer = 639
      > Dim lbuff As Integer = 256
      >
      > Debug.WriteLine (RasGetErrorStr ing(err, errstr, lbuff))
      > Debug.WriteLine (errstr)
      > ---
      >
      > the call to RasGetErrorStri ng fails with an unhandled
      > System.Executio nEngineExceptio n - even if i trap it in a Try...Catch
      > block (?). any help would be appreciated...[/color]

      \\\
      Private Declare Auto Function RasGetErrorStri ng Lib "rasapi32.d ll" ( _
      ByVal uErrorValue As Int32, _
      ByVal lpszErrorString As String, _
      ByVal cBufSize As Int32 _
      ) As Int32
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      Working...