Is this possible, or am I pushing it? 
Author Message
 Is this possible, or am I pushing it?

Hello,

I am using VB5 Enterprise to construct an FTP client. I want to be
able to save session profiles to the registry, which is no problem. I
have it saving the profiles to the registry in the following manner:

HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles

and in there, each individual profile has it's own subkey, for
instance:

HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles
                                                MyProfile1
                                                MyProfile2
                                                MyProfile3

Now, the thing that I want to do with this is have EACH individual
profile subkey load into a combo box, and when I select the subkey
name from the combo box, have all of the settings load into various
text boxes on my form.

As I said, SAVING the profiles to the registry is not a problem. But
loading the subkeys from the registry in to the combo box has me
spending MANY speepless nights trying to figure it out. If anyone can
help me on this, THANKS A MILLION!!       =)

Some Dude


All good comments and others to: sin 666 at iname dot com

"Beer: Nectar of the Gods."
        - Unknown



Sun, 14 Jan 2001 03:00:00 GMT  
 Is this possible, or am I pushing it?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

How did you do the naming of the subkeys? If you had your system
naming them (1,2,3,..... would be a nice idea), you can easily loop
though them until you encounter your default value.

Andre'

Quote:

>Hello,

>I am using VB5 Enterprise to construct an FTP client. I want to be
>able to save session profiles to the registry, which is no problem. I
>have it saving the profiles to the registry in the following manner:

>HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles

>and in there, each individual profile has it's own subkey, for
>instance:

>HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles
> MyProfile1
> MyProfile2
> MyProfile3

>Now, the thing that I want to do with this is have EACH individual
>profile subkey load into a combo box, and when I select the subkey
>name from the combo box, have all of the settings load into various
>text boxes on my form.

>As I said, SAVING the profiles to the registry is not a problem. But
>loading the subkeys from the registry in to the combo box has me
>spending MANY speepless nights trying to figure it out. If anyone can
>help me on this, THANKS A MILLION!!       =)

>Some Dude


>All good comments and others to: sin 666 at iname dot com

>"Beer: Nectar of the Gods."
> - Unknown

-----BEGIN PGP SIGNATURE-----
Version: PGP 5.5.5

iQA/AwUBNb9j9kiQ6hC5HiceEQKkkgCg6BWvQA1ThYHz/kj84UWyOXkT8TEAn3NG
F71fVH0PeEWTgj0duF2y7gU/
=wAgn
-----END PGP SIGNATURE-----



Sun, 14 Jan 2001 03:00:00 GMT  
 Is this possible, or am I pushing it?

Quote:
> As I said, SAVING the profiles to the registry is not a problem. But
> loading the subkeys from the registry in to the combo box has me
> spending MANY speepless nights trying to figure it out. If anyone can
> help me on this, THANKS A MILLION!!       =)

What you need to do is use the Win32 API to recurse through all of the profies
in the registry and load them into either an array or directly into the combo
box.

Daniel Appleman's book "Visual Basic Programmers Guide to the Win32 API"
should give you the API information you need to do this.

--Dave



Sun, 14 Jan 2001 03:00:00 GMT  
 Is this possible, or am I pushing it?
I'm not sure what your problem is.  Use RegEnumKeyEx to enumerate the subkeys
(sample below) and the additem method to add them to the combo box.

Quote:

>and in there, each individual profile has it's own subkey, for
>instance:

>HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles
>                                            MyProfile1
>                                            MyProfile2
>                                            MyProfile3

>Now, the thing that I want to do with this is have EACH individual
>profile subkey load into a combo box, and when I select the subkey
>name from the combo box, have all of the settings load into various
>text boxes on my form.

Function GetKeyList(Key As String, NKeys As Integer, KeyList() As String) As
Boolean
   'Find all the subkeys under a key, set them in KeyList array (0 to n)
   'Exclude any in exclude list.
   'Returns true if ok
   Dim hKey As Long        'Holds key handle from RegOpenKey.
   Dim I As Long, lResult As Long, DT As FILETIME
   Dim KName As String, lpClass As String, szKName As Long, szClass As Long

   lResult = RegOpenKeyEx(HKEY_CURRENT_USER, Key, 0, KEY_ENUMERATE_SUB_KEYS,
hKey)
   If lResult = ERROR_SUCCESS Then
      KName = Space(255): szKName = 255: lpClass = Space(255): szClass = 255
      I = 0
      Do While RegEnumKeyEx(hKey, I, KName, szKName, 0&, lpClass, szClass, DT) =
ERROR_SUCCESS
         CheckDate DT
         KName = Left$(KName, szKName)
         KeyList(I) = KName
         KName = Space(255): szKName = 255: lpClass = Space(255): szClass = 255
         I = I + 1
      Loop
      lResult = RegCloseKey(hKey)
      NKeys = I
      GetKeyList = True
   Else
      LogInfo "Error opening key: " & Key & " code= " & Str$(lResult)
   End If
