Results 1 to 4 of 4

Thread: How to disable network in C++

  1. #1
    Join Date
    Jan 2009
    Posts
    55

    How to disable network in C++

    How can I disable the network by C++. I want to know the coding and steps to execute the command. The am aware of the traditional way by which you can enable and disable network from control panel. I am using windows xp with visual c++. I need some codes by which I can disable a network of computer sharing the same nic. Also what the other way by which the nic of windows can be disabled and then enable back as per the need. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    3,424

    Re: How to disable network in C++

    You are having Service Control Manager (SCM) in windows which offers you several API function for the network purpose. Try this. Open the connection o the Service Control Manger ('OpenSCManager()'). Then look for the service you want to stop and then open it. Stop the service which will disable it ('ControlService()'). Then you will have to wait for sometime till the service is being terminated ('QueryServiceStatus()'). Then after when the service is stopped close the handle to service ('CloseServiceHandle()'). Then close the handle to service manager also ('CloseServiceHandle()').

  3. #3
    Join Date
    May 2008
    Posts
    3,516

    Re: How to disable network in C++

    You can disable it by editing the windows registry file. Go to start menu > run > type regedit. Then navigate to the following path - HKLM/System/CurrentControlSet/Services/Tcpip/Parameters/interfaces/{your nic id}. Now see the key name NTEContextList. It is a Multi_Sz key. Clear all the contents in the key. The value inside if deleted then the nic will be disabled. Then if you want to enable it back again give the following value - 0x0000000.

  4. #4
    Join Date
    Apr 2008
    Posts
    3,339

    Re: How to disable network in C++

    C++ has multiple option by which you enable and disable the nic in your system. But better you should use Shell network interface. This method is useful for those who want to start and stop the network service which usually appear in the Network connection shell folder. It only works for windows xp and higher version. Other than this see the listed codes to get more information on nic.
    • # ifconfig -a --- This code shows up the details of all interface.
    • # ifconfig eth0 down --- This will disable the network service.
    • # ifconfig eth0 up -- Enable the above service.

Similar Threads

  1. How to disable addtional network connection in Windows 7
    By LavinaD in forum Networking & Security
    Replies: 8
    Last Post: 21-09-2011, 01:48 PM
  2. How to disable Privacy/Network Interaction in VLC 092
    By Kim|ball in forum Windows Software
    Replies: 5
    Last Post: 09-07-2011, 10:14 AM
  3. Can not disable network adapter
    By Joko in forum Networking & Security
    Replies: 7
    Last Post: 18-03-2009, 11:48 PM
  4. Disable login popup from Network
    By Ananias in forum Networking & Security
    Replies: 3
    Last Post: 10-03-2009, 10:58 AM
  5. Enable/Disable Network connection at once
    By Fabio Rosa in forum Windows Server Help
    Replies: 6
    Last Post: 17-02-2009, 07:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,719,217,938.84014 seconds with 17 queries