Author |
Topic: INI returns (Read 445 times) |
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
INI returns
« Thread started on: Nov 28th, 2015, 12:25pm » |
|
I believe these two statements are in conflict and the first one does not work as written. What I get from Entry$="" ' empty is the Default$.
Replacing the "" with _NULL fixes the problem.
PS. I think this is what I meant elsewhere as "{halfhearted}" effort in case anyone is counting.
From LBPE http://lbpe.wikispaces.com/IniFiles
{my emphasis}
Quote:READING AN INI FILE BY API GetPrivateProfileStringA ... Entry$ Points to the null-terminated string that is associated with the value string. If this parameter is empty, the return string will contain a list of all values in the specified section, separated by null characters, and terminated with double null characters.
Default$ Points to a null-terminated string that specifies the default value for the given entry if the entry cannot be found in the initialization file. This parameter must never be NULL or empty. You might want to specify a value that makes it clear that this section of the ini file was blank. |
|
Code:
INIfile$ = DefaultDir$ + "\JunkINIstruct.ini"
calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
"Forward" as ptr, "1234567890" as ptr, INIfile$ as ptr, ret as long
calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
"Backward" as ptr, "0987654321" as ptr, INIfile$ as ptr, ret as long
calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
"ABCword" as ptr, "ABCDEFGHIJ" as ptr, INIfile$ as ptr, ret as long
default$ = "NO DATA SPECIFIED"
sizestring = 100
string$ = Space$(sizestring)
calldll #kernel32, "GetPrivateProfileStringA", "Register" as ptr, _
"" as ptr,_
default$ As ptr, _
string$ As ptr, _
sizestring As long, _
INIfile$ as ptr, ret as long
' _NULL as ptr,_
' "Forward" as ptr,_
print "Raw Returned Entry Value: "; string$+"<-"
print "GetINI: "; ret
print "Returned Entry Value: "; Left$(string$,ret)+"<-"
end
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: INI returns
« Reply #1 on: Nov 28th, 2015, 1:27pm » |
|
on Nov 28th, 2015, 12:25pm, pnlawrence wrote:I believe these two statements are in conflict and the first one does not work as written. |
|
I don't think they are "in conflict" but I agree that the term 'empty' is imprecise and ought to be better defined. Evidently what was meant is NULL (the numeric value zero) rather than "" (a zero-length string) but that's only evident by cross-referencing with the relevant MSDN page.
The potential for confusion is made even worse by a 'zero-length string' (or 'empty string') sometimes being referred to as a 'NULL string' - thus using the term NULL in two quite different senses.
Personally when needing a Windows API reference I would always prefer to go directly to the 'horse's mouth', i.e. MSDN, rather than reading somebody's (possibly incorrect or inaccurate) interpretation at LBPE.
Richard.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: INI returns
« Reply #2 on: Nov 28th, 2015, 1:38pm » |
|
Again, at risk of being labeled, I brought up the same subject.
If one is aware of part of the page, then one should be able to figure out the rest of the page. Right?
As this INI stuff moves along, I've wondered why it took so long. Not that I want an answer.
I've just been working on parts of my project, and different points came up. This way to list all of the entries in an INI file is part of a combo box.
|
|
Logged
|
|
|
|
|