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

Вниз

Ошибка в методе Inifile.ReadSections ?   Найти похожие ветки 

 
VID   (2002-05-20 19:33) [0]

Как известно этот метод помещает имена всех секций в Ini-файле ,в список TStrings.
Так вот у меня есть INI-файл, где 394 секции, итак:

begin
IniFile1.ReadSections(TargetList);
ShowMessage(Inttostr(targetList.Count));
end;

появляется сообщение 269 . Что это значит ? Метод не может оперировать с количеством секций, более 269 ?


 
limon   (2002-05-20 20:55) [1]

Под рукой сейчас нет, но
Посмотри как описано поведение GetPrivateProfileString
возможно при запросе списка секций просто не хватает памяти под буфер


 
limon   (2002-05-20 20:56) [2]

Sorry, GetPrivateProfileSection


 
VID   (2002-05-21 12:12) [3]

TO limon: строка GetPrivateProfileSection есть только в файле Windows.pas
Конкретного описания кода функции нету, функция импортируется из kernell.dll...


 
Виктор Щербаков   (2002-05-21 12:49) [4]

Объявление есть в windows.pas
function GetPrivateProfileSection(lpAppName: PChar; lpReturnedString: PChar; nSize: DWORD; lpFileName: PChar): DWORD; stdcall;
Описание параметров смотри в SDK.


 
VID   (2002-05-21 16:07) [5]

Вот это код метода ReadSections объекта TINIFILE:

procedure TIniFile.ReadSections(Strings: TStrings);
const
BufSize = 16384;
var
Buffer, P: PChar;
begin
GetMem(Buffer, BufSize);
try
Strings.BeginUpdate;
try
Strings.Clear;
if GetPrivateProfileString(nil, nil, nil, Buffer, BufSize,
PChar(FFileName)) <> 0 then
begin
P := Buffer;
while P^ <> #0 do
begin
Strings.Add(P);
Inc(P, StrLen(P) + 1);
end;
end;
finally
Strings.EndUpdate;
end;
finally
FreeMem(Buffer, BufSize);
end;
end;
Здесь нет вызова функции GetPrivateProfileSection. Может эта функция вызывается из GetPrivateProfileString ?

Я менял значение константы BufSize = 16384 на BufSize = 16384*10 НИКАКОЙ РАЗНИЦЫ.
ОС: WIN 2000


 
VID   (2002-05-21 21:55) [6]

ИДЕИ ? или нифига ?


 
Serhy   (2002-05-22 02:19) [7]

Очень смахивает на обсуждавшееся недавно ограничение на INI файл в 64К.


 
limon   (2002-05-22 10:41) [8]

Ну все правильно. Здесь ограничение буфера - 16к (BufSize).
Если меняешь в inifiles.pas - этого мало, надо его dcu заменить.
Ф-я GetPrivateProfileString при нулевом 1-м параметре возвращает список секций. При нулевом 2-м, когда 1-й имя секции - список ключей в секции.
Т.к. под рукой никаких док не было - не сосвсем правильно название написал.

Есть еще ф-я GetPrivateProfileSectionNames
The GetPrivateProfileSectionNames function retrieves the names of all sections in an initialization file.

Note This function is provided only for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.

DWORD GetPrivateProfileSectionNames(
LPTSTR lpszReturnBuffer, // return buffer
DWORD nSize, // size of return buffer
LPCTSTR lpFileName // initialization file name
);
Parameters
lpszReturnBuffer
[out] Pointer to a buffer that receives the section names associated with the named file. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character.
nSize
[in] Specifies the size, in TCHARs, of the buffer pointed to by the lpszReturnBuffer parameter.
lpFileName
[in] Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter is NULL, the function searches the Win.ini file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.
Return Values
The return value specifies the number of characters copied to the specified buffer, not including the terminating null character. If the buffer is not large enough to contain all the section names associated with the specified initialization file, the return value is equal to the length specified by nSize minus two.


 
VID   (2002-05-22 13:48) [9]

TO LIMON: Спасибо. Как я понял, лучше использовать функцию GetPrivateProfileSectionNames с непосредственным указанием размера буфера, нежели IniFile.ReadSections.



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

Форум: "Потрепаться";
Текущий архив: 2002.06.24;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.009 c
7-77628
Fredericco
2002-03-13 21:17
2002.06.24
Этот вопрос уже задавался, но все же... Как мне работать с СОМ портом без ассемблера?


1-77381
dimich
2002-06-11 11:27
2002.06.24
Вопрос про shellexecute


3-77306
niko4543
2002-05-31 10:10
2002.06.24
Таблица


14-77569
MisterBin
2002-05-17 20:27
2002.06.24
Вообще про прозрачность.


6-77525
star
2002-01-23 13:25
2002.06.24
Всем, кто спрашивал про работу с NetSessionEnum и NetFileEnum.





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