INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Forms & Screen

How can I display the registered name/company on a splash screen by ChrisRChamberlain
Posted: 19 Feb 03 (Edited 19 Feb 03)

If you want to retrieve the user's registered name and company from the registry and display it on a splash screen try the following code.

Once the values have been retrieved, they are passed as parameters to the splash screen and become the captions for two labels identifying the user's name and company.

If the splash screen is a top-level form, make sure _SCREEN. Visible = .F., initialise the application, create toolbar(s), run menu, and instantiate main/other form(s) BEFORE removing the splash screen, making _SCREEN. Visible = .T. and issuing READ EVENTS.

LOCAL lcAppKey ,;
    lcAppName ,;
    loRegistry
LOCAL uDataType ,;
    lcProperty    ,;
    lcValue ,;
    lnBufLen ,;
    hKey ,;
    lnResult ,;
    lnTemp ,;
    lcReturnData

#DEFINE HKEY_CURRENT_USER 2147483649
#DEFINE KEY_READ 131097

lcProperty = [DefName]
lcSoftWareKey =    [Software\Microsoft\MS Setup (ACME)\User Info]
lcValue    = []

DECLARE LONG RegCloseKey in ADVAPI32.DLL ;
    INTEGER nHKey
DECLARE LONG RegOpenKeyEx in ADVAPI32.DLL ;
    INTEGER nHKey ,;
    STRING cSubKey    ,;
    INTEGER nOptions ,;
    INTEGER nAccess ,;
    INTEGER @cResult
DECLARE LONG RegQueryValueEx in ADVAPI32.DLL;
    INTEGER nHKey ,;
    STRING    cValueToGet    ,;
    INTEGER nReserved ,;
    INTEGER @nType    ,;
    STRING    @cBufferData ,;
    INTEGER @nBufferLen
DECLARE INTEGER Sleep in Win32API INTEGER
            
hKey = 0

lnResult = RegOpenKeyEX( ;
    HKEY_CURRENT_USER ,;
    lcSoftWareKey ,;
    0 ,;
    KEY_READ ,;
    @hKey)

IF lnResult = 0
    lcReturnData = []
    uDataType = 0
    lnBufLen = 254
    lcReturnData = SPACE(lnBufLen)
    lnResult = RegQueryValueEx(;
        hKey ,;
        lcProperty ,;
        0 ,;
        @uDataType ,;
        @lcReturnData ,;
        @lnBufLen)
    
    lnTemp = RegCloseKey(hKey)
    lcValue = PADR(ALLT(lcReturnData),lnBufLen,[ ])
    lcValue = LEFT(lcValue,lnBufLen - 1)
ELSE
    lcValue = []
ENDI

IF EMPTY(lcValue)
   lcRegName = [(Unknown)]
ELSE
   lcRegName = lcValue
ENDIF

lcProperty    = [DefCompany]
lcSoftWareKey =    [Software\Microsoft\MS Setup (ACME)\User Info]
lcValue    = []
hKey = 0

lnResult = RegOpenKeyEX( ;
    HKEY_CURRENT_USER ,;
    lcSoftWareKey ,;
    0 ,;
    KEY_READ ,;
    @hKey)

IF lnResult = 0
    lcReturnData = []
    uDataType = 0
    lnBufLen = 254
    lcReturnData = SPACE(lnBufLen)
    lnResult = RegQueryValueEx( ;
        hKey ,;
        lcProperty ,;
        0    ,;
        @uDataType ,;
        @lcReturnData    ,;
        @lnBufLen)

    lnTemp = RegCloseKey(hKey)
    lcValue = PADR(ALLT(lcReturnData),lnBufLen,[ ])
    lcValue = LEFT(lcValue,lnBufLen - 1)
ELSE
    lcValue = []
ENDI

IF EMPTY(lcValue)
   lcRegCompany = [(Unknown)]
ELSE
   lcRegCompany = lcValue
ENDIF

PUBLIC oSplash
DO FORM splash NAME oSplash WITH lcRegName,lcRegCompany


Have fun!

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close