Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Display The Windows Registered User

The strings related to the registered user of a particular copy of Windows are stored in a string inside USER.EXE. You can retrieve them with code. In the general declarations section, insert:
Declare Function GetModuleHandle Lib "Kernel" _
	(ByVal Module As String) As Integer
Declare Function LoadString Lib "User" _
	(ByVal hInst As Integer, _
	ByVal wID As Integer, ByVal buf as Any, _
	ByVal size As Integer) As Integer
To get the user name and company strings into a variable, use this code:
 Sub Form_Load ()
Dim hInst As Integer, user As String, _
	org As String, title As String, length As Integer
user = Space$(256)
org = Space$(256)
hInst = GetModuleHandle("user.exe")
length = LoadString(hInst, 514, user, Len(user))
user = Left$(user, length)
length = LoadString(hInst, 515, org, Len(org))
organization = Left$(org, length)
Debug.Print user
Debug.Print organization
End Sub
Bill Reid
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date