Solved

How to gather IE connection parameters

Posted on 2001-07-30
5
181 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
ID: 6336248
 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
ID: 6338030
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
ID: 6342865
 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
ID: 6576718
thanks for your help

Sincerely, Marc
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6589396
 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 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

21 Experts available now in Live!

Get 1:1 Help Now