Init Method
Class: aboutbox
Expand/Collapse source code of procedure Init Source Code
*-- (c) Microsoft Corporation 1995
LPARAMETERS tcAppName, tcVersion, tcCopyright, tcTrademark, tcLogoBMP

LOCAL lcBuffer, ;
      lnBufferSize, ;
      lcRetVal, ;
      lnReserved, ;
      lnResult, ;
      lnError, ;
      lnType, ;
      lcKey

*- this class can't be used independent of the application
IF TYPE("m.gTTrade") # 'L' OR !m.gTTrade
	=MESSAGEBOX(CLASSBROWERR_LOC)
	RETURN .F.
ENDIF

*-- Initialize variables for DLL calls
STORE 0 TO lnReserved, lnResult, lnType
lcBuffer = SPACE(128)
lnBufferSize = LEN(lcBuffer)

*-- Set new property values if parameters do not contain .F.
IF TYPE("tcAppName") = "C"
  thisform.Caption = ABOUT_LOC + ALLTRIM(tcAppName)
  thisform.lblAppName.Caption = ALLTRIM(tcAppName)
ENDIF    

IF TYPE("tcVersion") = "C"
  thisform.lblVersion.Caption = VERSIONLABEL_LOC + ALLTRIM(tcVersion)
ENDIF  

IF TYPE("tcCopyright") = "C"    
  thisform.lblCopyright.Caption = ALLTRIM(tcCopyright)
ENDIF  

IF TYPE("tcTrademark") = "C"    
  thisform.lblTrademark.Caption = tcTrademark
  thisform.lblTrademark.WordWrap = 1
ENDIF  

IF TYPE("tcLogoBMP") = "C"
  thisform.imgLogo.Picture = tcLogoBMP
ENDIF

STORE "" TO ;
  thisform.lblUserName.Caption, ;
  thisform.lblUserCorp.Caption, ;
  thisform.cMSInfoDir

DO CASE
  CASE UPPER(OS()) = "WINDOWS NT"
    *-- Gets default user name, organization, and location of MSINFO.EXE from 
    *-- system registry
    *-- First need to open the appropriate key
    lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_SHARED_TOOLS_LOCATION, ;
                   lnReserved, KEY_QUERY_VALUE, @lnResult)

    IF lnError = ERROR_SUCCESS
      *-- Read the value for the MSINFO entry
      lnError = RegQueryValueEx(lnResult, "MSINFO", lnReserved, ;
                                @lnType, @lcBuffer, @lnBufferSize)

      IF lnError = ERROR_SUCCESS
        *-- Strip off the "junk" at the end, and set the form property
        thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1) + "\MSINFO32.EXE"
        IF !FILE(thisform.cMSInfoDir)
          *- try the older version
          thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1) + "\MSINFO.EXE"
          IF !FILE(thisform.cMSInfoDir)
            thisform.cMSInfoDir = ""
          ENDIF
        ENDIF
      ENDIF

      *-- Close the key
      =RegCloseKey(lnResult)

      lnResult = 0
      lcKey = KEY_NTCURRENTVERSION
      lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lcKey, ;
                     lnReserved, KEY_QUERY_VALUE, @lnResult)

      *-- The next 2 calls to RegQueryValueEx() retrieve the registered owner
      *-- and registered organization of the operating system
      IF lnError = ERROR_SUCCESS
        lnType = 0
        lcBuffer = SPACE(128)
        lnBufferSize = LEN(lcBuffer)
        lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ;
                                  @lnType, @lcBuffer, @lnBufferSize)

        IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
          thisform.lblUserName.Caption = LEFT(lcBuffer, lnBufferSize - 1)
        ENDIF
      ENDIF

      lnType = 0
      lcBuffer = SPACE(128)
      lnBufferSize = LEN(lcBuffer)
      lnError = RegQueryValueEx(lnResult, "RegisteredOrganization", lnReserved, ;
                                @lnType, @lcBuffer, @lnBufferSize)

      IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
        thisform.lblUserCorp.Caption = LEFT(lcBuffer, lnBufferSize - 1)
      ENDIF
    ENDIF

    *-- Close the key
    =RegCloseKey(lnResult)

  CASE UPPER(OS()) = "WINDOWS 4"
    *-- Gets default user name, organization, and location of MSINFO32.EXE from 
    *-- system registry
    *-- First need to open the appropriate key
    lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_WIN4_MSINFO, ;
                   lnReserved, KEY_QUERY_VALUE, @lnResult)

    IF lnError = ERROR_SUCCESS
      *-- Read the value for the MSINFO entry
      lnError = RegQueryValueEx(lnResult, "PATH", lnReserved, ;
                                @lnType, @lcBuffer, @lnBufferSize)

      IF lnError = ERROR_SUCCESS
        *-- Strip off the "junk" at the end, and set the form property
        thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1)
        IF !FILE(thisform.cMSInfoDir)
          thisform.cMSInfoDir = ""
        ENDIF
      ENDIF

      *-- Close the key
      =RegCloseKey(lnResult)

      lnResult = 0
      lcKey = KEY_WIN4CURRENTVERSION
      lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lcKey, ;
                     lnReserved, KEY_QUERY_VALUE, @lnResult)

      *-- The next 2 calls to RegQueryValueEx() retrieve the registered owner
      *-- and registered organization of the operating system
      IF lnError = ERROR_SUCCESS
        lnType = 0
        lcBuffer = SPACE(128)
        lnBufferSize = LEN(lcBuffer)
        lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ;
                                  @lnType, @lcBuffer, @lnBufferSize)

        IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
          thisform.lblUserName.Caption = LEFT(lcBuffer, lnBufferSize - 1)
        ENDIF
      ENDIF

      lnType = 0
      lcBuffer = SPACE(128)
      lnBufferSize = LEN(lcBuffer)
      lnError = RegQueryValueEx(lnResult, "RegisteredOrganization", lnReserved, ;
                                @lnType, @lcBuffer, @lnBufferSize)

      IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
        thisform.lblUserCorp.Caption = LEFT(lcBuffer, lnBufferSize - 1)
      ENDIF
    ENDIF

    *-- Close the key
    =RegCloseKey(lnResult)

  OTHERWISE
    *-- Gets default user name, organization, and location of MSINFO.EXE from 
    *-- WIN.INI (for Windows 3.x machines)
    *-- Gets default user name 
    lcRetVal = GetProStr("MS USER INFO", "DEFNAME", "", @lcBuffer, lnBufferSize)
    thisform.lblUserName.Caption = LEFT(lcBuffer, lcRetVal)

    *-- Get default corporation name 
    lcRetVal = GetProStr("MS USER INFO", "DEFCOMPANY", "", @lcBuffer, lnBufferSize)
    thisform.lblUserCorp.Caption = LEFT(lcBuffer, lcRetVal)

    *-- Get location of MSINFO.EXE name
    lcRetVal = GetProStr("MICROSOFT SYSTEM INFO", "MSINFO", "", @lcBuffer, lnBufferSize)
    thisform.cMSInfoDir = LEFT(lcBuffer, lcRetVal)

ENDCASE

*-- Check if MSINFO.EXE exists, otherwise remove the System Info command button and
*-- shorten the form
IF EMPTY(thisform.cMSInfoDir)
    thisform.cMSInfoDir = " "
    thisform.cmdSysInfo.Enabled = .F.
    thisform.Height = 282
ENDIF