RT:
例如:禁用本地连接
例如:修复本地连接
例如:把本地连接设置为共享等等
如有现成的例子烦请发到我的邮箱:[email protected]
谢谢!
------解决方案--------------------
- C/C++ code
forwardglobal type nvo_netlink from nonvisualobjectend typeend forwardglobal type nvo_netlink from nonvisualobject autoinstantiateend typetype variablesstring is_errorend variablesforward prototypespublic function boolean of_netlink (string as_adaptername, string as_oper)public subroutine of_disconnect (ref oleobject ao)public function string of_geterror ()public function boolean of_connect (ref oleobject ao, string as_name)public function integer of_dirlist_netlink (dropdownlistbox addlb)public function integer of_dirlist_oper (string as_adaptername, dropdownlistbox addlb)end prototypespublic function boolean of_netlink (string as_adaptername, string as_oper);if as_adaptername = '' or as_oper = '' then return falseoleobject lo_Shell, lo_folder, lo_folderitems, lo_folderitem, lo_folderitemverbs, lo_folderitemverbif not of_connect(lo_Shell, "shell.application") then return falselo_folder = lo_Shell.NameSpace(49)if not isvalid(lo_folder) then is_error = '无法通过NameSpace方法获取【网络连接】目录!' goto labelend iflo_folderitems = lo_folder.Items()boolean flag = falseint iFor i = 1 to lo_folderitems.count lo_folderitem = lo_folderitems.item(i - 1) If lo_folderitem.Name = as_adaptername Then flag = True Exit End IfNextIf flag = False Then is_error = '网络连接【' + as_adaptername + '】不存在!' GoTo labelEnd Ifflag = falselo_folderitemverbs = lo_folderitem.verbs()For i = 1 to lo_folderitemverbs.count lo_folderitemverb = lo_folderitemverbs.item(i - 1) If lo_folderitemverb.Name = as_oper Then try lo_folderitemverb.DoIt() flag = True catch(oleruntimeerror er) is_error = '网络连接【' + as_adaptername + '】对应的菜单操作【' + as_oper + '】当前不允许执行!' end try if not flag then GoTo label exit End IfNextIf flag = False Then is_error = '网络连接【' + as_adaptername + '】对应的菜单操作【' + as_oper + '】不存在!' GoTo labelEnd Iflabel:of_disconnect(lo_Shell)return flagend functionpublic subroutine of_disconnect (ref oleobject ao);//断开并注销oleif not isvalid(ao) then returnao.disconnectobject()destroy aoend subroutinepublic function string of_geterror ();//提取错误return is_errorend functionpublic function boolean of_connect (ref oleobject ao, string as_name);if isvalid(ao) then of_disconnect(ao)ao = create oleobjectint lili = ao.connecttonewobject(as_name)if li = 0 then return trueis_error = '连接【' + as_name + '】失败!~r~n失败原因:'choose case li case -1 is_error += 'Invalid Call: the argument is the Object property of a control' case -2 is_error += 'Class name not found' case -3 is_error += 'Object could not be created' case -4 is_error += 'Could not connect to object' case -9 is_error += 'Other error' case -15 is_error += 'MTS is not loaded on this computer' case -16 is_error += 'Invalid Call: this function not applicable' case else is_error += 'Unknow error'end choosereturn falseend functionpublic function integer of_dirlist_netlink (dropdownlistbox addlb);addlb.reset()int i, count = -1oleobject lo_Shell, lo_folder, lo_folderitems, lo_folderitemif not of_connect(lo_Shell, "shell.application") then return count//lo_folder = lo_Shell.NameSpace(49)if not isvalid(lo_folder) then is_error = '无法通过NameSpace方法获取【网络连接】目录!' goto labelend iflo_folderitems = lo_folder.Items()count = lo_folderitems.countFor i = 1 to count lo_folderitem = lo_folderitems.item(i - 1) addlb.additem(lo_folderitem.Name)Nextlabel:of_disconnect(lo_Shell)return countend functionpublic function integer of_dirlist_oper (string as_adaptername, dropdownlistbox addlb);addlb.reset()int i, count = -1oleobject lo_Shell, lo_folder, lo_folderitems, lo_folderitem, lo_folderitemverbif not of_connect(lo_Shell, "shell.application") then return countlo_folder = lo_Shell.NameSpace(49)if not isvalid(lo_folder) or isnull(lo_folder) then is_error = '无法通过NameSpace方法获取【网络连接】目录!' goto labelend iflo_folderitems = lo_folder.Items()boolean flag = falseFor i = 1 to lo_folderitems.count lo_folderitem = lo_folderitems.item(i - 1) If lo_folderitem.Name = as_adaptername Then flag = True Exit End IfNextIf flag = False Then is_error = '网络连接【' + as_adaptername + '】不存在!' GoTo labelEnd Ifcount = lo_folderitem.verbs().countFor i = 1 to count lo_folderitemverb = lo_folderitem.verbs().item(i - 1) addlb.additem(lo_folderitemverb.Name)Nextlabel:of_disconnect(lo_Shell)return countend functionon nvo_netlink.createcall super::createTriggerEvent( this, "constructor" )end onon nvo_netlink.destroyTriggerEvent( this, "destructor" )call super::destroyend on