Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Establishing an internet connection

Posted on 2000-04-07
20
260 Views
Last Modified: 2013-12-03
Hi all,

I need to be able to establish an internet (DUN) connection from my program. The program does not have to download anything, or otherwise use the internet connection: it merely has to establish a connection for the sake of establishing a connection.

It must work whether the EU uses IE (3+) or Netscape (3+), and if possible should work with AOL as well (though I don't know anything about AOL, so I'm not even sure if this is possible - ?).

Also, I can't use MFC or any other libraries (unless they're small and inexpensive) -- just C[++].

Thank you so much,
Stephen
0
Comment
Question by:semck
  • 11
  • 8
20 Comments
 
LVL 2

Expert Comment

by:mnguyen021997
ID: 2694208
can you rely on dun ras being installed?  if so, then just make a ras connection and talk PPP.  
0
 

Author Comment

by:semck
ID: 2694222
Thanks, mnquyen. Yes, I can probably rely on dun ras being installed. The thing is, I don't know HOW to make a RAS connection on the default Dial-Up server. (I don't know how to make a RAS connection at all).

Thanks,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694227
RasDial() is the API to use to initiate a RAS/DUN connection.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:semck
ID: 2694235
Hi jhance,

Thanks for the answer. Unfortunately, RasDial() takes some parameters that my program probably will not be able to provide -- username, password, and phone number.

You see, I want to be able to call up the automatic dial box of the browser, which already knows all of that information. (If the user has to click "Connect" or something on that box, that's no big deal.) The problem is, I won't know beforehand what browser is being used.

I wouldn't mind using RasDial(), except I know of no way to get the username, password, and phone number of the ISP, except asking the user, which is unacceptable.

Thank you,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694243
Two things you need here:

1) Determine the default internet connection.

2) Dial the connection successfully.



To accomplish #1, you must have IE installed and configured as this is an IE setting, not Windows standard.

Read the default DUN connection from:

HKEY_CURRENT_USER\RemoteAccess

and the value there called:

InternetProfile


Once you have that, you're ready to dial.  The function RasDial is defined as:

DWORD RasDial(
  LPRASDIALEXTENSIONS lpRasDialExtensions,
                          // pointer to function extensions data
  LPCTSTR lpszPhonebook,  // pointer to full path and filename of
                          // phone-book file
  LPRASDIALPARAMS lpRasDialParams,
                          // pointer to calling parameters data
  DWORD dwNotifierType,   // specifies type of RasDial event handler
  LPVOID lpvNotifier,     // specifies a handler for RasDial events
  LPHRASCONN lphRasConn   // pointer to variable to receive
                          // connection handle
);
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694270
>I wouldn't mind using RasDial(), >except I know of no way to get the >username, password, and phone number >of the ISP, except asking the user, >which is unacceptable.

You must know the users logon name and password to establish a connection using RasDial.  On Win9x it's stored using lame "encryption" in the users's pwl file.  There are many resources that describe this format and how to hack it.

On NT the data is stored more securely.

You can use the information in the following KB article to initiate a DUN connection from a Win9x computer via a system call using the (hopefully) stored username and password for the DUN connection.

On NT, you can accomplish the same thing with the RasDialDlg function.


From the remarks section in RASDIALPARAMS:

Remarks

The szUserName and szPassword strings are used to authenticate the user's access to the remote access server.

Windows NT/2000: RAS does not actually log the user onto the network. The user does this in the usual manner, for example, by logging on with cached credentials prior to making the connection or by using CTRL+ALT+DEL, after the RAS connection is established.

If both the szUserName and szPassword members are empty strings (""), RAS uses the user name and password of the current logon context for authentication. For a user mode application, RAS uses the credentials of the currently logged-on interactive user. For a Win32 service process, RAS uses the credentials associated with the service.

Windows 95: RAS uses the szUserName and szPassword strings to log the user onto the network.

Windows 95 cannot obtain the password of the currently logged-on user, so if both the szUserName and the szPassword members are empty strings (""), RAS leaves the user name and password empty during authentication



Neither is particularly clean since you're dependent on a valid DUN/RAS connection and a preconfigured username and password.  

Why is your application having to be so sneaky?  Why not just query the user for the required information at install and save it away for later use?
0
 

Author Comment

by:semck
ID: 2694275
Thanks jhance,

I've got IE (version 5.0), but I don't have the "Internet Profile" value in my registry.

Also, are you sure that Netscape has no such thing as a default connection? How do Netscape users connect to the internet?

Finally, even knowing the correct connection to call would not give me all the information I need to call it. (If everyone were kind enough to use IE4+, I could just use InternetAutoDial(0,0). Sigh. )

