Salesforce

How to extract all Uninstall entries from the Registry?

« Go Back

Information

 
TitleHow to extract all Uninstall entries from the Registry?
URL Namehow-to-extract-all-uninstall-entries-from-the-registry
Article Number000115061
EnvironmentProduct: OpenEdge
Version: 10.2x, 11.x
OS: Windows
Question/Problem Description

When looking for a comprehensive list of programs installed on a given machine a good number of them can be found in the registry under the Microsoft\WindowsCurrentVersion\Uninstall key.  Can this information be read from the registry programmatically?
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
USING Microsoft.Win32.*.
USING System.Collections.Generic.*.

DEFINE VARIABLE giAppSeq AS INTEGER NO-UNDO.

DEFINE TEMP-TABLE ttApplication
    FIELD tiAppSeq          AS INTEGER
    FIELD tcName            AS CHARACTER LABEL "Display name"       FORMAT "x(80)"
    FIELD tcVersion         AS CHARACTER LABEL "Display version"    FORMAT "x(12)"
    FIELD tiSize            AS INT64     LABEL "Estimated size"     FORMAT ">>,>>>,>>>,>>9"
    FIELD tcInstallLocation AS CHARACTER LABEL "Install location"   FORMAT "x(80)"
    FIELD tcInstallSource   AS CHARACTER LABEL "Install source"     FORMAT "x(80)"
    FIELD tcUninstallString AS CHARACTER LABEL "Uninstall string"   FORMAT "x(80)"
    FIELD tdtInstallDate    AS DATE      LABEL "Install date"       FORMAT "99/99/9999"
    FIELD tcHelpLink        AS CHARACTER LABEL "Application help"   FORMAT "x(80)"
    FIELD tcReadme          AS CHARACTER LABEL "Application readme" FORMAT "x(80)"
    INDEX idxAppSeq IS PRIMARY UNIQUE tiAppSeq.

DEFINE QUERY qryApps FOR ttApplication SCROLLING.
DEFINE BROWSE brwApps QUERY qryApps 
    DISPLAY ttApplication EXCEPT tiAppSeq
    WITH NO-ROW-MARKERS SEPARATORS SIZE 167 BY 23.96 FIT-LAST-COLUMN.

BROWSE brwApps:COLUMN-RESIZABLE = TRUE.

DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

DEFINE FRAME DEFAULT-FRAME brwApps
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 1 ROW 1
         SIZE 168.29 BY 24.23 WIDGET-ID 100.

CREATE WINDOW C-Win ASSIGN
         HIDDEN             = true
         TITLE              = "Installed Windows Applications"
         HEIGHT             = 24.23
         WIDTH              = 168.29
         MAX-HEIGHT         = 24.23
         MAX-WIDTH          = 168.29
         VIRTUAL-HEIGHT     = 24.23
         VIRTUAL-WIDTH      = 168.29
         RESIZE             = yes
         SCROLL-BARS        = no
         STATUS-AREA        = no
         BGCOLOR            = ?
         FGCOLOR            = ?
         KEEP-FRAME-Z-ORDER = yes
         THREE-D            = yes
         MESSAGE-AREA       = no
         SENSITIVE          = yes
         HIDDEN             = FALSE.

CURRENT-WINDOW = C-Win.

DEFINE VARIABLE oRegistryKey  AS RegistryKey           NO-UNDO.

oRegistryKey = Registry:CurrentUser:OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall").
    RUN loadApplicationList ( INPUT "CurrentUser",
                              INPUT oRegistryKey ).

oRegistryKey = Registry:LocalMachine:OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall").
    RUN loadApplicationList ( INPUT "LocalMachine",
                              INPUT oRegistryKey ).
    
oRegistryKey = Registry:LocalMachine:OpenSubKey("SOFTWARE\\Wow6432\\Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall").
    RUN loadApplicationList ( INPUT "LocalMachine",
                              INPUT oRegistryKey ).

OPEN QUERY qryApps FOR EACH ttApplication.
ENABLE ALL WITH FRAME DEFAULT-FRAME.
WAIT-FOR CLOSE OF THIS-PROCEDURE.

PROCEDURE loadApplicationList :
    DEFINE INPUT PARAMETER pcParentKey   AS CHARACTER   NO-UNDO.
    DEFINE INPUT PARAMETER poRegistryKey AS RegistryKey NO-UNDO.
    
    DEFINE VARIABLE oApplication  AS RegistryKey           NO-UNDO.
    
    DEFINE VARIABLE iApplication  AS INTEGER               NO-UNDO.
    DEFINE VARIABLE iMonth        AS INTEGER               NO-UNDO.
    DEFINE VARIABLE iDay          AS INTEGER               NO-UNDO.
    DEFINE VARIABLE iYear         AS INTEGER               NO-UNDO.
    
    DEFINE VARIABLE cAppArray     AS CHARACTER             NO-UNDO EXTENT.
    DEFINE VARIABLE cSize         AS CHARACTER             NO-UNDO.
    DEFINE VARIABLE cInstallDate  AS CHARACTER             NO-UNDO.
    DEFINE VARIABLE cAppName      AS CHARACTER             NO-UNDO.
    
    IF VALID-OBJECT(poRegistryKey) AND poRegistryKey:SubKeyCount GT 0 THEN DO:
        cAppArray = poRegistryKey:GetSubKeyNames().
    
        DO iApplication = 1 TO poRegistryKey:SubKeyCount:
            oApplication = poRegistryKey:OpenSubKey(cAppArray[iApplication]).
            
            cAppName = oApplication:GetValue("DisplayName").
            IF (cAppName GT "") NE TRUE THEN NEXT.
            
            CREATE ttApplication.
            ASSIGN giAppSeq          = giAppSeq + 1
                   tiAppSeq          = giAppSeq
                   tcName            = cAppName + " (" + pcParentKey + ")"
                   tcVersion         = oApplication:GetValue("DisplayVersion")
                   cSize             = oApplication:GetValue("EstimatedSize")
                   tiSize            = (if (cSize gt "") ne true then ? 
                                        else 
                                            (if index(cSize,"(") eq 0 then 
                                                 int64(cSize)
                                             else 
                                                 int64(right-trim(entry(2,cSize,"("),")"))))
                   tcInstallLocation = oApplication:GetValue("InstallLocation")
                   tcInstallSource   = oApplication:GetValue("InstallSource")
                   tcUninstallString = oApplication:GetValue("UninstallString")
                   cInstallDate      = oApplication:GetValue("InstallDate")
                   tcHelpLink        = oApplication:GetValue("HelpLink")
                   tcReadMe          = oApplication:GetValue("Readme").
            
            IF (cInstallDate GT "") EQ TRUE THEN
                ASSIGN iYear             = INTEGER(SUBSTRING(cInstallDate,1,4))
                       iMonth            = INTEGER(SUBSTRING(cInstallDate,5,2))
                       iDay              = INTEGER(SUBSTRING(cInstallDate,7))
                       tdtInstallDate    = DATE(iMonth,iDay,iYear).
        END.    
    END.
END PROCEDURE.

 
Workaround
Notes

References to Other Documentation:
Progress Article(s):
 Considerations when upgrading from OpenEdge 11 to a later OpenEdge 11 version.
 
Keyword Phrase
Last Modified Date11/20/2020 7:15 AM

Powered by