Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the user name?
Message
From
28/09/1998 08:28:05
Penmetsa Sridhar
Visualsoft Technologies Limited
Hyderabad, India
 
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00141215
Message ID:
00141377
Views:
31
try this code


Public usernm As String

Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long




Sub username()
Dim szBuffer As String, dataBuff As String, ldataBuffSize As Long, _
hKey As Long, phkResult As Long, RetVal As Long, _
Value As String, RegEnumIndex As Long
'Create Buffer
dataBuff = Space(255)
ldataBuffSize = Len(dataBuff)

szBuffer = ".Default\Software\Microsoft\MS Setup (ACME)\User Info"
hKey = HKEY_USERS
RetVal = RegOpenKeyEx(hKey, szBuffer, 0, KEY_ALL_ACCESS, phkResult)

Value = "DefName"
RetVal = RegQueryValueEx(phkResult, Value, 0, 0, dataBuff, ldataBuffSize)
If RetVal = ERROR_SUCCESS Then
usernm = ConvertString(dataBuff, ldataBuffSize)
End If

'Close the keys
RegCloseKey hKey
RegCloseKey phkResult
End Sub


Username Call this function



IF u still have any problem make a reply
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform