Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
How To Retrieve the Registered User Under Windows
| Article ID | : | 153309 |
| Last Review | : | July 15, 2004 |
| Revision | : | 3.2 |
This article was previously published under Q153309
On This Page
SUMMARY
The strings related to the registered user of a particular copy of Windows
are stored in a string inside USER.EXE. They are displayed in the Help
About box of File Manager, or Explorer in Windows 95 and Windows 98. This
article provides a code sample showing how to extract this information.
Back to the top
MORE INFORMATION
Step-by-Step Example
| 1. | Start a new project in Visual Basic. Form1 is created by default.
|
| 2. | Place a command button on the form.
|
| 3. | Add the following code to the form1 code window:
Option Explicit
Private Declare Function GetModuleHandle Lib "Kernel" _
(ByVal Module As String) As Integer
Private Declare Function LoadString Lib "user" _
(ByVal hInst As Integer, ByVal wID As Integer, _
ByVal buf As Any, ByVal size As Integer) As Integer
Sub Command1_Click()
Dim ihInst As Integer
Dim sUserName As String * 128
Dim sOrganization As String * 128
Dim sTitle As String
Dim iLength As Integer
ihInst = GetModuleHandle("user.exe")
iLength = LoadString(ihInst, 514, sUserName, Len(sUserName))
sUserName = Left$(sUserName, iLength)
iLength = LoadString(ihInst, 515, sOrganization, Len(sOrganization))
sOrganization = Left$(sOrganization, iLength)
Print sUserName
Print sOrganization
End Sub
|
| 4. | Press F5 to run the project. Click the command button. The information
should be printed on the form.
|
Back to the top
REFERENCES
The API can also be used if you use Visual Basic 4.0 32-bit by changing the
RegisteredOrganization and RegisteredOwner values in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
as explained in the Microsoft Knowledge Base article:
145679 (http://kbalertz.com/Feedback.aspx?kbNumber=145679/EN-US/)
: How To Use the Registry API to Save and Retrieve Setting
For additional information, please see the following article in the
Microsoft Knowledge Base:
88363 (http://kbalertz.com/Feedback.aspx?kbNumber=88363/EN-US/)
: Changing Name and Company After Windows Installation
Back to the top
APPLIES TO
| • | Microsoft Visual Basic 4.0 Standard Edition |
| • | Microsoft Visual Basic 4.0 Professional Edition |
| • | Microsoft Visual Basic 4.0 Enterprise Edition |
Back to the top
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please