RasGetEntryDialParams (rasapi32)
Last changed: -95.111.240.197

.
Summary
The RasGetEntryDialParams function retrieves the connection information saved by the last successful call to the RasDial or RasSetEntryDialParams function for a specified phone-book entry.

C# Signature:

[DllImport("rasapi32.dll", SetLastError=true)]
static extern uint RasGetEntryDialParams(
   string lpszPhonebook,
   [In, Out] ref RASDIALPARAMS lprasdialparams,
   out bool lpfPassword);

VB Signature:

    <DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
    Public Function RasGetEntryDialParams( _
    ByVal lpszPhonebook As String, _
    <[In](), Out()> ByRef lprasdialparams As RASDIALPARAMS, _
    <Out()> ByRef lpfPassword As Boolean) As Integer
    End Function

.or.

Declare Function RasGetEntryDialParams Lib "rasapi32.dll" (TODO) As TODO

User-Defined Types:

RASDIALPARAMS

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    // Only this sample works on my Windows 7 + dotNET4
    [DllImport("rasapi32.dll", SetLastError = true)]
    public static extern uint RasGetEntryDialParamsW(
        string lpszPhonebook,
        IntPtr lprasdialparams,
        out bool lpfPassword);

    public RASDIALPARAMS GetDialParams() {
    var lpRasDialParams = new RASDIALPARAMS
    {
         szEntryName = "Some dial name"
    };

    // Initialize unmanged memory to hold the struct.
    IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RASDIALPARAMS)));

    // Copy the struct to unmanaged memory.
    Marshal.StructureToPtr(lpRasDialParams, pnt, true);

    bool lprPassword = false;

    var nRet = RasGetEntryDialParamsW(null, pnt, out lprPassword);
    if (nRet != 0)
    {
        // Clear unmanaged memory
        Marshal.FreeHGlobal(pnt);
        throw new Exception("Error text");
    }

    // Copy unmanaged memory to the struct.
    lpRasDialParams = (RASDIALPARAMS)Marshal.PtrToStructure(pnt, typeof(RASDIALPARAMS));

    // Clear unmanaged memory
    Marshal.FreeHGlobal(pnt);

    return lpRasDialParams;
    }

Alternative Managed API:

http://www.codeplex.com/DotRas

Documentation