Форум: "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