| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1934 人关注过本帖
标题:VB如何遍历驱动程序?
只看楼主 加入收藏
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1926
专家分:2992
注 册:2009-12-22
结帖率:89.13%
收藏
 问题点数:0 回复次数:9 
VB如何遍历驱动程序?
VB如何遍历驱动程序名称?有可能做到吗?
搜索更多相关主题的帖子: VB 名称 遍历 驱动 
2022-03-18 19:51
约定的童话
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:56
帖 子:246
专家分:1442
注 册:2021-8-1
收藏
得分:0 
https://blog.
参考下
2022-03-19 08:00
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1926
专家分:2992
注 册:2009-12-22
收藏
得分:0 
回复 2楼 约定的童话
遍历驱动程序,不是遍历驱动器。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-03-19 18:53
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1479
专家分:9055
注 册:2010-3-16
收藏
得分:0 
祝你好运

[此贴子已经被作者于2022-3-20 23:07编辑过]

2022-03-19 20:53
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1926
专家分:2992
注 册:2009-12-22
收藏
得分:0 
参考链接没有营养,用Win32_SystemDriver是可以的。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-03-20 18:30
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1926
专家分:2992
注 册:2009-12-22
收藏
得分:0 
程序代码:
Private Sub Form_Load()
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
strComputer = "."
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemDriver", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
'Debug.Print objItem.DisplayName  '驱动名称
Debug.Print objItem.PathName  '驱动路径
Next
End Sub


[此贴子已经被作者于2022-5-15 08:42编辑过]


心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-03-21 19:14
时光流逝
Rank: 4
来 自:北京
等 级:业余侠客
威 望:8
帖 子:92
专家分:297
注 册:2019-11-16
收藏
得分:0 
如果你不嫌麻烦,也可以这样:
程序代码:
Private Declare Function VirtualAlloc Lib "kernel32.dll" (ByVal Address As Long, ByVal dwSize As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long
'Public Declare Function ZwUnloadDriver Lib "ntdll.dll" (DriverServiceName As UNICODE_STRING) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    ByVal pDst As Long, _
    ByVal pSrc As Long, _
    ByVal ByteLen As Long)
Private Declare Function NtQuerySystemInformation Lib "ntdll.dll" ( _
    ByVal SystemInformationClass As Long, _
    ByVal pSystemInformation As Long, _
    ByVal SystemInformationLength As Long, _
    ByRef ReturnLength As Long) As Long    
Private Type SYSTEM_MODULE_INFORMATION_ENTRY
    dwReserved(1) As Long
    dwBase As Long
    dwSize As Long
    dwFlags As Long
    Index As Integer
    Unknown As Integer
    LoadCount As Integer
    ModuleNameOffset As Integer
    ImageName As String * 256
End Type
Private Type SYSTEM_MODULE_INFORMATION
    Count As Long
    ModuleInformation As SYSTEM_MODULE_INFORMATION_ENTRY
End Type    
Private Const SystemModuleInformation = 11
Private Const PAGE_READWRITE = &H4
Private Const MEM_RELEASE = &H8000
Private Const MEM_COMMIT = &H1000
Public Sub GetKernelModuleList(lvwKernelModule As ListView)
    Dim ret As Long
    Dim Buffer As Long
    Dim ModulesInfo As SYSTEM_MODULE_INFORMATION
    Dim I As Long
    Dim n As Integer: n = 1
    
    NtQuerySystemInformation SystemModuleInformation, 0, 0, ret
    Buffer = VirtualAlloc(0, ret * 2, MEM_COMMIT, PAGE_READWRITE)
    NtQuerySystemInformation SystemModuleInformation, Buffer, ret * 2, ret
    CopyMemory ByVal VarPtr(ModulesInfo), ByVal Buffer, LenB(ModulesInfo)
    I = ModulesInfo.Count
    While (I > 1)
        I = I - 1
        Buffer = Buffer + 71 * 4
        CopyMemory ByVal VarPtr(ModulesInfo), ByVal Buffer, LenB(ModulesInfo)
        lvwKernelModule.ListItems.Add , , n'驱动索引
        'MyMsgBox InStrRev(GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode)), "\")
        'MyMsgBox Len(GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode)))
        lvwKernelModule.ListItems(n).SubItems(1) = Right(GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode)), Len(GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode))) - InStrRev(GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode)), "\")) '驱动名称
        lvwKernelModule.ListItems(n).SubItems(2) = "0x" & Hex(ModulesInfo.ModuleInformation.dwBase) '驱动基址
        lvwKernelModule.ListItems(n).SubItems(3) = "0x" & Hex(ModulesInfo.ModuleInformation.dwSize) '驱动偏移
        lvwKernelModule.ListItems(n).SubItems(4) = ModulesInfo.ModuleInformation.LoadCount '驱动加载次数
        lvwKernelModule.ListItems(n).SubItems(5) = ModulesInfo.ModuleInformation.dwFlags '驱动标志
        lvwKernelModule.ListItems(n).SubItems(6) = GetCorrectPath(StrConv(ModulesInfo.ModuleInformation.ImageName, vbUnicode)) '驱动路径
        DoEvents
        n = n + 1
    Wend
    Exit Sub
End Sub

Private Function GetCorrectPath(lpPath As String) As String    
    Dim CorrectPath As String    
    CorrectPath = lpPath    
    If InStr(lpPath, "\??\") = 1 Then CorrectPath = Right(lpPath, Len(lpPath) - 4)    
    If InStr(lpPath, "\??\") = 3 Then CorrectPath = Replace(CorrectPath, "\??\", "")    
    CorrectPath = Replace(CorrectPath, "\SystemRoot\", "C:\")    
    If InStr(CorrectPath, "C:") <> 1 Then        
        GetCorrectPath = Left("C:" & CorrectPath, InStr("C:" & CorrectPath, ".") + 3)        
    Else        
        GetCorrectPath = Left(CorrectPath, InStr(CorrectPath, ".") + 3)        
    End If    
    If LCase(Left(GetCorrectPath, 11)) = "c:\system32" Then GetCorrectPath = "c:\windows\system32" & Right(GetCorrectPath, Len(GetCorrectPath) - 11)    
    GetCorrectPath = UCase(Left(GetCorrectPath, 1)) & Right(GetCorrectPath, Len(GetCorrectPath) - 1)
End Function
2022-05-14 21:31
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1926
专家分:2992
注 册:2009-12-22
收藏
得分:0 
你这代码修改一下还好能运行,只是获取的驱动名称是驱动的文件名,不如我上面WIN32类获取的简洁。其它没有问题。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-05-15 08:45
时光流逝
Rank: 4
来 自:北京
等 级:业余侠客
威 望:8
帖 子:92
专家分:297
注 册:2019-11-16
收藏
得分:0 
但是可以获取驱动基址
2022-05-15 14:58
独木星空
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:河北省曲阳县
等 级:版主
威 望:71
帖 子:803
专家分:683
注 册:2016-6-29
收藏
得分:0 
都是高手,学习了。

素数问题的解决是我学习编程永恒的动力。
2022-05-15 21:30
快速回复:VB如何遍历驱动程序?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021352 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved