惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
H
Help Net Security
I
Intezer
G
Google Developers Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Troy Hunt's Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
J
Java Code Geeks
S
Security Affairs
T
The Blog of Author Tim Ferriss
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
Docker
The GitHub Blog
The GitHub Blog
F
Full Disclosure
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
S
Security @ Cisco Blogs
腾讯CDC
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
T
Threatpost
D
DataBreaches.Net
Recent Announcements
Recent Announcements
博客园 - 三生石上(FineUI控件)
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Help Net Security
Help Net Security
P
Proofpoint News Feed
Project Zero
Project Zero
S
SegmentFault 最新的问题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 叶小钗

博客园 - 学剑学诗两不成

VB:如何实现在代码中弹出toolbar的ButtonMenu VB:如何发送WM_KEYDOWN和WM_KEYUP消息 利用IDocHostUIHandler接口屏蔽WebBrowser的弹出菜单 VB:如何改变ComboBox自身的高度 VB:如何设置Richtextbox的行间距 VB:如何允许/禁止RICHTEXTBOX中的OLE对象拉伸 一个很有用的自定义函数 - 学剑学诗两不成 - 博客园 VB:如何隐藏/显示treeview的ToolTips - 学剑学诗两不成 - 博客园 VB:如何选定文件或文件夹 - 学剑学诗两不成 - 博客园 一个远程调用api函数的模块(转贴) VB:如何用需要身份验证的SMTP邮件服务器发信 - 学剑学诗两不成 - 博客园 VB:如何监听打开的窗口和程序 VB:如何隐藏ListView的某一列 vb:如何禁止鼠标指针进入某个区域 如何使frame控件的caption居中显示 - 学剑学诗两不成 - 博客园 怎样去掉窗体上的图标 - 学剑学诗两不成 - 博客园 VB中对string array快速插入、删除某个元素的办法 - 学剑学诗两不成 - 博客园 bug:在windows xp下用ImageList_GetImageCount返回值不正确(VB) - 学剑学诗两不成 - 博客园 VB中字符串数组快速复制的一种方法 - 学剑学诗两不成 - 博客园
VB:如何启用/禁用本地连接
学剑学诗两不成 · 2006-02-11 · via 博客园 - 学剑学诗两不成

        其实没什么说的,无非就是先找到“网络连接”这个虚拟文件夹,然后找到要控制的本地连接对应的folderitem,然后枚举verb,找到需要的verb后,调用verb的DoIt方法,在winxp sp2 ,vb6 sp6下测试通过,代码如下:
Option Explicit
'首先引用Microsoft Shell Controls And Automation
Private Function ExcNetLinkMenu(ByVal AdapterName As String, ByVal MenuName As String) As Boolean
    On Error Resume Next
    Dim mShell As New Shell32.Shell
    Dim NetConnection As Shell32.Folder
    Dim FolderItem As Shell32.FolderItem
    Dim NetConnectionItem As ShellFolderItem
    Dim verb As Shell32.FolderItemVerb
    Set NetConnection = mShell.NameSpace(49) '这个49是我找出来的,有了它就可以避免遍历控制面板
    If ObjPtr(NetConnection) = 0 Then
        ExcNetLinkMenu = False
        GoTo exitfunction
    End If
    Dim flag As Boolean
    flag = False
    For Each FolderItem In NetConnection.Items
        If FolderItem.Name = AdapterName Then
            Set NetConnectionItem = FolderItem
            flag = True
            Exit For
        End If
    Next
    If flag = False Then
        ExcNetLinkMenu = False
        GoTo exitfunction
    End If
    For Each verb In NetConnectionItem.Verbs
        If verb.Name = MenuName Then
            flag = True
            verb.DoIt
            ExcNetLinkMenu = True
            GoTo exitfunction
         End If
    Next
    If flag = False Then
        ExcNetLinkMenu = False
        GoTo exitfunction
    End If
exitfunction:
    Set mShell = Nothing
    Set NetConnection = Nothing
    Set FolderItem = Nothing
    Set NetConnectionItem = Nothing
    Set verb = Nothing
End Function

Private Sub Command1_Click()
        Dim flag As Boolean
        '把 本地连接 2 换成你要控制的本地连接的名字
        flag = ExcNetLinkMenu("本地连接 2", "停用(&B)") '这个在2000下对应的是禁用,具体是什么,点右键,自己看吧
End Sub

Private Sub Command2_Click()
    '把 本地连接 2 换成你要控制的本地连接的名字
    Dim flag As Boolean
    flag = ExcNetLinkMenu("本地连接 2", "启用(&A)")
End Sub