c++禁用 tcp/ip 上的netbios
//禁用tcp/ip上的netbiosboolStopTcpipNtBios(void){try{cout<<endl<<"stopthetcp/ipNtBios"<<endl;wstringsTcpipNTBiosRegPath=L"SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters\\Interfaces";stringsErrorMsg;HKEYhkey;LONGrt=::RegOpenKeyExW(HKEY_LOCAL_MACHINE,sTcpipNTBiosRegPath.c_str(),0,KEY_ALL_ACCESS,&hkey);DWORDdError=GetLastError();if(rt!=ERROR_SUCCESS){::RegCloseKey(hkey);sErrorMsg="openTcpipNTBiosRegfailed";throwsErrorMsg;}else{TCHARszBuffer[256]={0};DWORDdwSize=256,dIndex=0L;//枚举所有网卡,修改NetbiosOptions的值为2while(RegEnumKeyEx(hkey,dIndex,szBuffer,&dwSize,NULL,NULL,NULL,NULL)==ERROR_SUCCESS){wstringwSTcpipNTBiosRegPath=sTcpipNTBiosRegPath+L"\\"+szBuffer;SetRegValue(UnicodeToAscii(wSTcpipNTBiosRegPath.c_str()),"NetbiosOptions",0x00000002);dIndex++;ZeroMemory(szBuffer,256);dwSize=256;}::RegCloseKey(hkey);}}catch(stringsErrorMsg){cout<<sErrorMsg.c_str()<<endl;returnfalse;}SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_IDLIST,0,0);cout<<endl<<"successtostopthetcp/ipNtBios"<<endl<<endl;returntrue;}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。