首先和普通的方法一樣,根據guid禁用網絡卡類裝置,只是在禁用時列舉第i塊網絡卡,讀取其裝置資訊,讀到有"wireless"這個串的就認為它是無線網絡卡,就對它使用禁用操作,否則就接著列舉第i+1塊網絡卡,直到都列舉完.
下面給出重要結構.
// drivedemodlg.cpp : implementation file
#include "stdafx.h"
#include "drivedemo.h"
#include "drivedemodlg.h"
#include < windows.h >
#include < wincon.h >
#include < stdlib.h >
#include < stdio.h >
#include
hdevinfo hdevinfo = null;
class caboutdlg : public cdialog
; protected:
virtual void dodataexchange(cdataexchange* pdx); // ddx/ddv support
protected:
declare_message_map()};
caboutdlg::caboutdlg() : cdialog(caboutdlg::idd)
{} void caboutdlg::dodataexchange(cdataexchange* pdx)
begin_message_map(caboutdlg, cdialog)
end_message_map()
cdrivedemodlg::cdrivedemodlg(cwnd* pparent /*=null*/)
: cdialog(cdrivedemodlg::idd, pparent)
void cdrivedemodlg::dodataexchange(cdataexchange* pdx)
begin_message_map(cdrivedemodlg, cdialog)
on_wm_syscommand()
on_wm_paint()
on_wm_querydragicon()
on_bn_clicked(idc_button_searialport1, onbuttonsearialport1)
on_bn_clicked(idc_button_searialport2, onbuttonsearialport2)
end_message_map()
// cdrivedemodlg message handlers
bool cdrivedemodlg::oninitdialog() }
seticon(m_hicon, true); // set big icon
seticon(m_hicon, false); // set small icon
return true; // return true unless you set the focus to a control
} void cdrivedemodlg::onsyscommand(uint nid, lparam lparam)
else }
void cdrivedemodlg::onpaint()
else }
hcursor cdrivedemodlg::onquerydragicon()
void cdrivedemodlg::onok()
void cdrivedemodlg::formatmsg(dword dwerror, lptstr * lpszmsg) }
} //changestatus
bool cdrivedemodlg::changestatus(dword newstatus, dword selecteditem, hdevinfo hdevinfo)
; sp_devinfo_data deviceinfodata = ;
hcursor = setcursor(loadcursor(null, idc_wait));
// get a handle to the selected item.
if (!setupdienumdeviceinfo(hdevinfo, selecteditem, &deviceinfodata))
// set the propchangeparams structure.
propchangeparams.classinstallheader.installfunction = dif_propertychange;
propchangeparams.scope = dics_flag_global;
propchang
eparams.statechange = newstatus;
if (!setupdisetclassinstallparams(hdevinfo, &deviceinfodata, (sp_classinstall_header *)&propchangeparams,
sizeof(propchangeparams)))
// call the classinstaller and perform the change.
if (!setupdicallclassinstaller(dif_propertychange,hdevinfo,&deviceinfodata))
setcursor(hcursor);
return true;
} catch (tchar * pszerror)
return false;
} }
// this function can stop/start the wireless.
// parameters description:the nstatus has three state.-1:do nothing
// 0 :stop the wireless,1:start the wireless.
// nindex is the parameter to said if stop the wireless.
// if you want to stop the wireless,you can call controldisk(0, 4).
bool cdrivedemodlg::controldisk(int nstatus, int nindex)
lptstr lpszmsg = null;
try
dword i;int icount=0;
sp_devinfo_data deviceinfodata;
zeromemory(&deviceinfodata, sizeof(sp_devinfo_data));
deviceinfodata.cbsize = sizeof(sp_devinfo_data);
for (i = 0; setupdienumdeviceinfo(hdevinfo, i, &deviceinfodata); ++i)
else }
cstring strethernet = buffer ;
char *str=strupr(buffer);
char *str2="wireless";//wireless sign
char *p;
p=strstr(str,str2);//compare
if (p!=null) bwireless=true;//ok,found.
if (int i= cm_get_devnode_status(&status, &problem, deviceinfodata.devinst,0) != cr_success)
if (!((status & dn_has_problem) && (cm_prob_disabled == problem)))
if ((status & dn_has_problem) && (cm_prob_disabled == problem))
if( (bdisabled==false) && (0 == nstatus) && (bwireless) )
if( (bdisabled==true) && (1 == nstatus) && (bwireless) ) }
return setupdidestroydeviceinfolist(hdevinfo);
} catch (tchar * pszerror)
return false;
} return false;
} // 禁用
void cdrivedemodlg::onbuttonsearialport1()
// 啟用
void cdrivedemodlg::onbuttonsearialport2()
Win7如何禁用無線網絡卡
教室裡的孩子們太不乖了,他們一次次通過手機讓電腦共享手機wifi上網。所以給出以下解決方案。1 解除安裝免費wifi軟體 關閉軟體或者退出。但是可以開回來。2 禁用網路連線 優點 最快捷的方式,將他們斷網。相對解除安裝軟體而言 缺點 360重新開一遍就好了。會自動重新配置網路 3 解除安裝wifi驅...
win7怎麼禁用無線網絡卡
我們有時候電腦上用網線上網的時候,或者通過手機讓電腦共享手機wifi上網後,這時候我們是可以關閉禁用無線網絡卡的,是不是要禁用無線網絡卡要根據自己需要來操作,那麼我們如何禁用無線網絡卡呢?有些朋友老是在問這個問題,小編這裡介紹下win7系統下無線網絡卡禁用的方法。我們點選工作列右下角的網路圖示,這裡...
win7怎麼禁用無線網絡卡
我們有時候電腦上用網線上網的時候,或者通過手機讓電腦共享手機wifi上網後,這時候我們是可以關閉禁用無線網絡卡的,是不是要禁用無線網絡卡要根據自己需要來操作,那麼我們如何禁用無線網絡卡呢?有些朋友老是在問這個問題,小編這裡介紹下win7系統下無線網絡卡禁用的方法。我們點選工作列右下角的網路圖示,這裡...