Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: HKEY_DYN_DATA DUN Connection
The dunConnect is supposed to check to see if the connection is already open, and if so, return the handle to the open connection. Make sure the names in the dunConnect matches the name of the connection you are trying to test.
It should not try to open a new connection unless the names are different and you have more than one modem.
I think by poking around in the HKEY_DYN_DATA section of the registry, you *might* be able to figure out if you have a DUN connection. Or try the DllCall method below.
Also, if you can get a pComOpen to work, it would indicate that dialup networking is not active at that moment. You could then close the port and terminate the program. The serial extender needs access to the com port, and if it is tied up with dialup networking, then pComOpen will not work. So you can use this information to indicate that a DUN connection still exists.
If you're trying to determine when to close a connection, with the Internet extender you should be able to see bytes going by. If there is no traffic for maybe 30 seconds, it might be time to close the connection.
The code might look something like:
AddExtender("wwwsk34I.dll") con=dunConnect("connection name") ; YOUR CONNECTION APPLET if con==0 Message("Error","Zero con returned") exit endif OldBytesIn=wxGetInfo(4,con) while 1 TimeDelay(30) NewBytesIn=wxGetInfo(4,con) if NewBytesIn==OldBytesIn then break OldBytesIn=NewBytesIn endwhile dunDisconnect(con) Display(5,"Lurker","Disconnected") exit
According to the API info, the WININET.dll can find out if there is a DUN connection going on or not. The "InternetGetConnectedState" will return a true if connected and false if not. So this is what I did.
dllhandle=DllLoad("%winsys%wininet.dll") a = DllCall(dllhandle, long:"InternetGetConnectedState", lpnull:"") DllFree(dllhandle) pause("", "%a%")and this is what happened I get what looks like a wil message box that the title says INTERNAL DYNALLOC ERROR and the text states Tag overwrite 1 The only way to exit that message or the wbt is to shut it down w/taskmanager. So now that I'm twice as lost as before, any Ideas?
BOOL InternetGetConnectedState( OUT LPDWORD lpdwFlags, IN DWORD dwReserved );Your DLLCall should be more like:
dadll=strcat(DirWindows(1),"wininet.dll") binbuf=BinaryAlloc(4) BinaryEODset(binbuf,4) rslt=DllCall(dadll, long:"InternetGetConnectedState", lpbinary:binbuf,long:0) debug(1) code=BinaryPeek4(binbuf,0) BinaryFree(binbuf) if rslt==@True switch code case 1 str="INTERNET_CONNECTION_MODEM... Local system uses a modem to connect to the Internet." break case 2 str="INTERNET_CONNECTION_LAN... Local system uses a local area network to connect to the Internet." break case 4 str="INTERNET_CONNECTION_PROXY... Local system uses a proxy server to connect to the Internet." break case 8 str="INTERNET_CONNECTION_MODEM_BUSY... Local system's modem is busy with a non-Internet connection." break endswitch message("How is the user connected?",str) else message("No connection","User is not connected to internet") endif
;return values from InternetGetConnectedState could be
Article ID: W12621
Filename: Check Existence of a DUN Connection.txt
File Created: 2001:03:01:15:12:56
Last Updated: 2001:03:01:15:12:56