End Function

+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---

Center for Academic Computing, THE Pennsylvania State University



Sun, 14 Jan 2001 03:00:00 GMT  
 Is this possible, or am I pushing it?
Try my DMReg Registry Tool on
http://www.wave.co.nz/pages/datamasta/download.htm. It supports Key
Enumeration which is what you need.

--
Jeff Law
DataMasta Limited
New Zealand
http://www.wave.co.nz/pages/datamasta

begin 666 Jeff Law.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DQA=SM*969F#0I&3CI*969F
M($QA=PT*3U)'.D1A=&%-87-T82!,:6UI=&5D#0I.3U1%.B -"E1%3#M73U)+


`
end



Mon, 15 Jan 2001 03:00:00 GMT  
 Is this possible, or am I pushing it?

Quote:
> Hello,
> I am using VB5 Enterprise to construct an FTP client. I want to be
> able to save session profiles to the registry, which is no problem. I
> have it saving the profiles to the registry in the following manner:
> HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles
> and in there, each individual profile has it's own subkey, for
> instance:
> HKEY_CURRENT_USER\MyPrograms\MyFTP\Profiles
>                                            MyProfile1
>                                            MyProfile2
>                                            MyProfile3
> Now, the thing that I want to do with this is have EACH individual
> profile subkey load into a combo box, and when I select the subkey
> name from the combo box, have all of the settings load into various
> text boxes on my form.
> As I said, SAVING the profiles to the registry is not a problem. But
> loading the subkeys from the registry in to the combo box has me
> spending MANY speepless nights trying to figure it out. If anyone can
> help me on this, THANKS A MILLION!!       =)

The function you're looking for is RegEnumKeyEx().  It's declared as

Declare Function RegEnumKeyEx& Lib "advapi32.dll" Alias "RegEnumKeyExA" _
    (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _
    lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As _
    String, lpcbClass As Long, lpftLastWriteTime As FILETIME)

The other declarations you'll need are the FILETIME type, ERROR_NONE,
HKEY_CURRENT_USER and KEY_ALL_ACCESS, plus the RegOpenKeyEx and
RegCloseKey functions; you can get these through the API viewer.

The code you need to use is this:

Public Function EnumSubKey(ByVal lIndex as Long) as String

    Dim y               as Long
    Dim hKey            as Long
    Dim sKeyBuffer      as String
    Dim sSubKey         as String
    Dim lKeyBufferLen   as Long
    Dim foo             as Long
    Dim FT              as FILETIME

    sKeyBuffer = String$(256, vbNullChar) 'allocate a buffer for the
        'response
    lKeyBufferLen = Len(sKeyBuffer)

    foo = Len(vbNullString)

'   open the key
    y = RegOpenKeyEx(HKEY_CURRENT_USER, "MyPrograms\MyFTP\Profiles", _
        0&, KEY_ALL_ACCESS, hKey)

    If y = ERROR_NONE Then

    'here's the meat.  hKey is the handle to the Profiles key.  lIndex
    'is the zero-based index of the subkey.  sKeyBuffer is the buffer
    'you've allocated; lKeyBufferLen is its length.  You don't need to
    'worry about the other parameters.

        y = RegEnumKeyEx(hKey, lIndex, sKeyBuffer, lKeyBufferLen, _
            0&, vbNullString, foo, FT)
        If y = ERROR_NONE Then

        'sKeyBuffer is a null-terminated string containing the subkey's
        'name.  lKeyBufferLen is set to the length of the key name incl.
        'the null character.

            sSubKey = Left$(sKeyBuffer, lKeyBufferLen - 1)
        Else
            sSubKey = ""
        End If
        RegCloseKey hKey
    End If

    EnumSubKey = sSubKey

End Function

Then add the following to the code you're using to populate the combo
box:

Dim sSubKey     as String
Dim lKeyIndex   as Long

lKeyIndex = 0

Do
    sSubKey = EnumSubKey(lKeyIndex)
    If sSubKey <> "" Then Combo1.AddItem sSubKey
    lKeyIndex = lKeyIndex + 1
Loop Until sSubKey = ""

--



Mon, 15 Jan 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Is this possible, or am I pushing it?

2. Is this possible, or am I pushing it?

3. I am trying to update a record, i am not using data control

4. I am learning VB.NET and am wondering....

5. I am trying to update a record, i am not using data control

6. is this possible or am I dreaming

7. When is 5:00 AM not 5:00 AM? When it's 5:00 AM.

8. Am I missing something or am I just plain dumb?

9. Am I missing something???? Or Am I just Dumb????

10. Am I an .EXE, or am I running under VB env?

11. I am stopping(error 70) when I am distributing a client program using DCOM server.

12. I am trying to create a database application. I am using a data control

 

 
Powered by phpBB® Forum Software