Click to See Complete Forum and Search --> : ask how to disable internet connection


insider
November 19th, 2006, 03:47 AM
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.... :)

golanshahar
November 19th, 2006, 05:22 AM
What do you mean with disable? Please explain.

Cheers

insider
November 19th, 2006, 05:54 AM
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...

S_M_A
November 20th, 2006, 02:58 PM
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. ;)

insider
November 20th, 2006, 09:03 PM
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...

kkez
November 21st, 2006, 04:46 AM
IMO you can't block internet connection. But you can try to block every program that asks for internet connection.

zeRoau
November 21st, 2006, 05:38 AM
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).


#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

0xC0000005
November 21st, 2006, 09:15 AM
This code will 'disable an internet connection' - is it what you are looking for?#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;

insider
November 22nd, 2006, 02:39 AM
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).


#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.... :)

insider
November 22nd, 2006, 02:46 AM
This code will 'disable an internet connection' - is it what you are looking for?#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.... :)

insider
November 22nd, 2006, 03:24 AM
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.... :cool: and i think this is coolll.... :)

regards....

NoHero
November 23rd, 2006, 11:02 AM
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.

insider
November 28th, 2006, 03:34 AM
It says that this variable is declared in the global namespace, not in the current one.

thanx alot NoHero....... you are my real herooooo........ :wave: