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

Вниз

Как читать строки из реестра   Найти похожие ветки 

 
i-s-v   (2003-08-11 01:51) [0]

Здравствуйте, мастера!
Помогите, Пожалуйста!
Может, этот вопрос уже задавался - нету времени искать.
Как считать строку из реестра с помощью апи?
Вернее, что нужно записать под DataSize: RegQueryValueEx(Key, ..., @PByte(Data), А_что_тута___);
Пробовал "выкачать" из модуля Registry - не получается


 
Игорь Шевченко   (2003-08-11 10:23) [1]

Адрес переменной типа DWORD


 
i-s-v   (2003-08-12 10:58) [2]

А что этой переменной присваивать?
Чтоб читать целую переменную - SizeOf(Integer).
А что писать для строки?


 
Игорь Шевченко   (2003-08-12 11:24) [3]

открываем F1 и внимательно читаем:

Points to a variable specifying the size, in bytes, of the buffer pointed to by the lpValue parameter. When the function returns, this variable contains the size of the data copied to lpValue, including the terminating null character.

If the buffer specified by lpValue parameter is not large enough to hold the data, the function returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcbValue.
If lpValue is NULL, the function returns ERROR_SUCCESS, and stores the size of the string, in bytes, into the variable pointed to by lpcbValue. This lets an application determine the best way to allocate a buffer for the value key"s data.

In all cases the value returned in lpcbValue always includes the size of the terminating null character in the string.

Отсюда делаем вывод, что для чтения строки можно
а) зарезервировать заведомо большой буфер и передать в этой переменной его размер.
б) передать NULL в качестве lpValue, и 0 в переменную, тогда в эту переменную будет занесена длина значения. Выделяем память под lpValue, вызываем второй раз RegQueryValue и опаньки - все хорошо и значение прочитано.
Но гораздо лучше бы было, если бы ты F1 сам читал.



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

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

Наверх




Память: 0.45 MB
Время: 0.186 c
1-51340
Fast
2003-10-05 22:30
2003.10.16
Получить список всех кнопок на форме


1-51177
Eugene_
2003-10-05 11:00
2003.10.16
Опрос клавиатуры


1-51203
dnsokol
2003-09-25 10:10
2003.10.16
MDI окошко в DLL ке


3-51111
Диня
2003-09-25 09:51
2003.10.16
Перестроение индексов IB


1-51297
Seldon
2003-10-05 22:00
2003.10.16
TPropertyEditor





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский