Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #9500 > unrolled thread

Problem with GetPrivateProfileString()

Started byJürgen Knauf <trotterklaus@googlemail.com>
First post2016-07-04 23:10 -0700
Last post2016-07-08 04:18 -0700
Articles 6 — 4 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Problem with GetPrivateProfileString() Jürgen Knauf <trotterklaus@googlemail.com> - 2016-07-04 23:10 -0700
    Re: Problem with GetPrivateProfileString() "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2016-07-05 09:41 +0200
    Re: Problem with GetPrivateProfileString() "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-07-05 11:24 +0200
    Re: Problem with GetPrivateProfileString() Jürgen Knauf <trotterklaus@googlemail.com> - 2016-07-06 00:55 -0700
    Re: Problem with GetPrivateProfileString() "Jean Raymond" <jean_ray67@hotmail.com> - 2016-07-07 08:10 -0400
      Re: Problem with GetPrivateProfileString() Jürgen Knauf <trotterklaus@googlemail.com> - 2016-07-08 04:18 -0700

#9500 — Problem with GetPrivateProfileString()

FromJürgen Knauf <trotterklaus@googlemail.com>
Date2016-07-04 23:10 -0700
SubjectProblem with GetPrivateProfileString()
Message-ID<0a08cc3b-7ab7-4a57-b9f2-ca872dc1f93d@googlegroups.com>
GetPrivateProfileString() is not workiung correctly.
 

When I try to read an empty value from an INI-File, I do not get the alternate value back. 

pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
pszBuffer := Space(127)    

GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFile)

? pszBuffer
In this case it must be "ABCDE", but I get an empty value.

Windows 10 64-Bit, Vo 2.8 

Jürgen

[toc] | [next] | [standalone]


#9501

From"Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it>
Date2016-07-05 09:41 +0200
Message-ID<nlfobc$qcf$1@dont-email.me>
In reply to#9500
Hello Jürgen,

Until now I have not seen any problems with Windows 10 64 and VO 2.8.

Perhaps it is better to use Memalloc and copy the psz to a normal string 
before verifying as in the example below.

Does another process writes into the ini file at the same time? I have seen 
that this can create problems even if other entries of the file are changed.

Arne Ortlinghaus
ACS Data Systems


METHOD GetString (cSection, cEntry, cDefault, cFirmaID) CLASS IniFile
//p Liefert den Wert einer Variablen als String
//a cSection - String: Section
//a cEntry - String: Entry
//a cDefault - String für Defaultwert oder nil
//a cFirmaID - Falls angegeben: Lesen von einer ine speziellen Firma (falls 
Firmenverwaltung)
 LOCAL ptrBuffer as psz
 LOCAL cBuffer as STRING
 Default(@cDefault, "")
 ptrBuffer := MemAlloc (2049)
 GetPrivateProfileString (String2Psz(_cSubSection+cSection), 
String2Psz(cEntry), String2Psz(cDefault), ptrBuffer, ;
                2048, String2Psz(self:fullPath))
 cBuffer := Psz2String (ptrBuffer)
   MemFree (ptrBuffer)


 RETURN cBuffer


"Jürgen Knauf" <trotterklaus@googlemail.com> schrieb im Newsbeitrag 
news:0a08cc3b-7ab7-4a57-b9f2-ca872dc1f93d@googlegroups.com...
GetPrivateProfileString() is not workiung correctly.


When I try to read an empty value from an INI-File, I do not get the 
alternate value back.

pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
pszBuffer := Space(127)

GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFile)

? pszBuffer
In this case it must be "ABCDE", but I get an empty value.

Windows 10 64-Bit, Vo 2.8

Jürgen 

[toc] | [prev] | [next] | [standalone]


#9502

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2016-07-05 11:24 +0200
Message-ID<du1clmFe89oU1@mid.individual.net>
In reply to#9500
Hi Jürgen,

please pay attention that the program files directory and the windows
directory have special handlings when a process tries to write there.

To be compatible with Windows 7/8/10 you should NEVER write anything
there.

If your program or another program tries this, the following can occur:

1) if the writing program is manifested for Windows 7/8/10, and the
process has not elevated rights, the write will fail.

2) if the writing program is not manifested for newer Windows versions,
the ini or whatever file is written to the virtual store hierarchy of
the current user, so the configuration data is not shared between
different users, and could also not be shared between different
applications.

I don't know if GetPrivateProfileString() is not trying to write and
fails therefore - it is a Windows API function, not a VO function.

My strong recommendation is to never install programs that are using
configuration data or, even worser, application data (like nearly all
my VO programs do) into the Program Files structure - better to install
them in a separate directory.
Programs installed into the Program Files structure should put their
configuration and data in the (hidden) ProgramData structure.

Wolfgang


Jürgen Knauf wrote:

