Link to home
Start Free TrialLog in
Avatar of pedro_arzac
pedro_arzac

asked on

How to add my program to windows registry


Hi my problem is that when I made my package it works perfectly but if I want to search in the windows registry for my app , in the registry I found nothing how can I put my app in //software//my app in wondows registry at local machine

 is this possible
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Here are some permutation routines you can use.

Public Enum SamplingMethod
   DiscardAfterChoosing = 1
   ReturnAfterChoosing = 2
End Enum

Private Function AssembleResults( _
   ByRef Results As Collection, _
   ByVal SlotDelimiter As String) As Collection
   
' Combines results into strings with elements separated by SlotDelimiter.
   
   Dim AssembledResult As String
   Dim SelectionIndex As Long
   Dim ElementIndex As Long
   
   Set AssembleResults = New Collection
   For SelectionIndex = 1 To Results.Count
      AssembledResult = Results(SelectionIndex)(1)
      If Results(SelectionIndex).Count > 1 Then
         For ElementIndex = 2 To Results(SelectionIndex).Count
            AssembledResult = AssembledResult & SlotDelimiter & Results(SelectionIndex)(ElementIndex)
         Next
      End If
      AssembleResults.Add AssembledResult
   Next
   
End Function

Private Sub BuildCombinations( _
   ByRef SampleList As Collection, _
   ByVal SelectionSize As Long, _
   ByRef SampleListIndex() As Long, _
   ByVal SelectionCount As Long, _
   ByRef Permutations As Collection)
   
' Returns all combinations of sample list in lexicographic order.
' (0 1 2 3), 3 => ((0 1 2) (0 1 3) (0 2 3) (1 2 3))
' Selection size must be less than or equal to the number of SampleList elements.
' SampleListIndex must contain at least SelectionSize elements.
   
   Dim Index As Long
   Dim StartIndex As Long
   Dim Permutation As Collection
   
   If SelectionCount = SelectionSize Then
      ' Build new permutation and add to collection
      Set Permutation = New Collection
      For Index = 1 To SelectionSize
         Permutation.Add SampleList(SampleListIndex(Index))
      Next
      Permutations.Add Permutation
   Else
      If SelectionCount = 0 Then
         StartIndex = 1
      Else
         StartIndex = SampleListIndex(SelectionCount) + 1
      End If
      For Index = StartIndex To SampleList.Count - SelectionSize + SelectionCount + 1
         ' Refer to current sample element
         SelectionCount = SelectionCount + 1
         SampleListIndex(SelectionCount) = Index
         ' Continue until last sample element used
         BuildCombinations SampleList, SelectionSize, SampleListIndex, SelectionCount, Permutations
         SelectionCount = SelectionCount - 1
      Next
   End If
   
End Sub

Private Sub BuildPermutationsMultipleLists( _
   ByRef SampleLists As Collection, _
   ByRef SampleListIndex() As Long, _
   ByVal SelectionCount As Long, _
   ByRef Permutations As Collection)
   
' Returns all permutations of multiple sample lists.
   
   Dim Index As Long
   Dim Permutation As Collection
   
   If SelectionCount = UBound(SampleListIndex) Then
      ' Build new permutation and add to collection
      Set Permutation = New Collection
      For Index = 1 To SampleLists.Count
         Permutation.Add SampleLists(Index)(SampleListIndex(Index))
      Next
      Permutations.Add Permutation
   Else
      For Index = 1 To SampleLists(SelectionCount + 1).Count
         ' Refer to current sample element
         SelectionCount = SelectionCount + 1
         SampleListIndex(SelectionCount) = Index
         ' Continue until last sample element used
         BuildPermutationsMultipleLists SampleLists, SampleListIndex, SelectionCount, Permutations
         SelectionCount = SelectionCount - 1
      Next
   End If

End Sub

Private Sub BuildPermutationsNoReturn( _
   ByRef SampleList As Collection, _
   ByRef SampleListIndex() As Long, _
   ByRef SampleListUsed() As Boolean, _
   ByVal SelectionCount As Long, _
   ByRef Permutations As Collection)
   
' Returns all permutations of sample list in lexicographic order without returning to sample.
' (0 1 2) => ((0 1 2) (0 2 1) (1 0 2) (1 2 0) (2 0 1) (2 1 0))
' Number of elements in SampleListIndex is selection size and must equal number of elements in SampleList.
' Number of elements in SampleListUsed must be same as number of elements in SampleListIndex.
   
   Dim Index As Long
   Dim Permutation As Collection
   
   If SelectionCount = UBound(SampleListIndex) Then
      ' Build new permutation and add to collection
      Set Permutation = New Collection
      For Index = 1 To SampleList.Count
         Permutation.Add SampleList(SampleListIndex(Index))
      Next
      Permutations.Add Permutation
   Else
      For Index = 1 To SampleList.Count
         If Not SampleListUsed(Index) Then
            ' Mark this sample element used
            SampleListUsed(Index) = True
            ' Refer to current sample element
            SelectionCount = SelectionCount + 1
            SampleListIndex(SelectionCount) = Index
            ' Continue until last sample element used
            BuildPermutationsNoReturn SampleList, SampleListIndex, SampleListUsed, SelectionCount, Permutations
            SelectionCount = SelectionCount - 1
            SampleListUsed(Index) = False
         End If
      Next
   End If
   
End Sub

Private Sub BuildPermutationsReturn( _
   ByRef SampleList As Collection, _
   ByRef SampleListIndex() As Long, _
   ByRef SampleListUsed() As Boolean, _
   ByVal SelectionCount As Long, _
   ByRef Permutations As Collection)
   
' Returns all permutations of sample list in lexicographic order with returning to sample.
' (0 1 2) => ((0 0 0) (0 0 1) (0 0 2) (0 1 0) (0 1 1) (0 1 2) (0 2 0) ... (2 2 2))
' Number of elements in SampleListIndex is selection size and must equal number of elements in SampleList.
' Number of elements in SampleListUsed must be same as number of elements in SampleListIndex.

   Dim Index As Long
   Dim Permutation As Collection
   
   If SelectionCount = UBound(SampleListIndex) Then
      ' Build new permutation and add to collection
      Set Permutation = New Collection
      For Index = 1 To SampleList.Count
         Permutation.Add SampleList(SampleListIndex(Index))
      Next
      Permutations.Add Permutation
   Else
      For Index = 1 To SampleList.Count
         ' Refer to current sample element
         SelectionCount = SelectionCount + 1
         SampleListIndex(SelectionCount) = Index
         ' Continue until last sample element used
         BuildPermutationsReturn SampleList, SampleListIndex, SampleListUsed, SelectionCount, Permutations
         SelectionCount = SelectionCount - 1
      Next
   End If

End Sub

Private Sub BuildSequences( _
   ByRef SampleList As Collection, _
   ByVal MinSelectionSize As Long, _
   ByVal MaxSelectionSize As Long, _
   ByRef Permutations As Collection)
   
' Builds all sequences of sample list.
' (0 1 2 3), Min=2, Max=4 => ((0 1) (0 1 2) (0 1 2 3) (1 2) (1 2 3) (2 3))
' MinSelectionSize must be greater than or equal to 1 and less than or equal to MaxSelctionSize.
' MaxSelectionSize must be greater than or equal to 1 and less than or equal to number of SampleList elements.
   
   Dim FirstIndex As Long
   Dim LastIndex As Long
   Dim Index As Long
   Dim Permutation As Collection
   
   For FirstIndex = 1 To SampleList.Count - MinSelectionSize + 1
      For LastIndex = FirstIndex + MinSelectionSize - 1 To Min(FirstIndex + MaxSelectionSize - 1, SampleList.Count)
         Set Permutation = New Collection
         For Index = FirstIndex To LastIndex
            Permutation.Add SampleList(Index)
         Next
         Permutations.Add Permutation
      Next
   Next

End Sub

Public Function Combinations( _
   ByRef SampleList As Collection, _
   ByVal MinSelectionSize As Long, _
   ByVal MaxSelectionSize As Long, _
   Optional ByVal SlotDelimiter As Variant) As Collection

' Builds and returns all combinations.

   Dim Results As New Collection
   Dim SelectionSize As Long
   Dim SampleListIndex() As Long
   Dim SelectionCount As Long
   
   For SelectionSize = MinSelectionSize To MaxSelectionSize
      ReDim SampleListIndex(1 To SelectionSize)
      SelectionCount = 0
      BuildCombinations SampleList, SelectionSize, SampleListIndex, SelectionCount, Results
   Next
   If Not IsMissing(SlotDelimiter) Then
      Set Combinations = AssembleResults(Results, CStr(SlotDelimiter))
   Else
      Set Combinations = Results
   End If

End Function

Public Function Permutations( _
   ByRef SampleList As Collection, _
   ByVal MinSelectionSize As Long, _
   ByVal MaxSelectionSize As Long, _
   ByVal SamplingMethod As SamplingMethod, _
   Optional ByVal SlotDelimiter As Variant) As Collection
   
' Builds and returns all permutations.

   Dim Combinations As New Collection
   Dim Combination As Collection
   Dim Results As New Collection
   Dim SelectionSize As Long
   Dim SampleListIndex() As Long
   Dim SampleListUsed() As Boolean
   Dim SelectionCount As Long
   
   For SelectionSize = MinSelectionSize To MaxSelectionSize
      ReDim SampleListIndex(1 To SelectionSize)
      ReDim SampleListUsed(1 To SelectionSize)
      Set Combinations = Nothing
      BuildCombinations SampleList, SelectionSize, SampleListIndex, SelectionCount, Combinations
      For Each Combination In Combinations
         If SamplingMethod = DiscardAfterChoosing Then
            BuildPermutationsNoReturn Combination, SampleListIndex, SampleListUsed, SelectionCount, Results
         Else
            BuildPermutationsReturn Combination, SampleListIndex, SampleListUsed, SelectionCount, Results
         End If
      Next
   Next
   If Not IsMissing(SlotDelimiter) Then
      Set Permutations = AssembleResults(Results, CStr(SlotDelimiter))
   Else
      Set Permutations = Results
   End If

End Function

Public Function Sequences( _
   ByRef SampleList As Collection, _
   ByVal MinSelectionSize As Long, _
   ByVal MaxSelectionSize As Long, _
   Optional ByVal SlotDelimiter As Variant) As Collection

' Builds and returns all sequences.

   Dim Results As New Collection
   
   BuildSequences SampleList, MinSelectionSize, MaxSelectionSize, Results
   If Not IsMissing(SlotDelimiter) Then
      Set Sequences = AssembleResults(Results, CStr(SlotDelimiter))
   Else
      Set Sequences = Results
   End If

End Function

Public Function Min( _
      ParamArray ValueArray() As Variant _
   ) As Variant

' Return the minimum value in the parameter list.

   Dim Value As Variant
   
   If UBound(ValueArray) = -1 Then Exit Function
   Min = ValueArray(0)
   For Each Value In ValueArray
      If Value < Min Then Min = Value
   Next

End Function

Kevin
Please ignore the above post. EE was having some difficulties with accepting posts and I posted to the wrong question.

Kevin
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pedro_arzac
pedro_arzac

ASKER


I`m using the standar installer of vb6, And what I need is to have some registry in windows of my program and the version of it.

I don`t know if I can do this with code.