|
Whilst the english in the article may be lacking.
The code available in this component is very good. (the code, not the comments).
|
|
|
|
|
|
This code helps out greatly in my goal to programmatically connect to the Internet. I had to modify the RasConnection.HangUp() and remove that first RasGetConnectedState it calls, as I discovered that with it, Ras.RasHangUp never actually gets called if I try to make a RAS connection when my device isn't turned on (I first use RasConnection.Dial(), but with RAS you have to hang up before you can attempt another dial). So now it's able to reattempt dialing without saying "This connection is already being dialed." Other than that your class is working quite nicely.
|
|
|
|
|
Please clarify what you did to get the HangUp to work correctly. I have been fighting with this for several weeks. Every time I get a busy signal or no answer, the connection won't work again, and since I have this running as a service, it requires me to spend a lot of time baby sitting it.
Thanks,
Jeff Hill
|
|
|
|
|
I had noticed after a similar scenario to what you speak of, Ras.RasHangUp would never be called from within RasConnection.HandUp (sic), because after assigning
res=Ras.RasGetConnectStatus(_Handle,status), res would always equal 6, meaning the conditional statement following it would be skipped and Ras.RasHangUp would never be called. So after that first res=Ras.RasGetConnectStatus(_Handle,status) line I added res=0, so it always tries to call the HangUp function. I haven't figured out why RasGetConnectStatus doesn't like the handle while RasHangUp does. I think it has something to do with the connection terminating before a RasHangUp is even called, and so the natural assumption is that you shouldn't have to hang up. But as it says in the RasDial documentation, "An application must eventually call RasHangUp..." Anyway, you shouldn't need to use the initial RasGetConnectStatus if you properly alternate between Dial and HangUp on the same connection.
|
|
|
|
|
I am facing the same problem. but when i modify the conditional statment
so not check res value and just check the state, conditional statment becomes true and call RasAPI.Handup(...), the stopthread() method still alive and wait at WaitAny(...) but this thread never expire even after calling handup() due to exception in handup when calling RasAPI.Handup(...). So resources is still used without any work.
Zeeshan
|
|
|
|
|
I really love your example, it has all the gimmicks in it i can use for my own project!
I credit you in my project!
Many thanx!!;)
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|
|
I need ur help..
plz give me ur email..
my email id is
vavjeeva@gmail.com
Keep Smile Always
|
|
|
|
|
I need ur help.. vavjeeva@gmail.com
Keep Smile Always
|
|
|
|
|
The link is dead, can author fix or someone else supply?
"How to using Remote Access Service on DotNet"
Thanks,
|
|
|
|
|
Nice code. But i'm trying to use it to connect to a VPN server.
And I only get a error message..
Any suggestion on differences with doing RAS calls to PPTP. Should this work or do I have to change the code?
CC
|
|
|
|
|
Easy.
just add the entryname & phone book file to the rasdial.
looks like:
RasDial(null,"C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk",_Params,1,_DialNotifyDelegate,ref _Handle);
the keys are:
1. need to add the entryname in _Params, that is the entryname, not a connection manager name, very important.
2. use IP instead the phone no in _Params.
3. the phone book name.
and you get it.
Still some errors somewhere. but definitely Cool code. thanks a lot.
|
|
|
|
|
hi,
the demo code is great, but could u give an example of how to detect that a connection has been made to an ISP/server, and how to detect that it has been terminated.
thanks
rt
|
|
|
|
|
I am using Windows XP as my development machine. I have found that the alternate numbers are not loading properly after making a call to the RasGetEntryProperties. I have tried several things to get it to work. I have not modified the code given. Any suggestions??
|
|
|
|
|
in the actual pbk file, it's just adding 2 additional numbers even though i didnt specify them, and calling them "ack" and something else, garbage data...
any ideas of how to fix? I even try doing rasEntry.AdditionalNumbers.clear()
|
|
|
|
|
Does anybody use this code for ISDN modem and how?
I try but unsuccessful .
smac
|
|
|
|
|
I want to dial automaticly to the internet using rasapi32.dll. My problem is, that I don't want to ask the user for his username and password. Is it possible the get these information automaticly?
|
|
|
|
|
I had the same problem. I figured it out. I just used an XML file (or you can use a text file)
to put the info in. then take the info out of that file, and set it as the parameters.
It's not a bug it's a f- oh wait... no..It's a bug.
|
|
|
|
|
Can we somehow find the modem type using RAS.. i.e. Is my modem is 56K, 33k or ISDN or cable modem ?
Help will be highly appriciated
sdsd
|
|
|
|
|
The devicetype offers the help to find out if it is modem or isdn.
|
|
|
|
|
The code is very good,But I find a question your code can't connect to pppoe
look http://www.codeproject.com/internet/afdialer.asp
It can use to pppoe,but my vc is poor .can you anser the question?
I love .net
|
|
|
|
|
Hi,
Your code is perfect, but I think that I've found a little problem.
If I use an existing Dun, using entry name and phonebook in a RasConnection, I found some problems if the modem is not connect to a line.
It notify me that there is no answare, and if I try to re-dial the same connection it tells me that is already being dialled.
Did you have some suggest?
thanks a lot.
Spagna
|
|
|
|
|
Thanks for a great effort. This code is exactly what I was looking for, for soooooo long! Actualy I am just looking to determine when a internet connection is present, and when not.
Thanks,
|
|
|
|
|
Look at this code...
They tell you when is connected or not...
I think may help.
Guber
using System;
using System.Runtime.InteropServices;
namespace InetStateTest
{
public class ConnectionState
{
private enum ConnectionStateEnum
{
//Local system has a valid connection to the Internet, but it might or might not be currently connected.
ConnectionConfigured = 64,
//Local system uses a local area network to connect to the Internet.
ConnectionLan = 2,
//Local system uses a modem to connect to the Internet.
ConnectionModem = 1,
//No longer used.
ConnectionModemBusy = 8,
//Local system is in offline mode.
ConnectionOffline = 32,
//Local system uses a proxy server to connect to the Internet.
ConnectionProxy = 4,
//Local system has RAS installed.
RasInstalled = 16
}
private class Win32
{
[DllImport("Wininet.dll", CharSet=CharSet.Auto)]
public static extern int InternetGetConnectedState(out int Flag, int Reserved);
}
private static int GetConnectionFlag()
{
int Flag;
Win32.InternetGetConnectedState(out Flag,0);
return Flag;
}
public static bool IsModemConnected()
{
return ((GetConnectionFlag() & (int)ConnectionStateEnum.ConnectionModem)==0) ?
false : true;
}
}
public class StartUp
{
public static void Main()
{
if (ConnectionState.IsModemConnected())
{
Console.WriteLine("Connected");
}
else
{
Console.WriteLine("Not connected");
}
Console.ReadLine();
}
}
}
Guber
|
|
|
|
|
Guber, you are the man! This is absolutely perfect! Clean, short and to the point.
Thx man!
G
|
|
|
|