1. Detecting network and/or inet

I can use ipconf, but that pops up an ugly cmd window. Is there a Windows call to get this?

new topic     » topic index » view message » categorize

2. Re: Detecting network and/or inet

irv said...

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Detecting network and/or inet

irv said...

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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Detecting network and/or inet

Adapted from my previous response eleven years ago. smile

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Detecting network and/or inet

Thanks. Now, how about getting network address 192.168...?

new topic     » goto parent     » topic index » view message » categorize

6. Re: Detecting network and/or inet

irv said...

Thanks. Now, how about getting network address 192.168...?

Perhaps looking at this example might help:

http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancediphelperfunction13h.html

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu