"himu" <hi*********@healthasyst-dot-com.no-spam.invalid> wrote in message
news:40********@127.0.0.1...
Hi :idea: ,
I am looking for some input on “Dialup Connectivity” in .Net
My scenario being I will have a config file containing the parameters
required for modem connection like the phone number, data bit, baud
rate, etc. Here I have instantiate the connection and send a string
to the server (machine I connect to) and where I will receive a
message once the string has been received.
Any code and documentation on how to set this project scenario will be
welcome.
Thanking you in advance.
Hima :roll:
Snippets of code cut/pasted in to give you and idea... Functions work, but
not tested as from snippets.
// Calling code in form
RAS rc;
private void buttonConnect_Click(object sender, System.EventArgs e)
{
int ret = -1;
// ISP is an existing phone book RAS Dialup/VPN entry
rc = new RAS("ISP");
ret = rc.Connect();
if (ret != 0)
{
rc = null;
}
}
private void buttonDisconnect_Click(object sender, System.EventArgs e)
{
if (rc != null)
{
rc.Disconnect();
rc = null;
}
}
// end calling code in form
// Requires IE 5.5 or above!
public class RAS
{
public enum DialUpOptions
{
INTERNET_AUTODIAL_FORCE_ONLINE = 0x0001,
INTERNET_AUTODIAL_FORCE_UNATTENDED = 0x0002,
INTERNET_DIAL_FORCE_PROMPT =0x2000,
INTERNET_DIAL_SHOW_OFFLINE =0x4000,
INTERNET_DIAL_UNATTENDED =0x8000
}
public RAS() {}
[DllImport("wininet.dll",CharSet=CharSet.Auto)]
private extern static int InternetDial(
IntPtr hwnd,
[In]string lpszConnectoid,
uint dwFlags,
ref int lpdwConnection,
uint dwReserved
);
[DllImport("wininet.dll",CharSet=CharSet.Auto)]
private extern static int InternetHangUp(
int lpdwConnection,
uint dwReserved
);
public int Connect()
{
int retVal = RAS.InternetDial(IntPtr.Zero, m_ConnectionName, (uint)
this.DialUpOptions.INTERNET_DIAL_UNATTENDED, ref m_connectionnumber, 0);
return retVal;
}
public void Disconnect()
{
InternetHangUp(m_connectionnumber, 0);
}
}