|
|||
|
Because you need to check the internet connection state constantly, the ping method is not so good as you have mentioned in another topic.
We will build a dll for you, it will check the state of the internet connection in a work thread so the application won't freeze. |
|
|||
|
Please extract the attached file and add the inetconn.dll into the attachment list in swfkit pro.
Code:
var dll = getAdditionalFile("inetconn.dll");
Dll.registerFunction(dll, "start", "start", "cdecl", "void", "char*");
Dll.registerFunction(dll, "stop", "stop", "cdecl", "void");
Dll.registerFunction(dll, "GetInternetConnectedState", "getInternetConnectedState",
***"cdecl", "long");
***
function showState()
{
***var state = getInternetConnectedState();
***trace("The internet connection state: ",
******state == 0 ? "unknown" : (state == 1 ? "offline" : "online"));
}
Application.setInterval(showState, 1000);
start("www.swfkit.com");
getMainWnd().onClose = function ()
{
***stop();
}
|
|
|||
|
The inetconn.dll exports three functions:
1. function start(server) server is the address of a remote host on internet. This function starts a thread to ping the server every other minute. 2. function stop() This function stops the pinging thread. It must be called before the application is about to close. 3. function GetInternetConnectedState() This function returns the pinging result. 0 indicates that it's still pinging and the internet connected state is unknown, 1 indicates that it's offline and 2 indicates that it's online. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|