2022年计算机二级C++辅导实例编程:用C语言实现禁用网卡的代码
enum c++用C语言实现禁用网卡的代码
#include
#include
#include
#include
void EnumDevices(HDEVINFO hDevInfo)
{
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
LPOLESTR guid;
char devName[128];
char instanceId[128];
for (int i=0;SetupDiEnumDeviceInfo(hDevInfo,i,i++)
{
StringFromCLSID(DeviceInfoData.ClassGuid,
#include
#include
#include
#include
void EnumDevices(HDEVINFO hDevInfo)
{
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
LPOLESTR guid;
char devName[128];
char instanceId[128];
for (int i=0;SetupDiEnumDeviceInfo(hDevInfo,i,i++)
{
StringFromCLSID(DeviceInfoData.ClassGuid,
SetupDiClassNameFromGuid(
if(!strcmp(devName,“Net“))
{
SetupDiGetDeviceInstanceId(hDevInfo,
if(!strncmp(instanceId,“PCI“,3))
{
wprintf(L“%s\n“,guid);
printf(“%s\n“,devName);
printf(“%s\n“,instanceId);
SP_PROPCHANGE_PARAMS params = {sizeof(SP_CLASSINSTALL_HEADER )};
params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
params.Scope = DICS_FLAG_CONFIGSPECIFIC;
params.StateChange = DICS_DISABLE;
params.HwProfile = 0;
SetupDiSetClassInstallParams(hDevInfo, ms, sizeof(SP_PROPCHANGE_PARAMS));
if(!strcmp(devName,“Net“))
{
SetupDiGetDeviceInstanceId(hDevInfo,
if(!strncmp(instanceId,“PCI“,3))
{
wprintf(L“%s\n“,guid);
printf(“%s\n“,devName);
printf(“%s\n“,instanceId);
SP_PROPCHANGE_PARAMS params = {sizeof(SP_CLASSINSTALL_HEADER )};
params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
params.Scope = DICS_FLAG_CONFIGSPECIFIC;
params.StateChange = DICS_DISABLE;
params.HwProfile = 0;
SetupDiSetClassInstallParams(hDevInfo, ms, sizeof(SP_PROPCHANGE_PARAMS));
SetupDiChangeState(hDevInfo,
}
}
CoTaskMemFree(guid);
}
}
int main(int argc, char* argv[])
{
HDEVINFO hDevInfo = INVALID_HANDLE_VALUE;
hDevInfo = SetupDiGetClassDevs(NULL,NULL,NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES);
if(INVALID_HANDLE_VALUE == hDevInfo)
return GetLastError();
EnumDevices(hDevInfo);
SetupDiDestroyDeviceInfoList(hDevInfo);
}
}
CoTaskMemFree(guid);
}
}
int main(int argc, char* argv[])
{
HDEVINFO hDevInfo = INVALID_HANDLE_VALUE;
hDevInfo = SetupDiGetClassDevs(NULL,NULL,NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES);
if(INVALID_HANDLE_VALUE == hDevInfo)
return GetLastError();
EnumDevices(hDevInfo);
SetupDiDestroyDeviceInfoList(hDevInfo);
return 0;
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论