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

推荐订阅源

G
Google Developers Blog
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
D
Docker
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Project Zero
Project Zero
Engineering at Meta
Engineering at Meta
J
Java Code Geeks
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Simon Willison's Weblog
Simon Willison's Weblog
S
Security Affairs
NISL@THU
NISL@THU
T
Tor Project blog
A
About on SuperTechFans
宝玉的分享
宝玉的分享
腾讯CDC
S
Schneier on Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
P
Privacy International News Feed
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
Vercel News
Vercel News
Cisco Talos Blog
Cisco Talos Blog
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
L
LINUX DO - 热门话题
Microsoft Security Blog
Microsoft Security Blog
Latest news
Latest news
C
Check Point Blog
有赞技术团队
有赞技术团队
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
云风的 BLOG
云风的 BLOG
SecWiki News
SecWiki News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
爱范儿
爱范儿
月光博客
月光博客
V
Vulnerabilities – Threatpost
T
Threat Research - Cisco Blogs
P
Palo Alto Networks Blog
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
Webroot Blog
Webroot Blog
S
Security @ Cisco Blogs

博客园 - 学剑学诗两不成

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