Solved

How to gather IE connection parameters

Posted on 2001-07-30
5
180 Views
Last Modified: 2010-04-06
Hi, I 'd like to reuse the connection parameters as they were defined in IE

mainly, I want to know if
the connection is permanent of dial up
in case of dial up is there a default profile
is there a proxy and a proxy port
is a host defined and a host port

I'd like a solution that works with all versions of windows >= w95

I'd like a solution that does not need to have the administrator rights to be working or at least that would let me know that these righs are mandatory

I am not opposed to buy a component that des that if reliable and not too expensive

thanks in advance

Marc
0
Comment
Question by:mhervais
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 These are a few of the internet functions that I use:


function TryToConnectInternet : Cardinal;
var
  Modem, LAN, Proxy: Boolean;
begin
  If not GetOnline(Modem, LAN, Proxy) then Result := InternetAttemptConnect(0)
  else Result := 0;
end;

function GetOnline(var Modem, LAN, Proxy: Boolean): Boolean;
var
  flags: Cardinal;
begin
  Result:=InternetGetConnectedState(@flags,0);
  Modem:=flags and INTERNET_CONNECTION_MODEM>0;
  LAN:=flags and INTERNET_CONNECTION_LAN>0;
  Proxy:=flags and INTERNET_CONNECTION_PROXY>0;
end;

procedure GetDefaultProxyServer(var Server, ByPass: string; var Port: Integer);
const
  BUF_SIZE: DWORD = 500;
var
  ProxyInfo: PInternetProxyInfo;
  Buffer: Pointer;
begin
  GetMem(Buffer, BUF_SIZE);
  try
    if not InternetQueryOption(nil, INTERNET_OPTION_PROXY, Buffer, BUF_SIZE) then
      RaiseLastWin32Error;
    ProxyInfo := Buffer;
    ByPass := ProxyInfo^.lpszProxyBypass;
    if (ProxyInfo^.lpszProxy = '') then begin
      Server := '';
      Port := 0;
    end else with TStringTokenizer.Create(ProxyInfo^.lpszProxy, [':']) do try
      Server := NextToken;
      if HasMoreTokens then
        Port := StrToInt(NextToken)
      else
        Port := 0;
    finally
      Free;
    end;
  finally
    FreeMem(Buffer);
  end;
end;


  An overview of the Internet API can be found here:

http://shu.smolensk.su:8100/tech/wininet/general.htm#wininet_functions


  Hope this is of some initial help.

  Steven
0
 
LVL 4

Author Comment

by:mhervais
Comment Utility
Sorry Steven, I did not receive an Email to inform me about this comment.

actually, Know about these functions (Did not try them though) because I figure that the can get me to know the parameters once the connction has been made (correct me if this is not true).

what I would like is to get the info before the connction has been made.

this might be a bad idea however because I could issue a connection whatever the parameters are.

however the question was about this.

I increase the poinst a bit in case more people would be interested to comment

regards, Marc

0
 
LVL 4

Accepted Solution

by:
StevenB earned 150 total points
Comment Utility
 As far as your individual requirements go:

the connection is permanent or dial up - I'm pretty sure that InternetGetConnectedState (my GetOnline) function will return these values (LAN, Modem booleans) even if there is no current connection.
in case of dial up is there a default profile - I'm not sure about this one, but InternetAttemptConnect (my TryToConnectInternet) function certainly uses the default profile. I assume the value is lurking in the Registry somewhere, but I couldn't find it at a quick glance.
is there a proxy and a proxy port - InternetQueryOption(nil, INTERNET_OPTION_PROXY, Buffer, BUF_SIZE)  (My GetDefaultProxyServer) returns these values even when offline.

  Good luck with the rest, if I find anything I'll let you know. Much of the internet information by the way can also be found in the registry. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings is a good place to start looking.

  Steven
0
 
LVL 4

Author Comment

by:mhervais
Comment Utility
thanks for your help

Sincerely, Marc
0
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 No worries,

  Sorry about this by the way, I've only just noticed that the GetDefaultProxyServer function I sent you uses my TStringTokenizer object, so the code wouldn't work. The Tokenizer simply splits up a string by delimiters, in this case it splits the Port and the Server parts of the proxy information by splitting on the ":" character. Although I guess you worked that out :o)

  Steven
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now