Discussion:
InternetGoOnline
(too old to reply)
Al Christoph
2005-01-17 12:27:49 UTC
Permalink
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning true.
Any suggestions would be appreciated. I don't expect delphi expertise here,
just am I doing all the necessary stuff checks.

if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil, 0);
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
result:= WinINet.InternetGetConnectedState(@flags,res);
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);

Regards,
Al
Brian Cryer
2005-01-23 09:20:46 UTC
Permalink
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning true.
Any suggestions would be appreciated. I don't expect delphi expertise here,
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil, 0);
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,

could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't InternetGoOnline
just toggle the online/offline state? If you do not have a connection to the
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.

Just for information: There are lots of people out there using WinInet with
Delphi. (Delphi is a good choice. All the power of C++ with the ease of VB,
but I don't know yet how Delphi .NET tools stack up against Microsofts which
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.

hope this helps,

Brian.

www.cryer.co.uk/brian
Paul Baker
2005-01-24 20:06:20 UTC
Permalink
Yes, InternetGoOnline just turns off the Work Offline flag. It doesn't
actually establish a dial-up connection :)

Paul
Post by Brian Cryer
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning
true.
Post by Al Christoph
Any suggestions would be appreciated. I don't expect delphi expertise
here,
Post by Al Christoph
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,
0);
Post by Al Christoph
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,
could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't
InternetGoOnline
Post by Brian Cryer
just toggle the online/offline state? If you do not have a connection to the
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.
Just for information: There are lots of people out there using WinInet with
Delphi. (Delphi is a good choice. All the power of C++ with the ease of VB,
but I don't know yet how Delphi .NET tools stack up against Microsofts which
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.
hope this helps,
Brian.
www.cryer.co.uk/brian
Al Christoph
2005-01-25 19:00:35 UTC
Permalink
Given that this code is going to run on a customer PC where I have no
control over the state of the connection or the way that IE is configured do
I need to worry about the Work Offline flag? I just want to make sure that a
connection is available if InternetGetConnectedState returns false.

Regards,
Al
Post by Paul Baker
Yes, InternetGoOnline just turns off the Work Offline flag. It doesn't
actually establish a dial-up connection :)
Paul
Post by Brian Cryer
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected
the
Post by Brian Cryer
Post by Al Christoph
GoOnline seems to wait a sec or two and pass right on ahead returning
true.
Post by Al Christoph
Any suggestions would be appreciated. I don't expect delphi expertise
here,
Post by Al Christoph
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,
0);
Post by Al Christoph
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,
could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't
InternetGoOnline
Post by Brian Cryer
just toggle the online/offline state? If you do not have a connection to
the
Post by Brian Cryer
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.
Just for information: There are lots of people out there using WinInet
with
Post by Brian Cryer
Delphi. (Delphi is a good choice. All the power of C++ with the ease of
VB,
Post by Brian Cryer
but I don't know yet how Delphi .NET tools stack up against Microsofts
which
Post by Brian Cryer
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.
hope this helps,
Brian.
www.cryer.co.uk/brian
Brian Cryer
2005-01-26 10:45:46 UTC
Permalink
Post by Al Christoph
Given that this code is going to run on a customer PC where I have no
control over the state of the connection or the way that IE is configured do
I need to worry about the Work Offline flag? I just want to make sure that a
connection is available if InternetGetConnectedState returns false.
Regards,
Al
Yes you do need to worry about it. If the internet system is offline then
you only have access to what is in the browser cache. Most people will
probably leave it online, but if a user switches offline then expect things
to stop working.

Brian.

www.cryer.co.uk/brian
Paul Baker
2005-01-26 20:18:10 UTC
Permalink
Newer versions of Internet Explorer have a separate Work Offline flag for
each process, so unless your application is embedded in Internet Explorer,
you won't be affected. However, you will be affeted cby the global Work
Offline flag used by older versions of Internet Explorer.

You can be connected to the Internet but Working Offline. They are separate
concepts. I don't think that InternetGetConnectedState takes into account
the Work Offline flag, but the documentation does not say.

Paul
Post by Brian Cryer
Post by Al Christoph
Given that this code is going to run on a customer PC where I have no
control over the state of the connection or the way that IE is
configured
Post by Brian Cryer
do
Post by Al Christoph
I need to worry about the Work Offline flag? I just want to make sure
that
Post by Brian Cryer
a
Post by Al Christoph
connection is available if InternetGetConnectedState returns false.
Regards,
Al
Yes you do need to worry about it. If the internet system is offline then
you only have access to what is in the browser cache. Most people will
probably leave it online, but if a user switches offline then expect things
to stop working.
Brian.
www.cryer.co.uk/brian
Brian Cryer
2005-01-28 10:53:06 UTC
Permalink
Post by Paul Baker
Newer versions of Internet Explorer have a separate Work Offline flag for
each process, so unless your application is embedded in Internet Explorer,
you won't be affected. However, you will be affeted cby the global Work
Offline flag used by older versions of Internet Explorer.
You can be connected to the Internet but Working Offline. They are separate
concepts. I don't think that InternetGetConnectedState takes into account
the Work Offline flag, but the documentation does not say.
Paul
Paul,

I didn't know newer versions allowed it to be on a per process. Much better
approach. Do you happen to know how whether you can tell in software whether
the flag is of global effect or just the current process? Thanks.

Brian.
Paul Baker
2005-01-31 14:49:28 UTC
Permalink
Brian,

I was bitten by this once because we have no Work Offline feature in our
software, yet we would sometimes be connected but offline.

It is not well documented, but InternetQueryOption may help:
http://msdn.microsoft.com/library/en-us/wininet/wininet/option_flags.asp

INTERNET_OPTION_IGNORE_OFFLINE will apparently ignore the global offline
flag, which I take to mean the Work Offline mode.

INTERNET_OPTION_OFFLINE_MODE is unfortunately listed as not implemented.

If HttpSendRequest or HttpSendRequestEx return ERROR_FILE_NOT_FOUND, what I
do is call InternetGoOnline and try again.

Paul
Post by Paul Baker
Post by Paul Baker
Newer versions of Internet Explorer have a separate Work Offline flag for
each process, so unless your application is embedded in Internet Explorer,
you won't be affected. However, you will be affeted cby the global Work
Offline flag used by older versions of Internet Explorer.
You can be connected to the Internet but Working Offline. They are
separate
Post by Paul Baker
concepts. I don't think that InternetGetConnectedState takes into account
the Work Offline flag, but the documentation does not say.
Paul
Paul,
I didn't know newer versions allowed it to be on a per process. Much better
approach. Do you happen to know how whether you can tell in software whether
the flag is of global effect or just the current process? Thanks.
Brian.
Brian Cryer
2005-02-01 09:54:18 UTC
Permalink
Post by Paul Baker
Brian,
I was bitten by this once because we have no Work Offline feature in our
software, yet we would sometimes be connected but offline.
http://msdn.microsoft.com/library/en-us/wininet/wininet/option_flags.asp
INTERNET_OPTION_IGNORE_OFFLINE will apparently ignore the global offline
flag, which I take to mean the Work Offline mode.
INTERNET_OPTION_OFFLINE_MODE is unfortunately listed as not implemented.
If HttpSendRequest or HttpSendRequestEx return ERROR_FILE_NOT_FOUND, what I
do is call InternetGoOnline and try again.
Paul
Thanks Paul,

I'll take a look at INTERNET_OPTION_IGNORE_OFFLINE. I'm currently toggling
the global offline state, doing it just for my application would be so so
much better.

kind regards,

Brian.

Al Christoph
2005-01-25 12:48:13 UTC
Permalink
Thanks for the response. According to the doco you are correct. However, I'm
not seeing the dialog I expect with that either. Oh well.

Regards,
Al
Post by Brian Cryer
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning
true.
Post by Al Christoph
Any suggestions would be appreciated. I don't expect delphi expertise
here,
Post by Al Christoph
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,
0);
Post by Al Christoph
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,
could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't
InternetGoOnline
just toggle the online/offline state? If you do not have a connection to the
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.
Just for information: There are lots of people out there using WinInet with
Delphi. (Delphi is a good choice. All the power of C++ with the ease of VB,
but I don't know yet how Delphi .NET tools stack up against Microsofts which
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.
hope this helps,
Brian.
www.cryer.co.uk/brian
Al Christoph
2005-01-25 12:56:34 UTC
Permalink
Thanks for the hint. When I followed the directions, it worked:-))) The
reserved value apparently has to be the literal 0. It apparently can't be a
variable set to 0!?!?!?!

Not sure what else fixed it.

Oh well.

Regards,
Al
Post by Brian Cryer
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning
true.
Post by Al Christoph
Any suggestions would be appreciated. I don't expect delphi expertise
here,
Post by Al Christoph
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,
0);
Post by Al Christoph
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,
could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't
InternetGoOnline
just toggle the online/offline state? If you do not have a connection to the
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.
Just for information: There are lots of people out there using WinInet with
Delphi. (Delphi is a good choice. All the power of C++ with the ease of VB,
but I don't know yet how Delphi .NET tools stack up against Microsofts which
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.
hope this helps,
Brian.
www.cryer.co.uk/brian
Paul Baker
2005-01-25 17:23:04 UTC
Permalink
Perhaps you were passing in a non-zero pointer to your variable.

Paul
Post by Al Christoph
Thanks for the hint. When I followed the directions, it worked:-))) The
reserved value apparently has to be the literal 0. It apparently can't be a
variable set to 0!?!?!?!
Not sure what else fixed it.
Oh well.
Regards,
Al
Post by Brian Cryer
Post by Al Christoph
I'm using the following hunk of code in Delphi to try to insure user is
connected to net. Check and if not popup standard connect dialog to get
connection. The open and check seem to work fine. If I'm not connected the
GoOnline seems to wait a sec or two and pass right on ahead returning
true.
Post by Al Christoph
Any suggestions would be appreciated. I don't expect delphi expertise
here,
Post by Al Christoph
just am I doing all the necessary stuff checks.
if not inited then
begin
sHNet:=InternetOpen(pchar(url), INTERNET_OPEN_TYPE_PRECONFIG, nil,nil,
0);
Post by Al Christoph
inited:=sHNet<>nil;
end;
result:=false;
res:=0;
if result then exit;
if url[length(url)]<>#0 then url:=url + #0;
result:= WinInet.InternetGoOnline(pchar(url),hwndParent,0);
Regards,
Al
Al,
could be wrong here, becasue I've not looked up the behaviour of
InternetGoOnline and I'm relying on memory ... but doesn't
InternetGoOnline
just toggle the online/offline state? If you do not have a connection to the
internet dial-up say then I don't think it will invoke the dial up
connection. I think you may need to consider invoking InternetDial.
Just for information: There are lots of people out there using WinInet with
Delphi. (Delphi is a good choice. All the power of C++ with the ease of VB,
but I don't know yet how Delphi .NET tools stack up against Microsofts which
are very good.) My own notes on using WinInet with Delphi are at
http://www.cryer.co.uk/brian/delphi/wininet.htm.
hope this helps,
Brian.
www.cryer.co.uk/brian
Loading...