Forum > General

is there an internet connection?

(1/10) > >>

Nicole:
I took a method out of some source and have no idea, how it works:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function InternetConnected: Boolean;  var  dwConnectionTypes: DWord;begin  dwConnectionTypes := INTERNET_CONNECTION_MODEM or INTERNET_CONNECTION_LAN or INTERNET_CONNECTION_PROXY;  Result := InternetGetConnectedState(@dwConnectionTypes, 0);end;
What I want to: Check, if the internet connection exists.
The check produces false positives.

Any ideas, why this may be?

At the moment it starts from within a VMWare-VM under Win 7 and has a NAT connection.

TRon:
Always try to read the original documentation first. It helps in understanding what the function is suppose to do.

https://learn.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-internetgetconnectedstate

There it states:

--- Quote ---Note  Using this API is not recommended, use the INetworkListManager::GetConnectivity method instead.

--- End quote ---

howardpc:
See this  answer, and the others in the same thread

Nicole:
Thank you for the link.
The problem is: I do not understand the details. Neither in "my" source, nor in the links.

Do you think, you can just copy me the correct line form there?
The only thing I need, is a result only true, if there is a connection.

I do not want to understand it, my work is something completely different.

KodeZwerg:

--- Quote from: Nicole on February 03, 2023, 01:44:47 pm ---The problem is: I do not understand the details.
--- End quote ---
What you not understand, do it like link provided and you have a proper response.

--- Quote from: Nicole on February 03, 2023, 01:44:47 pm ---I do not want to understand it
--- End quote ---
That is the worst a programmer can say, Pascal ain't a script language where you just copy/paste.

Navigation

[0] Message Index

[#] Next page

Go to full version