Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

RasDial (rasapi32)
 
.
Summary
The RasDialDlg function establishes a RAS connection using a specified phone-book entry and the credentials of the logged-on user. The function displays a stream of dialog boxes that indicate the state of the connection operation.
Summary
The RasDial function establishes a RAS connection between a RAS client and a RAS server. The connection data includes callback and user-authentication information.

C# Signature:

[DllImport("Rasdlg.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool RasDialDlg(
    IntPtr phoneBook,
    string entryName,
    IntPtr phoneNumber,
    ref RASDIALDLG info);

VB Signature:

TODO

User-Defined Types:

public const int ERROR_SUCCESS = 0;
[DllImport("rasapi32.dll",CharSet=CharSet.Auto)]
static extern uint RasDial([In]RASDIALEXTENSIONS lpRasDialExtensions, [In]string lpszPhonebook, [In]RASDIALPARAMS lpRasDialParams, uint dwNotifierType, Delegate lpvNotifier, ref IntPtr lphRasConn);

[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
public struct RASDIALDLG
{
    public int dwSize;
    public IntPtr hwndOwner;
    public int dwFlags;
    public int xDlg;
    public int yDlg;
    public int dwSubEntry;
    public int dwError;
    public IntPtr reserved;
    public IntPtr reserved2;
}

VB Signature:

     VB.NET,   :)

Notes:

I don't use phoneBook and phoneNumber, so they are as IntPtr.

User-Defined Types:

    [StructLayout(LayoutKind.Sequential)]
    internal class RASDIALEXTENSIONS
    {
        public readonly int dwSize = Marshal.SizeOf(typeof(RASDIALEXTENSIONS));
        public uint dwfOptions = 0;
        public int hwndParent = 0;
        public int reserved = 0;
        public int reserved1 = 0;
        public RASEAPINFO RasEapInfo = new RASEAPINFO();
    }

Sample Code:

RASDIALDLG info = new RASDIALDLG();
info.dwSize = Marshal.SizeOf(info);
bool ret = RAW.RasDialDlg(IntPtr.Zero, "Some Connection Name", IntPtr.Zero, ref info);
if (ret == false && info.dwError != ERROR_SUCCESS)
    throw new Win32Exception(info.dwError);
    [StructLayout(LayoutKind.Sequential,CharSet = CharSet.Auto)]
    internal class RASDIALPARAMS
    {
        public int dwSize = Marshal.SizeOf(typeof(RASDIALPARAMS));
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.RAS_MaxEntryName+1)]
        public string szEntryName = null;
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.RAS_MaxPhoneNumber+1)]
        public string szPhoneNumber = null;
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.RAS_MaxCallbackNumber+1)]
        public string szCallbackNumber = null;
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.UNLEN+1)]
        public string szUserName = null;
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.PWLEN+1)]
        public string szPassword = null;
        [MarshalAs(UnmanagedType.ByValTStr,SizeConst =
            (int) RasFieldSizeConstants.DNLEN+1)]
        public string szDomain = null;
        public int dwSubEntry = 0;
        public int dwCallbackId = 0;
    }

Alternative Managed API:

http://www.codeplex.com/DotRas - The RasDialDialog component in the project exposes functionality provided by the RasDialDlg API.

Notes:

Documentation
RasDialDlg on MSDN

Tips & Tricks:

Sample Code:

Alternative Managed API:

http://www.codeplex.com/DotRas - The RasDialer component in the project exposes the functionality available through the RasDial API.

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions