Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2004.06.06;
Скачать: [xml.tar.bz2];

Вниз

Поиск в реестре в windows   Найти похожие ветки 

 
Maximys ©   (2004-04-27 18:47) [0]

Подскажите пожалуйста, как можно загрузить список всех ключей реестра (Например HKEY_LOCAL_MACHINE) в компонент типа listbox?Заранее благодарен.


 
Dummy   (2004-04-27 19:09) [1]

RegEnumKeyEx
The RegEnumKeyEx function enumerates subkeys of the specified open registry key. The function retrieves information about one subkey each time it is called.

LONG RegEnumKeyEx(
 HKEY hKey,                  // handle to key to enumerate
 DWORD dwIndex,              // subkey index
 LPTSTR lpName,              // subkey name
 LPDWORD lpcName,            // size of subkey buffer
 LPDWORD lpReserved,         // reserved
 LPTSTR lpClass,             // class string buffer
 LPDWORD lpcClass,           // size of class string buffer
 PFILETIME lpftLastWriteTime // last write time
);
Parameters
hKey
[in] Handle to a currently open key or one of the following predefined keys:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Windows NT/2000/XP: HKEY_PERFORMANCE_DATA
Windows 95/98/Me: HKEY_DYN_DATA

The enumerated keys are subkeys of the key identified by hKey.

dwIndex
[in] Specifies the index of the subkey to retrieve. This parameter should be zero for the first call to the RegEnumKeyEx function and then incremented for subsequent calls.
Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.

lpName
[out] Pointer to a buffer that receives the name of the subkey, including the terminating null character. The function copies only the name of the subkey, not the full key hierarchy, to the buffer.
lpcName
[in/out] Pointer to a variable that specifies the size, in TCHARs, of the buffer specified by the lpName parameter. This size should include the terminating null character. When the function returns, the variable pointed to by lpcName contains the number of characters stored in the buffer. The count returned does not include the terminating null character.
lpReserved
Reserved; must be NULL.
lpClass
[in/out] Pointer to a buffer that receives the null-terminated class string of the enumerated subkey. No classes are currently defined; applications should ignore this parameter. This parameter can be NULL.
lpcClass
[in/out] Pointer to a variable that specifies the size, in TCHARs, of the buffer specified by the lpClass parameter. The size should include the terminating null character. When the function returns, lpcClass contains the number of characters stored in the buffer. The count returned does not include the terminating null character. This parameter can be NULL only if lpClass is NULL.
lpftLastWriteTime
[out] Pointer to a variable that receives the time the enumerated subkey was last written to.
Return Values
If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

Windows NT/2000/XP: If a key has been successfully retrieved and there are more keys to be retrieved, the function returns ERROR_MORE_DATA.

Remarks
To enumerate subkeys, an application should initially call the RegEnumKeyEx function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call RegEnumKeyEx until there are no more subkeys (until the function returns ERROR_NO_MORE_ITEMS).

The application can also set dwIndex to the index of the last subkey on the first call to the function and decrement the index until the subkey with the index 0 is enumerated. To retrieve the index of the last subkey, use the RegQueryInfoKey function.

While an application is using the RegEnumKeyEx function, it should not make calls to any registration functions that might change the key being enumerated.

The key identified by hKey must have been opened with KEY_ENUMERATE_SUB_KEYS access (KEY_READ includes KEY_ENUMERATE_SUB_KEYS). Use the RegCreateKeyEx or RegOpenKeyEx function to open the key.

Windows 95/98/Me: No registry subkey or value name may exceed 255 characters.

Windows 95/98/Me: RegEnumKeyExW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

Example Code
For an example, see Using the Registry.

Requirements
 Windows NT/2000/XP: Included in Windows NT 3.1 and later.
 Windows 95/98/Me: Included in Windows 95 and later.
 Header: Declared in Winreg.h; include Windows.h.
 Library: Use Advapi32.lib.
 Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.


 
Cobalt ©   (2004-04-27 22:01) [2]

TRegistry проще, особливо в компонент.


 
Игорь Шевченко ©   (2004-04-28 00:27) [3]

unit main;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, ComCtrls, Registry;

type
 TfMain = class(TForm)
   TreeView: TTreeView;
   procedure FormCreate(Sender: TObject);
   procedure FormDestroy(Sender: TObject);
 private
   FRegistry: TRegistry;
   procedure AddKey (RootNode: TTreeNode; AKeys: TStrings;
     ARegistry: TRegistry; const RootKey: string);
 end;

var
 fMain: TfMain;

implementation

{$R *.dfm}

procedure TfMain.AddKey(RootNode: TTreeNode; AKeys: TStrings;
 ARegistry: TRegistry; const RootKey: string);
var
 I: Integer;
 KeyNode: TTreeNode;
 SubKeys: TStrings;
 KeyName: string;
begin
 for I:=0 to Pred(AKeys.Count) do begin
   KeyNode := TreeView.Items.AddChild(RootNode, AKeys[I]);
   SubKeys := TStringList.Create;
   if Length(RootKey) = 0 then
     KeyName := AKeys[I]
   else
     KeyName := RootKey + "\"+ AKeys[I];
   try
     ARegistry.OpenKeyReadOnly(KeyName);
     try
       ARegistry.GetKeyNames(SubKeys);
     finally
       ARegistry.CloseKey;
     end;
     AddKey(KeyNode, SubKeys, ARegistry, KeyName);
   finally
     SubKeys.Free;
   end;
 end;
end;

procedure TfMain.FormCreate(Sender: TObject);
var
 SubKeys: TStrings;
begin
 TreeView.Items.BeginUpdate;
 try
   FRegistry := TRegistry.Create (KEY_READ);
   with FRegistry do begin
     RootKey := HKEY_LOCAL_MACHINE;
     OpenKeyReadOnly("");
     SubKeys := TStringList.Create;
     try
       GetKeyNames (SubKeys);
       AddKey (nil, SubKeys, FRegistry, "");
     finally
       SubKeys.Free;
     end;
     CloseKey;
   end;
 finally
   TreeView.Items.EndUpdate;
 end;
end;

procedure TfMain.FormDestroy(Sender: TObject);
begin
 FRegistry.Free;
end;

end.


Но работать будет до скончания века :)))



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2004.06.06;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.47 MB
Время: 0.048 c
3-1084863828
AndrewK
2004-05-18 11:03
2004.06.06
Данные хранимой процедуры обрезаются в DBGrid


1-1085074474
K@rt
2004-05-20 21:34
2004.06.06
Information for


4-1082818484
gRad
2004-04-24 18:54
2004.06.06
Параметры ф-ий из dll


14-1084452019
Dmitriy O.
2004-05-13 16:40
2004.06.06
А вот зацените анимацию на основе БД.


14-1085050729
Том
2004-05-20 14:58
2004.06.06
Как решить задачу !





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский