Windows Installer API (SDK)

RegLocator Table

Referenz » RegLocator Table | Microsoft Docs


VBS class RegLocator


Class classRegLocatorTable
Private mSignature, mRoot, mKey, mName, mType

    Public Property Get pSignature
        pSignature = mSignature
    End Property
    Public Property Let pSignature(strSignature)
        mSignature = strSignature
    End Property
    Public Property Get pRoot
        pRoot = mRoot
    End Property
    Public Property Let pRoot(intRoot)
        mRoot = intRoot
    End Property
    Public Property Get pKey
        pKey = mKey
    End Property
    Public Property Let pKey(strKey)
        mKey = strKey
    End Property
    Public Property Get pName
        pName = mName
    End Property
    Public Property Let pName(strName)
        mName = strName
    End Property
    Public Property Get pType
        pType = mType
    End Property
    Public Property Let pType(intType)
        mType = intType
    End Property

    Private Sub Class_Initialize
        'Anweisungen
    End Sub
    ' -----------------------------------------------------------------

    Public Function CreateTable()
    Dim strSQL, objView

    strSQL = "CREATE TABLE " & Chr(96) & "RegLocator" & Chr(96) & " (" & _
                 Chr(96) & "Signature_" & Chr(96) & " CHAR(72) NOT NULL, " & _
                 Chr(96) & "Root" & Chr(96) & " SHORT NOT NULL, " & _
                 Chr(96) & "Key" & Chr(96) & " CHAR(255) NOT NULL, " & _
                 Chr(96) & "Name" & Chr(96) & " CHAR(255), " & _
                 Chr(96) & "Type" & Chr(96) & " SHORT PRIMARY KEY " & _
                 Chr(96) & "Signature_" & Chr(96) & ")"

    Set objView = objDatabase.OpenView(strSQL)
    objView.Execute
    objDatabase.Commit()

    msiValidation.pTable = "RegLocator"
    msiValidation.pColumn = "Signature_"
    msiValidation.pNullable = "N"
    msiValidation.pMinValue = Null
    msiValidation.pMaxValue = Null
    msiValidation.pKeyTable = ""
    msiValidation.pKeyColumn = Null
    msiValidation.pCategory = "Identifier"
    msiValidation.pSet = ""
    msiValidation.pDescription = "The table key. The Signature_ represents a unique file signature " & _
                    "and is also the foreign key in the Signature table. If the type is 0, the  " & _
                    "registry values refers a directory, and _Signature is not a foreign key."

        msiValidation.ModifyValidationRecord
        msiValidation.ResetValidationRecord

    msiValidation.pTable = "RegLocator"
    msiValidation.pColumn = "Root"
    msiValidation.pNullable = "N"
    msiValidation.pMinValue = cInt("0")
    msiValidation.pMaxValue = cInt("3")
    msiValidation.pKeyTable = ""
    msiValidation.pKeyColumn = Null
    msiValidation.pCategory = ""
    msiValidation.pSet = ""
    msiValidation.pDescription = "The predefined root key for the registry value, one of rrkEnum."

        msiValidation.ModifyValidationRecord
        msiValidation.ResetValidationRecord

    msiValidation.pTable = "RegLocator"
    msiValidation.pColumn = "Key"
    msiValidation.pNullable = "N"
    msiValidation.pMinValue = Null
    msiValidation.pMaxValue = Null
    msiValidation.pKeyTable = ""
    msiValidation.pKeyColumn = Null
    msiValidation.pCategory = "RegPath"
    msiValidation.pSet = ""
    msiValidation.pDescription = "The key for the registry value."

        msiValidation.ModifyValidationRecord
        msiValidation.ResetValidationRecord

    msiValidation.pTable = "RegLocator"
    msiValidation.pColumn = "Name"
    msiValidation.pNullable = "Y"
    msiValidation.pMinValue = Null
    msiValidation.pMaxValue = Null
    msiValidation.pKeyTable = ""
    msiValidation.pKeyColumn = Null
    msiValidation.pCategory = "Formatted"
    msiValidation.pSet = ""
    msiValidation.pDescription = "The registry value name."

        msiValidation.ModifyValidationRecord
        msiValidation.ResetValidationRecord

    msiValidation.pTable = "RegLocator"
    msiValidation.pColumn = "Type"
    msiValidation.pNullable = "Y"
    msiValidation.pMinValue = cInt("0")
    msiValidation.pMaxValue = cInt("2")
    msiValidation.pKeyTable = ""
    msiValidation.pKeyColumn = Null
    msiValidation.pCategory = "Formatted"
    msiValidation.pSet = ""
    msiValidation.pDescription = "An integer value that determines if the registry value is a filename " & _
                                    "or a directory location or to be used as is w/o interpretation."

        msiValidation.ModifyValidationRecord
        msiValidation.ResetValidationRecord

    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Public Function ModifyRegLocatorRecord()
    Dim strSQL, objView, objTableRow

    strSQL = "SELECT * FROM RegLocator"

    Set objView = objDatabase.OpenView(strSQL)
    objView.Execute
    Do 
        Set objTableRow = objView.Fetch
        If objTableRow Is Nothing Then
            Set objTableRow = objInstaller.CreateRecord(5)
            objTableRow.StringData(1) = mSignature
            objTableRow.IntegerData(2) = mRoot
            objTableRow.StringData(3) = mKey
            objTableRow.StringData(4) = mName
            objTableRow.IntegerData(5) = mType
            objView.Modify msiViewModifyAssign, objTableRow
            Exit Do
        End If
            objTableRow.StringData(1) = mSignature
            objTableRow.IntegerData(2) = mRoot
            objTableRow.StringData(3) = mKey
            objTableRow.StringData(4) = mName
            objTableRow.IntegerData(5) = mType
            objView.Modify msiViewModifyAssign, objTableRow
    Loop
    objDatabase.Commit()
    objView.Close
    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Public Function ExcludeDuplicateSignature(strSignature)
    Dim objView, objRecord, strSQL
    Dim intPOS, intCount, strTemp

    intPOS = ""
    intCount = ""
    strTemp = ""
    strSQL = "SELECT RegLocator.Signature_ FROM RegLocator"

    Set objView = objDatabase.OpenView(strSQL)
    objView.Execute
    Do
        Set objRecord = objView.Fetch
        If objRecord Is Nothing Then Exit Do
    
        If objRecord.StringData(1) <> mSignature Then
            'do nothing
        Else
            If Instr(1, objRecord.StringData(1), strSignature & "_", vbTextCompare) Then
                intPOS = InStrRev(objRecord.StringData(1), "_", -1, 1)
                intCount = CInt(Mid(objRecord.StringData(1), intPOS + 1))
                If IsNumeric(intCount) AND intCount <> "" Then
                    strTemp = strSignature & "_" & CStr(CInt(intCount) + 1)
                End If
            ElseIf objRecord.StringData(1) = strSignature Then
               If Right(objRecord.StringData(1), 2) <> "_1" Then
                    strTemp = strSignature & "_1"
               End If
            End If
        End If
    Loop
    If strTemp <> "" Then
        mSignature = strTemp
    Else
        mSignature = strSignature
    End If
    objView.Close
    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Public Function ExecuteRequest(strKey, strValue)
    Dim PosFirst, PosLast, tmpRoot

    If IsMissingTable("RegLocator") Then CreateTable

    If InStr(1,strValue, "\", vbTextCompare) Then _
        PosFirst = InStr(1,strValue, "\", vbTextCompare)
    If InStrRev(strValue, "\", -1, vbTextCompare) Then _
        PosLast = InStrRev(strValue, "\", -1, vbTextCompare)
    tmpRoot = Left(strValue, PosFirst - 1)

    Select Case UCase(tmpRoot)
        Case "HKEY_CLASSES_ROOT", "HKCR"
            mRoot = CInt("0")
        Case "HKEY_CURRENT_USER", "HKCU"
            mRoot = CInt("1")
        Case "HKEY_LOCAL_MACHINE", "HKLM"
            mRoot = CInt("2")
        Case "HKEY_USERS", "HKU"
            mRoot = CInt("3")
        Case Else
    End Select

    mSignature = LCase(strKey)
    mKey = Mid(strValue, PosFirst + 1, PosLast - PosFirst - 1)
    mName = Mid(strValue, PosLast + 1)

    If ApplicationInfo.pArchitecture = "Intel" Then
        mType = 2
    Else
        If InStr(1,strValue, "Wow6432Node", vbTextCompare) Then
            mType = 2
        Else
            mType = 18
        End If
    End If
        ModifyRegLocatorRecord

    msiAppSearch.pProperty = UCase(strKey)
    msiAppSearch.pSignature = LCase(strKey)
        msiAppSearch.ModifyAppSearchRecord

    End Function
    ' -----------------------------------------------------------------

    Public Function DeleteRegLocatorRecord()
    Dim strSQL, objView, objTableRow

    strSQL = "SELECT * FROM RegLocator"

    Set objView = objDatabase.OpenView(strSQL)
    objView.Execute
    Do 
        Set objTableRow = objView.Fetch
        If objTableRow Is Nothing Then Exit Do

        If objTableRow.StringData(1) = mSignature Then _
           objView.Modify msiViewModifyDelete, objTableRow
    Loop
    objDatabase.Commit()
    objView.Close
    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Public Function DeleteAllRecords()
    Dim strSQL, objView

    strSQL = "DELETE FROM RegLocator"

    Set objView = objDatabase.OpenView(strSQL)
        objView.Execute
    objDatabase.Commit()
        objView.Close
    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Public Function DropTable()
    Dim strSQL, objView

    strSQL = "DROP TABLE RegLocator"

    Set objView = objDatabase.OpenView(strSQL)
        objView.Execute
    objDatabase.Commit()
        objView.Close
    Set objView = Nothing

    End Function
    ' -----------------------------------------------------------------

    Private Sub Class_Terminate()
        'Anweisungen
    End Sub
End Class
' ---------------------------------------------------------------------