Hi Konstantin,
Let me know a bit some more of what you expect to do with your first posted routine ?
Code: Select all
nFlags :=space(10)
do while .T.
tnk:=nextkey()
if tnk=27 // exit on esc pressed
exit
endif
if tnk>0
inkey()
endif
CallDll32( "InternetGetConnectedState", "WININET.DLL", @nFlags, 0 )
enddo
In this code you execute InternetGetConnectedState function but what are you doing with the result of it ?
Another question is why do not use the Bernard Mouille solution ?
This is what at my previous message I've indicated to you:
to change for other solution instead CallDll32.
My next suggestion is to test with
IsWebConnect() replacing
CallDll32( "InternetGetConnectedState", "WININET.DLL", @nFlags, 0 ) and then let us know your average time. IMHO, depending how is your interval time, ie if you have give a little slow time in the loop. Do you agree in my previous example the interval for timer do not need to be equal 1 (I do not think is so necessary for this extreme testing, does it necessary ?).
Please reevaluate following test or adapt to your code:
Code: Select all
#include <hmg.ch>
Function Main()
DEFINE WINDOW Form_1 AT 256 , 357 WIDTH 550 HEIGHT 350 TITLE "Testing Internet Connection" MAIN
ON KEY ESCAPE ACTION ThisWindow.Release
DEFINE TIMER Timer_1 INTERVAL 1000 ACTION Main_Timer_1_Action()
DEFINE STATUSBAR FONT "Courier New" SIZE 9
STATUSITEM " <Esc> to exit"
END STATUSBAR
END WINDOW
Form_1.Center
Form_1.Activate
Return Nil
Function Main_Timer_1_Action()
Local nFromHnd:=GetFormhandle("Form_1")
Local nId:=GetControlId("Timer_1","Form_1")
If IsWebConnect() == 0
/* Follwing commands, do not need to be like that.
This is just to exemplify what can it be done in case not connection found. */
KillTimer( nFromHnd, nId )
MsgStop(" Without Internet !", "Warning" ) // Send BrodCast Message thru LAN
InitTimer ( nFromHnd, nId, 1000 )
Endif
Return Nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <wininet.h>
HB_FUNC( ISWEBCONNECT )
{
int nRetour = 0;
DWORD state;
if ( InternetGetConnectedState( &state, 0 ) != FALSE )
{
nRetour = 1;
}
hb_retni( nRetour );
}
#pragma ENDDUMP
And please let us know results.
PeteWG wrote:Hi,
In my humble opinion , the "calldll32(...)" function as it is implemented in both HMG & HMG extended sources (h_controlmisc.prg) is broken!
I would suggest to remove it and let applications use the (same name) function of harbour by linking hbmisc contrib library.
regards,
---
Pete
Hi Pete, thank you for your opinion and indication regarding CallDll32 HMG function.
I have tested the Harbour's function but with no success. But probably in my tests I have done something wrong.
I will make some tests cutting off CallDll32 function from HMG and will revert
in this topic. And I will appreciated to treat this matter in this topic just to avoid off topic here.
My kind regards to all