1. Detecting network and/or inet
- Posted by irv Sep 09, 2016
- 1392 views
I can use ipconf, but that pops up an ugly cmd window. Is there a Windows call to get this?
2. Re: Detecting network and/or inet
- Posted by jimcbrown (admin) Sep 09, 2016
- 1384 views
I can use ipconf, but that pops up an ugly cmd window.
I think you can use "cmd /c start /b" or something along those lines to hide the cmd window.
3. Re: Detecting network and/or inet
- Posted by jimcbrown (admin) Sep 09, 2016
- 1437 views
Is there a Windows call to get this?
I think you may want to look at the following:
GetIpInterfaceTable https://msdn.microsoft.com/en-us/library/windows/desktop/aa814418(v=vs.85).aspx
GetInterfaceInfo https://msdn.microsoft.com/en-us/library/windows/desktop/aa365947(v=vs.85).aspx
GetAdaptersInfo https://msdn.microsoft.com/en-us/library/windows/desktop/aa366314(v=vs.85).aspx
Personally, I'd find it easier to redirect the output of a command and process the resulting text, instead of attempting to wrap these methods.
4. Re: Detecting network and/or inet
- Posted by ghaberek (admin) Sep 09, 2016
- 1404 views
Adapted from my previous response eleven years ago.
Re: Is this computer connected to the Internet
-- InternetGetConnectedState function -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa384702(v=vs.85).aspx include std/dll.e include std/machine.e constant wininet = open_dll( "wininet.dll" ) constant xInternetGetConnectedState = define_c_func( wininet, "InternetGetConnectedState", {C_POINTER,C_LONG}, C_INT ) ifdef not EU4_1 then function sizeof( atom ctype ) return and_bits( ctype, #FF ) end function end ifdef public constant INTERNET_CONNECTION_MODEM = #01, INTERNET_CONNECTION_LAN = #02, INTERNET_CONNECTION_PROXY = #04, INTERNET_CONNECTION_MODEM_BUSY = #08, -- no longer used INTERNET_RAS_INSTALLED = #10, INTERNET_CONNECTION_OFFLINE = #20, INTERNET_CONNECTION_CONFIGURED = #40, $ public function InternetGetConnectedState() atom lpdwFlags = allocate( sizeof(C_POINTER), 1 ) atom dwFlags = 0 atom dwReserved = 0 atom result = c_func( xInternetGetConnectedState, {lpdwFlags,dwReserved} ) dwFlags = peek4u( lpdwFlags ) return {result,dwFlags} end function
Example:
include std/utils.e include internet.e sequence result = InternetGetConnectedState() sequence status = iff( result[1], "Online", "Offline" ) printf( 1, "status = %s (flags = #%02x)\n", {status,result[2]} )
Output:
status = Online (flags = #12)
-Greg
5. Re: Detecting network and/or inet
- Posted by irv Sep 10, 2016
- 1336 views
Thanks. Now, how about getting network address 192.168...?
6. Re: Detecting network and/or inet
- Posted by jimcbrown (admin) Sep 10, 2016
- 1370 views
Thanks. Now, how about getting network address 192.168...?
Perhaps looking at this example might help: