i have vb6 and i want to know how can i disable/enable a network connection
in Win98 and Win2k.
witch API shoud i call?
Here are just some snipped (but main) codes to provide some ideas.
BOOL StateChange(DWORD NewState, DWORD SelectedItem,HDEVINFO hDevInfo)
{
SP_PROPCHANGE_PARAMS PropChangeParams =
{sizeof(SP_CLASSINSTALL_HEADER)};
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
//
// Get a handle to the Selected Item.
//
if (!SetupDiEnumDeviceInfo(hDevInfo,SelectedItem,&DeviceInfoData))
return FALSE;
//
// Set the PropChangeParams structure.
//
PropChangeParams.ClassInstallHeader.InstallFunction =
DIF_PROPERTYCHANGE;
PropChangeParams.Scope = DICS_FLAG_GLOBAL;
PropChangeParams.StateChange = NewState;
if (!SetupDiSetClassInstallParams(hDevInfo,
&DeviceInfoData,
(SP_CLASSINSTALL_HEADER *)&PropChangeParams,
sizeof(PropChangeParams)))
return FALSE;
//
// Call the ClassInstaller and perform the change.
//
if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,
hDevInfo,
&DeviceInfoData))
return FALSE;
return TRUE;
}
BOOL DisableNetAdapter()
{
HDEVINFO hdi;
BOOL res;
// get a list of all devices of class 'GUID_DEVCLASS_NET'
hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL,
DIGCF_PRESENT);
if (hdi == INVALID_HANDLE_VALUE)
return FALSE;
res = StateChange(DICS_DISABLE, 0, hdi);
// release the device info list
SetupDiDestroyDeviceInfoList(hdi);
return res;
}
BOOL EnableNetAdapter()
{
HDEVINFO hdi;
BOOL res;
// get a list of all devices of class 'GUID_DEVCLASS_NET'
hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL,
DIGCF_PRESENT);
if (hdi == INVALID_HANDLE_VALUE)
return FALSE;
res = StateChange(DICS_ENABLE, 0, hdi);
// release the device info list
SetupDiDestroyDeviceInfoList(hdi);
return res;
}
Best Regards,
Alick Ye
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Jean" <Thunde...@Hotmail.com>
| Newsgroups: microsoft.public.vb.winapi
| Subject: disable network card
| Lines: 7
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <ejrG8.6605$ie.143132@charlie>
| Date: Tue, 21 May 2002 12:44:58 GMT
| NNTP-Posting-Host: 205.237.41.84
| X-Complaints-To: ab...@cgocable.ca
| X-Trace: charlie 1021985098 205.237.41.84 (Tue, 21 May 2002 08:44:58 EDT)
| NNTP-Posting-Date: Tue, 21 May 2002 08:44:58 EDT
| Path:
cpmsftngxa07!cpmsftngxa10!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de
!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!charlie!5
3ab2750!not-for-mail
| Xref: cpmsftngxa07 microsoft.public.vb.winapi:147859
| X-Tomcat-NG: microsoft.public.vb.winapi