Get registered username and company from windows.


Declare Function GetModuleHandle% Lib "Kernel" (ByVal Module$)
Declare Function LoadString% Lib "User" (ByVal hInst%, ByVal wID%, ByVal buf As Any, ByVal size%)

Sub GetRegisteredInfo (strName$, strCompany$)
'Returns the registered user name and company name of the Windows system
    Static hInst%, iLength%
    Static strTemp$

    hInst = GetModuleHandle("user.exe")

    'Get user name
    strTemp = Space$(256)
    iLength = LoadString(hInst, 514, strTemp, Len(strTemp))
    txtName.Text = Left$(strTemp, iLength)

    'Get organization
    strTemp = Space$(256)
    iLength = LoadString(hInst, 515, strTemp, Len(strTemp))
    txtCompany.Text = Left$(strTemp, iLength)
End Sub



Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 980315
<- The VB home
<- Daniels homepage