> GetPrivateProfileString() is not workiung correctly.
>  
> 
> When I try to read an empty value from an INI-File, I do not get the
> alternate value back.
> 
> pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
> pszBuffer := Space(127)    
> 
> GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFi
> le)
> 
> ? pszBuffer
> In this case it must be "ABCDE", but I get an empty value.
> 
> Windows 10 64-Bit, Vo 2.8 
> 
> Jürgen



-- 

[toc] | [prev] | [next] | [standalone]


#9511

FromJürgen Knauf <trotterklaus@googlemail.com>
Date2016-07-06 00:55 -0700
Message-ID<c090116d-d01a-4715-a0ac-7a27ab67c67e@googlegroups.com>
In reply to#9500
Am Dienstag, 5. Juli 2016 08:10:40 UTC+2 schrieb Jürgen Knauf:
> GetPrivateProfileString() is not workiung correctly.
>  
> 
> When I try to read an empty value from an INI-File, I do not get the alternate value back. 
> 
> pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
> pszBuffer := Space(127)    
> 
> GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFile)
> 
> ? pszBuffer
> In this case it must be "ABCDE", but I get an empty value.
> 
> Windows 10 64-Bit, Vo 2.8 
> 
> Jürgen

Thank you for your answers.
GetPrivateProfileString() is only reading data.
And is runs since years without any changes.

I think the silent updates of windows 10 are a  big problem for programmers. Because the sentence “Never change a running system” is no longer valid!

Jürgen

[toc] | [prev] | [next] | [standalone]


#9517

From"Jean Raymond" <jean_ray67@hotmail.com>
Date2016-07-07 08:10 -0400
Message-ID<nllgrc$k36$1@dont-email.me>
In reply to#9500
REf: 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724353(v=vs.85).aspx

lpDefault [in]
A default string. If the lpKeyName key cannot be found in the initialization 
file, GetPrivateProfileString copies the default string to the 
lpReturnedString buffer. If this parameter is NULL, the default is an empty 
string, "".

As far as I know, only if the key [LOCALAPP] is not found, then it will 
return [ABCDE] default value.
If the key is found, then it will return a NULL_STRING, and this is correct.

No where here they say that if the value is empty, then it will return the 
[ABCDE] default value.

My humble opinion...

Jean Raymond
http://www.rayonline.com




/-----------------------------------------------------------------------------------------------------------------------------------

"Jürgen Knauf"  wrote in message 
news:0a08cc3b-7ab7-4a57-b9f2-ca872dc1f93d@googlegroups.com...

GetPrivateProfileString() is not workiung correctly.


When I try to read an empty value from an INI-File, I do not get the 
alternate value back.

pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
pszBuffer := Space(127)

GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFile)

? pszBuffer
In this case it must be "ABCDE", but I get an empty value.

Windows 10 64-Bit, Vo 2.8

Jürgen 

[toc] | [prev] | [next] | [standalone]


#9520

FromJürgen Knauf <trotterklaus@googlemail.com>
Date2016-07-08 04:18 -0700
Message-ID<607fa318-6118-4174-94c4-c99562dd68b1@googlegroups.com>
In reply to#9517
Am Donnerstag, 7. Juli 2016 14:10:21 UTC+2 schrieb Jean Raymond:
> REf: 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms724353(v=vs.85).aspx
> 
> lpDefault [in]
> A default string. If the lpKeyName key cannot be found in the initialization 
> file, GetPrivateProfileString copies the default string to the 
> lpReturnedString buffer. If this parameter is NULL, the default is an empty 
> string, "".
> 
> As far as I know, only if the key [LOCALAPP] is not found, then it will 
> return [ABCDE] default value.
> If the key is found, then it will return a NULL_STRING, and this is correct.
> 
> No where here they say that if the value is empty, then it will return the 
> [ABCDE] default value.
> 
> My humble opinion...
> 
> Jean Raymond
> http://www.rayonline.com
> 
> 
> 
> 
> /-----------------------------------------------------------------------------------------------------------------------------------
> 
> "Jürgen Knauf"  wrote in message 
> news:0a08cc3b-7ab7-4a57-b9f2-ca872dc1f93d@googlegroups.com...
> 
> GetPrivateProfileString() is not workiung correctly.
> 
> 
> When I try to read an empty value from an INI-File, I do not get the 
> alternate value back.
> 
> pszFile   := "C:\Program Files (x86)\texManager 8\tm.ini"
> pszBuffer := Space(127)
> 
> GetPrivateProfileString("PFADE","LOCALAPP","ABCDE",pszBuffer,127,pszFile)
> 
> ? pszBuffer
> In this case it must be "ABCDE", but I get an empty value.
> 
> Windows 10 64-Bit, Vo 2.8
> 
> Jürgen

Hi Jean,
you are the best. Thank you.

This was the solution!!

Jürgen

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web