Thanks,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694281
Actually, now that I think about it, InternetDial may be what you're looking for....



DWORD InternetDial(
    IN HWND hwndParent,
    IN LPTSTR lpszConnectoid,
    IN DWORD dwFlags,
    OUT LPDWORD lpdwConnection,
    IN DWORD dwReserved
);
0
 
LVL 32

Accepted Solution

by:
jhance earned 1000 total points
ID: 2694293
>I've got IE (version 5.0), but I don't
>have the "Internet Profile" value in
>my registry.

Are you sure you looked in the right place and you have a default connection defined?


>Also, are you sure that Netscape has
>no such thing as a default connection?
>How do Netscape users connect to the
>internet?

I'm sure.  If Netscape autodials, it's due to the IE auto dial setup.  Pretty ironic that Netscape uses an IE4 feature to autodial.
0
 

Author Comment

by:semck
ID: 2694313
Adjusted points from 700 to 1000
0
 

Author Comment

by:semck
ID: 2694314
Hi jhance,

Thanks for the suggestion. There is nothing I would like better than to use InternetDial, but it works only with IE4.

I really don't want to get into hacking passwords.

>Why is your application having to be >so sneaky?  Why not just query the >user for the required information at >install and save it away for later >use?

Well, it's not that I'm being 'sneaky' (at least that's not my purpose), but this is supposed to be super-convenient. Of course, if nothing else works, then I will have to query the user for his password, but I'd rather do it automatically if possible.

I appreciate the time you're taking with this.

Thanks,
Stephen



0
 

Author Comment

by:semck
ID: 2694320
>I'm sure.  If Netscape autodials, it's >due to the IE auto dial setup.  Pretty >ironic that Netscape uses an IE4 >feature to autodial.

Very interesting indeed, lol. I'll mention this to my customer (he's the one who wants this in the first place).

Yes, I'm sure that I have a default connection and that I looked in the right place (HKEY_CURRENT_USER\RemoteAccess).

Thanks yet again,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694345
OK, if Netscape will autodial an internet connection there MUST be someplace to configure it, right?

So tell me where it is configured?

I'll tell you where.  Right-click on Internet Explorer select Properties.

This opens the Internet Properties dialog.  There choose the Connections tab.  You must choose "Dial whenever" or "Always dial" and then select one of the connections.  Click "Set Default".

You can add points all day but it won't change the facts.
0
 

Author Comment

by:semck
ID: 2694363
Appologies. I have now found the "default" registry entry. I was looking for a subkey instead of a named value. Sorry. :-|

Thanks,
Stephen
0
 

Author Comment

by:semck
ID: 2694485
I'm sorry jhance,

I increased the points before I saw your remark about Netscape using IE.

I'll discuss things with my customer, then I'll probably go ahead and accept one of your comments as an answer.

Thank you for all of your help,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694530
By the way, the reason I'm so positive about this is that I've been through this with a customer of mine.

He wanted their app to be able to use an existing DUN connection independent of the user's username/password but without any intervention.

I explored this in depth and even wrote a dialer that used password hacked out of the pwl file.  We finally rejected that for 2 reasons, first there is no assurance that MS won't change the pwl format in some future patch and second, they didn't like the potential liability of their program "hacking" password files on their customer's computers.

We ended up not using any of the existing DUN connection either since there is no assurance that any of them are actually workable.  The program just asked the user for his ISP information during the installation and used that to build a "private" DUN connection using RasSetEntryProperties.  Then it used RasDial to call that connection.

If there were problems, then the customer support could freely deal with and modify the "private" connection without having to worry about messing with the users other connections.
0
 

Author Comment

by:semck
ID: 2694607
Hi,

OK, thanks for the info.

I should go ahead and explain my request a bit, too. My program needs the modem, and for that reason it disconnects the user's internet connection, if there is one. After it's done with the modem, it then has to reconnect the user to the internet (so as to be polite).

Thanks,
Stephen
0
 

Author Comment

by:semck
ID: 2694668
Many thanks, jhance. I appreciate all your time and trouble here.

All the best,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
ID: 2694744
You may want to use RasEnumConnections instead of the default information.  Since you are dealing with an existing connection, you can't assume that the active connection is the default one.

RasEnumConnections will give you the active one.  It's possible that there is more than one, but it's unlikely.  You can check the szDeviceName in the return RASCONN struct and see if this is the one on your modem line.
0
 

Author Comment

by:semck
ID: 2695157
Right-O, thanks for the info.

All the best,
Stephen
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question