Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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