//
// This may take a while :^(
//
hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
//
// Get a handle to the Selected Item.
//
if (!SetupDiEnumDeviceInfo(hDevInfo,SelectedItem,&DeviceInfoData))
{
printf("EnumDeviceInfo");
return FALSE;
}
//
// Set the PropChangeParams structure.
//
PropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
PropChangeParams.Scope = DICS_FLAG_GLOBAL;
PropChangeParams.StateChange = NewState;
//
// Call the ClassInstaller and perform the change.
//
if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,
hDevInfo,
&DeviceInfoData))
{
printf("SetClassInstallParams");
SetCursor(hCursor);
return TRUE;
}
int main(int argc, char* argv[])
{
if (INVALID_HANDLE_VALUE == (hDevInfo =
SetupDiGetClassDevs(NULL,NULL,0,
DIGCF_PRESENT|DIGCF_ALLCLASSES)))
{
printf("GetClassDevs");
return 0;
}
DWORD i, Status, Problem;
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
HKEY hKeyClass;
char DeviceName[200];
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);i++)
{
if (IsClassNet(&DeviceInfoData.ClassGuid))
{
printf(" the class's index is %d\n",i);
//
//DICS_DISABLE-->禁用网络
//DICS_ENABLE--->恢复网络
//
if (StateChange(DICS_ENABLE,i,hDevInfo))
printf("NetWork stopped");