CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ and WinAPI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C++ and WinAPI Discuss Windows API related issues using C++ (and Visual C++). This is a non-MFC forum.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 19th, 2006, 04:47 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    ask how to disable internet connection

    hai guyz, i have an idea : how to disable an internet connection ?? i've try to search in msdn, but have no clue in there.

    thanx 4 the answer....
    Reply With Quote
      #2    
    Old November 19th, 2006, 06:22 AM
    golanshahar golanshahar is offline
    Elite Member
    Power Poster
     
    Join Date: May 2005
    Posts: 4,936
    golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)golanshahar has a reputation beyond repute (3000+)
    Re: ask how to disable internet connection

    What do you mean with disable? Please explain.

    Cheers
    __________________
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers
    Reply With Quote
      #3    
    Old November 19th, 2006, 06:54 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by golanshahar
    What do you mean with disable? Please explain.

    Cheers
    i mean, i want to try my computer can't connect to internet even, it has connection to internet connection.

    i hope it clear you...

    regards...
    Reply With Quote
      #4    
    Old November 20th, 2006, 03:58 PM
    S_M_A S_M_A is offline
    Senior Member
     
    Join Date: Oct 2006
    Location: Sweden
    Posts: 1,597
    S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)S_M_A is a glorious beacon of light (400+)
    Re: ask how to disable internet connection

    Do you wan't to disable internet access completely or just block some programs?

    The easiest way has to be to install ZoneAlarm or similar software.
    Reply With Quote
      #5    
    Old November 20th, 2006, 10:03 PM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by S_M_A
    Do you wan't to disable internet access completely or just block some programs?

    The easiest way has to be to install ZoneAlarm or similar software.
    Nooo... i want to disable my internet connection with program made by C++. Not by software that you said above...
    Problem is i can't see the function in MSDN library to disable internet connection.

    regards...
    Reply With Quote
      #6    
    Old November 21st, 2006, 05:46 AM
    kkez kkez is offline
    Member
     
    Join Date: Sep 2004
    Location: Italy
    Posts: 389
    kkez is a glorious beacon of light (400+)kkez is a glorious beacon of light (400+)kkez is a glorious beacon of light (400+)kkez is a glorious beacon of light (400+)kkez is a glorious beacon of light (400+)
    Re: ask how to disable internet connection

    IMO you can't block internet connection. But you can try to block every program that asks for internet connection.
    Reply With Quote
      #7    
    Old November 21st, 2006, 06:38 AM
    zeRoau zeRoau is offline
    Member
     
    Join Date: Nov 2006
    Location: ntdll.dll
    Posts: 29
    zeRoau is on a distinguished road (30+)
    Re: ask how to disable internet connection

    You can disable your NIC (Network Interface Card).

    Here is an example (The code could use some work/error checking but it's a start for you).

    Code:
    #include <netcon.h>
    
    void DisableNIC(char* InterfaceName)
    {
    	INetConnectionManager* pNet;
    	INetConnection* pConn;
    	IEnumNetConnection* pEnum;
    	NETCON_PROPERTIES* pProps;
    	wchar_t Temp[255];
    	ULONG uCount = 0;
    
    	swprintf(Temp, L"%S", InterfaceName);
    	CoInitialize(NULL);
    	CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pNet);
    	pNet->EnumConnections(NCME_DEFAULT, &pEnum);
    
    	while (pEnum->Next(1, &pConn, &uCount) == S_OK)
    	{
    		pConn->GetProperties( &pProps );
    		if (!wcscmp(pProps->pszwName, Temp))
    		{
    			printf("Found %S\n", pProps->pszwName);
    			printf("Going to disable connection now!\n");
    			pConn->Disconnect();
    			printf("Disabled!");
    			CoTaskMemFree(pProps->pszwName);
    			CoTaskMemFree(pProps->pszwDeviceName);
    			CoTaskMemFree(pProps);
    			pConn->Release();
    		}
    	}
    	pEnum->Release();
    	pNet->Release();
    	CoUninitialize();
    }
    Example: DisableNIC("Local Area Connection");


    -
    Tom

    Last edited by zeRoau; November 21st, 2006 at 06:57 AM.
    Reply With Quote
      #8    
    Old November 21st, 2006, 10:15 AM
    0xC0000005 0xC0000005 is offline
    Senior Member
     
    Join Date: May 2002
    Posts: 1,362
    0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)0xC0000005 is a name known to all (1000+)
    Re: ask how to disable internet connection

    This code will 'disable an internet connection' - is it what you are looking for?
    Code:
    #include "IpExport.h"
    #include "Iphlpapi.h"
    #pragma comment(lib,"iphlpapi")
    
    ...
    
    // Call GetInterfaceInfo() with empty buffer to get the required size.
    ULONG ulInfoLength = 0;
    ::GetInterfaceInfo(0,&ulInfoLength);
    
    //  Allocate buffer for PIP_INTERFACE_INFO
    LPBYTE pInfoBuffer = new BYTE[ulInfoLength];
    PIP_INTERFACE_INFO pInfo = (PIP_INTERFACE_INFO)pInfoBuffer;
    
    //  Call GetInterfaceInfo() with valid buffer to get the actual data
    ::GetInterfaceInfo(pInfo,&ulInfoLength);
    
    // Release adapters
    for( LONG i=0; i<pInfo->NumAdapters; ++i )
      ::IpReleaseAddress(&pInfo->Adapter[i]);
      
    // Delete the IP_INTERFACE_INFO buffer
    delete [] pInfoBuffer;
    Reply With Quote
      #9    
    Old November 22nd, 2006, 03:39 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by zeRoau
    You can disable your NIC (Network Interface Card).

    Here is an example (The code could use some work/error checking but it's a start for you).

    Code:
    #include <netcon.h>
    
    void DisableNIC(char* InterfaceName)
    {
    	INetConnectionManager* pNet;
    	INetConnection* pConn;
    	IEnumNetConnection* pEnum;
    	NETCON_PROPERTIES* pProps;
    	wchar_t Temp[255];
    	ULONG uCount = 0;
    
    	swprintf(Temp, L"%S", InterfaceName);
    	CoInitialize(NULL);
    	CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pNet);
    	pNet->EnumConnections(NCME_DEFAULT, &pEnum);
    
    	while (pEnum->Next(1, &pConn, &uCount) == S_OK)
    	{
    		pConn->GetProperties( &pProps );
    		if (!wcscmp(pProps->pszwName, Temp))
    		{
    			printf("Found %S\n", pProps->pszwName);
    			printf("Going to disable connection now!\n");
    			pConn->Disconnect();
    			printf("Disabled!");
    			CoTaskMemFree(pProps->pszwName);
    			CoTaskMemFree(pProps->pszwDeviceName);
    			CoTaskMemFree(pProps);
    			pConn->Release();
    		}
    	}
    	pEnum->Release();
    	pNet->Release();
    	CoUninitialize();
    }
    Example: DisableNIC("Local Area Connection");


    -
    Tom
    Thanx Tom.... this code really new to me.... coz, i never use this code. But, thanx 4 sharing a new thing to me....

    cherrssss....
    Reply With Quote
      #10    
    Old November 22nd, 2006, 03:46 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by 0xC0000005
    This code will 'disable an internet connection' - is it what you are looking for?
    Code:
    #include "IpExport.h"
    #include "Iphlpapi.h"
    #pragma comment(lib,"iphlpapi")
    
    ...
    
    // Call GetInterfaceInfo() with empty buffer to get the required size.
    ULONG ulInfoLength = 0;
    ::GetInterfaceInfo(0,&ulInfoLength);
    
    //  Allocate buffer for PIP_INTERFACE_INFO
    LPBYTE pInfoBuffer = new BYTE[ulInfoLength];
    PIP_INTERFACE_INFO pInfo = (PIP_INTERFACE_INFO)pInfoBuffer;
    
    //  Call GetInterfaceInfo() with valid buffer to get the actual data
    ::GetInterfaceInfo(pInfo,&ulInfoLength);
    
    // Release adapters
    for( LONG i=0; i<pInfo->NumAdapters; ++i )
      ::IpReleaseAddress(&pInfo->Adapter[i]);
      
    // Delete the IP_INTERFACE_INFO buffer
    delete [] pInfoBuffer;
    I have question : what is mean "::" in front of IpReleaseAddress, etc. I never used it, but if i'm download source code, many of them use this....

    regards....
    Reply With Quote
      #11    
    Old November 22nd, 2006, 04:24 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by kkez
    IMO you can't block internet connection. But you can try to block every program that asks for internet connection.
    Thanx 4 clear me... i just wanna to make my brother angry coz this thing.... and i think this is coolll....

    regards....
    Reply With Quote
      #12    
    Old November 23rd, 2006, 12:02 PM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by insider
    I have question : what is mean "::" in front of IpReleaseAddress, etc. I never used it, but if i'm download source code, many of them use this....

    regards....
    It says that this variable is declared in the global namespace, not in the current one.
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
      #13    
    Old November 28th, 2006, 04:34 AM
    insider insider is offline
    Member
     
    Join Date: Nov 2006
    Posts: 27
    insider is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    Quote:
    Originally Posted by NoHero
    It says that this variable is declared in the global namespace, not in the current one.
    thanx alot NoHero....... you are my real herooooo........
    Reply With Quote
      #14    
    Old October 15th, 2008, 10:07 AM
    Damner Damner is offline
    Junior Member
     
    Join Date: Oct 2008
    Posts: 8
    Damner is an unknown quantity at this point (<10)
    Re: ask how to disable internet connection

    I've got a question concerning this problem, too, or should I better open a new thread?

    How do I disable the internet connection for one program? And no, I do not want to install a firewall, its only for one program/process.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ and WinAPI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:50 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009