GetPrivateProfileString - bug under Win2000 
Author Message
 GetPrivateProfileString - bug under Win2000

I found something strange with the API function GetPrivateProfileString().
It seems to return an extra character under Windows2000 (a block -
unsupported by WIndows character set). Any ideas?


Sun, 17 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
I ran into this problem on a class I created for reading ini files. Seems
that under win2k the api fills in all the buffer space you allocate with
every character, including tabs, line feeds as well as any line text you
have commented out behind a semicolon. I had to redevelop the class to
ignore everything after a semicolon as well as ignoring tab characters. I
wasn't too happy about it but it seems to work without any issues so far.

GL,
John R. Chaffier
====================================================
Weidenhammer System Corporation
1650 Valley Parkway
Suite 200
Bethlehem, PA 18017

Phone: (610) 317 - 4027
Fax: (610) 317 - 4001


Quote:
> I found something strange with the API function GetPrivateProfileString().
> It seems to return an extra character under Windows2000 (a block -
> unsupported by WIndows character set). Any ideas?



Sun, 17 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
Although this is not directly related to the characters returned (I have not
seen a particular problem in that respect) I have noticed that the
GetProfileStringA function is much much **slower** under win2k - so much so
that in some applications I am now looking to write my own version of the
function to improve performance (and that seems daft that some VB code to
manipulate a file would be faster than the native API function!!)

R


Quote:
> I found something strange with the API function GetPrivateProfileString().
> It seems to return an extra character under Windows2000 (a block -
> unsupported by WIndows character set). Any ideas?



Tue, 19 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
What about the unicode function ? (GetPrivateProfileStringW).  Just declare
the string params as long, then call it by passing the strings ByVal
strptr(myString)


Quote:
> Although this is not directly related to the characters returned (I have
not
> seen a particular problem in that respect) I have noticed that the
> GetProfileStringA function is much much **slower** under win2k - so much
so
> that in some applications I am now looking to write my own version of the
> function to improve performance (and that seems daft that some VB code to
> manipulate a file would be faster than the native API function!!)

> R



> > I found something strange with the API function

GetPrivateProfileString().
Quote:
> > It seems to return an extra character under Windows2000 (a block -
> > unsupported by WIndows character set). Any ideas?



Fri, 22 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
Thanks for the suggestion but this seemed just as slow (even if I didn't
quite master it -- the returned string was not exactly what I was expecting,
but it returned something and was no faster)...

R


Quote:
> What about the unicode function ? (GetPrivateProfileStringW).  Just
declare
> the string params as long, then call it by passing the strings ByVal
> strptr(myString)



Fri, 22 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
This is something I noticed between Windows 95/98 and NT4 as well.  I had a
program (in Delphi) that would read from an INI file for a lot of values, as
a quick and dirty "database".  On an NT4 machine it would take about half a
second to read values that the Win9x machine would read in no discernable
time.  The hardware was actually better on the NT4 machine too.  So
apparently MS doesn't want us to use INI files quickly under NT.
--
David Ellis
Black & Veatch Solutions Group


Quote:
> Although this is not directly related to the characters returned (I have
not
> seen a particular problem in that respect) I have noticed that the
> GetProfileStringA function is much much **slower** under win2k - so much
so
> that in some applications I am now looking to write my own version of the
> function to improve performance (and that seems daft that some VB code to
> manipulate a file would be faster than the native API function!!)

> R



> > I found something strange with the API function

GetPrivateProfileString().
Quote:
> > It seems to return an extra character under Windows2000 (a block -
> > unsupported by WIndows character set). Any ideas?



Fri, 22 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
Hi Robert,

that's strange.. I wouldn't have thought there would be any reason for it to
be slower on win2K, but I haven't tested it.
FWIW: the following should probably work to wrap the Wide version (NOT
tested !!)

Private Declare Function GetPrivateProfileStringW Lib "kernel32" _
      (ByVal lpSectionName As Long, ByVal lpKeyName As Long, _
      ByVal lpDefault As Long, ByVal lpReturnedString As Long, _
      ByVal nSize As Long, ByVal lpFileName As Long) As Long

Public Function IniGetString(ByVal lpSectionName As String, ByVal lpKeyName
As String, ByVal lpFileName As String, Optional strDefault As String = "")
As String
   Dim sBuff As String
   Dim nSize As Long, rtn As Long
   Do
      nSize = nSize + 256&
      sBuff = String$(nSize, 0)
      rtn = GetPrivateProfileStringW(StrPtr(lpSectionName),
StrPtr(lpKeyName), StrPtr(strDefault), StrPtr(sBuff), nSize,
StrPtr(lpFileName))
   Loop While rtn = nSize - 1
   IniGetString = Left$(sBuff, rtn)
End Function


Quote:
> Thanks for the suggestion but this seemed just as slow (even if I didn't
> quite master it -- the returned string was not exactly what I was
expecting,
> but it returned something and was no faster)...

> R



> > What about the unicode function ? (GetPrivateProfileStringW).  Just
> declare
> > the string params as long, then call it by passing the strings ByVal
> > strptr(myString)



Sat, 23 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
Thanks it was the Loop portion that I missed...  rgds - R

Quote:
> Hi Robert,

> that's strange.. I wouldn't have thought there would be any reason for it
to
> be slower on win2K, but I haven't tested it.
> FWIW: the following should probably work to wrap the Wide version (NOT
> tested !!)

> Private Declare Function GetPrivateProfileStringW Lib "kernel32" _
>       (ByVal lpSectionName As Long, ByVal lpKeyName As Long, _
>       ByVal lpDefault As Long, ByVal lpReturnedString As Long, _
>       ByVal nSize As Long, ByVal lpFileName As Long) As Long

> Public Function IniGetString(ByVal lpSectionName As String, ByVal
lpKeyName
> As String, ByVal lpFileName As String, Optional strDefault As String = "")
> As String
>    Dim sBuff As String
>    Dim nSize As Long, rtn As Long
>    Do
>       nSize = nSize + 256&
>       sBuff = String$(nSize, 0)
>       rtn = GetPrivateProfileStringW(StrPtr(lpSectionName),
> StrPtr(lpKeyName), StrPtr(strDefault), StrPtr(sBuff), nSize,
> StrPtr(lpFileName))
>    Loop While rtn = nSize - 1
>    IniGetString = Left$(sBuff, rtn)
> End Function



> > Thanks for the suggestion but this seemed just as slow (even if I didn't
> > quite master it -- the returned string was not exactly what I was
> expecting,
> > but it returned something and was no faster)...

> > R



> > > What about the unicode function ? (GetPrivateProfileStringW).  Just
> > declare
> > > the string params as long, then call it by passing the strings ByVal
> > > strptr(myString)



Tue, 26 Nov 2002 03:00:00 GMT  
 GetPrivateProfileString - bug under Win2000
-- I hadn't noticed the performance degrade under NT4 although I didn't have
the same machines to compare... so it is clearly a decelerating trend!!

R


Quote:
> This is something I noticed between Windows 95/98 and NT4 as well.  I had
a
> program (in Delphi) that would read from an INI file for a lot of values,
as
> a quick and dirty "database".  On an NT4 machine it would take about half
a
> second to read values that the Win9x machine would read in no discernable
> time.  The hardware was actually better on the NT4 machine too.  So
> apparently MS doesn't want us to use INI files quickly under NT.
> --
> David Ellis
> Black & Veatch Solutions Group



> > Although this is not directly related to the characters returned (I have
> not
> > seen a particular problem in that respect) I have noticed that the
> > GetProfileStringA function is much much **slower** under win2k - so much
> so
> > that in some applications I am now looking to write my own version of
the
> > function to improve performance (and that seems daft that some VB code
to
> > manipulate a file would be faster than the native API function!!)

> > R



> > > I found something strange with the API function
> GetPrivateProfileString().
> > > It seems to return an extra character under Windows2000 (a block -
> > > unsupported by WIndows character set). Any ideas?



Tue, 26 Nov 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. GetPrivateProfileString bug in VB5?

2. GetPrivateProfileString- bug in Win32api.txt

3. Bug in GetPrivateProfileString()???

4. Win2000 File Share Mapping bug

5. OutputDebugString Bug in Win2000

6. ComboBox bug in Win2000??

7. Win2000 File Share Mapping bug

8. IDE BUGs, BUGs, BUGs....

9. BUGS BUGS BUGS!

10. Project98 OLE & VB: bugs, bugs, bugs

11. GetPrivateProfileString fon Win98 HELP!!

12. GetPrivateProfileString HELP !!!

 

 
Powered by phpBB® Forum Software