如何获取windows所有用户及组名称

mjdwcn 2008-06-24 09:38:38
如何获取windows所有用户及组名称
...全文
196 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
神之泪花 2008-06-24
  • 打赏
  • 举报
回复
路过,关注.....
害怕飞的鸟 2008-06-24
  • 打赏
  • 举报
回复
楼上的方法貌似可行,关注
anticlimax 2008-06-24
  • 打赏
  • 举报
回复
Dim objSWbemLocator As SWbemLocator
Dim objSWbemServices As SWbemServices
Dim objSWbemObjectSet As SWbemObjectSet
Dim objSWbemObject As SWbemObject
Dim strComputer As String, strNameSpace As String, strClass As String

Public Function GetAllUser()
strComputer = "." '计算机名,.为本机
strNameSpace = "root\cimv2" '指定命名空间为root\cimv2
strClass = "Win32_UserAccount" '指定类为Win32_Service
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") '建立1个WBEM对象的引用指针
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, strNameSpace) '连接到指定计算机、命名空间的WMI,返回一个对 SWbemServices 对象的引用
Dim i As Long
Dim tmpu As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
With objSWbemObject
tmpu = IIf(tmpu = "", .Name, tmpu & ";" & .Name)
' Debug.Print .AccountType & .installdate & .Name & "-" & .PasswordChangeable & .Status & .Domain & .SIDType & "哈哈" & .PasswordRequired & .SID & .PasswordExpires & .Description
End With
Next
GetAllUser = tmpu
End Function
CloneCenter 2008-06-24
  • 打赏
  • 举报
回复
看看这个链接里面给的例子能否解决:
http://www.cnblogs.com/ww21xx/articles/93864.html

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