Use rather WMI (Win32_UserAccount)
(+ WMI Code Creator to generate VB code)
VB Populate combo with Local Machine users
Michael
1
Reputation point
I'm new to programming. I've tried using some older code a co-worker of mine made but his program has too many variables for my program to use it.
I'm trying to populate a combobox with all of the local machine users using the registry. Below is currently what I have.
Sub GetUserList(sKeyName As String)
Dim I, Idx As Integer
Dim SubKeyName As String
LUcombo.Items.Clear()
Dim RegKey2 As RegistryKey = Registry.LocalMachine.OpenSubKey("software\microsoft\windows NT\CurrentVersion\ProfileList")
Dim SubKeys() = RegKey2.GetSubKeyNames
I = SubKeys.Length
For Idx = 0 To I - 1
SubKeyName = SubKeys(Idx).ToString
If SubKeyName.Substring(0, 8) = "S-1-5-21" Then
LUcombo.Items.AddRange(SubKeys)
End If
Next
LUcombo.Text = "-Select User-"
End Sub
Private Sub LUcombo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles LUcombo.SelectedIndexChanged
GetUserList()
End Sub
Developer technologies | VB
Developer technologies | VB
An object-oriented programming language developed by Microsoft that can be used in .NET.
1 answer
Sort by: Most helpful
-
Castorix31 91,506 Reputation points2022-08-23T12:27:57.413+00:00