Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I display the registered name/company on a splash screen

Forms & Screen

How can I display the registered name/company on a splash screen

by  ChrisRChamberlain  Posted    (Edited  )
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 [color blue]_SCREEN. Visible = .F.[/color], initialise the application, create toolbar(s), run menu, and instantiate main/other form(s) BEFORE removing the splash screen, making [color blue]_SCREEN. Visible = .T.[/color] and issuing [color blue]READ EVENTS[/color].
[color blue]
LOCAL lcAppKey ,;
[tab]lcAppName ,;
[tab]loRegistry
LOCAL uDataType ,;
[tab]lcProperty ,;
[tab]lcValue ,;
[tab]lnBufLen ,;
[tab]hKey ,;
[tab]lnResult ,;
[tab]lnTemp ,;
[tab]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 ;
[tab]INTEGER nHKey
DECLARE LONG RegOpenKeyEx in ADVAPI32.DLL ;
[tab]INTEGER nHKey ,;
[tab]STRING cSubKey ,;
[tab]INTEGER nOptions ,;
[tab]INTEGER nAccess ,;
[tab]INTEGER @cResult
DECLARE LONG RegQueryValueEx in ADVAPI32.DLL;
[tab]INTEGER nHKey ,;
[tab]STRING cValueToGet ,;
[tab]INTEGER nReserved ,;
[tab]INTEGER @nType ,;
[tab]STRING @cBufferData ,;
[tab]INTEGER @nBufferLen
DECLARE INTEGER Sleep in Win32API INTEGER

hKey = 0

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

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

[tab]lnTemp = RegCloseKey(hKey)
[tab]lcValue = PADR(ALLT(lcReturnData),lnBufLen,[ ])
[tab]lcValue = LEFT(lcValue,lnBufLen - 1)
ELSE
[tab]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( ;
[tab]HKEY_CURRENT_USER ,;
[tab]lcSoftWareKey ,;
[tab]0 ,;
[tab]KEY_READ ,;
[tab]@hKey)

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

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

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

PUBLIC oSplash
DO FORM splash NAME oSplash WITH lcRegName,lcRegCompany[/color]

Have fun!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top