Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetPrivateProfileString() problem
Message
 
À
15/04/1999 09:34:23
Pascal Binette
Pratt & Whitney Canada
Saint-Hubert, Québec, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00208540
Message ID:
00208557
Vues:
28
>I tried to use the GetPrivateProfileString(), but could not make it work. However, I got the GetPrivateProfileInt to work.
>
>Here is what I did:
>Declare Integer GetPrivateProfileString in Win32API ;
> string lpApplicationName, ;
> string lpKeyName, ;
> string lpDefault, ;
> string lpReturnedString, ;
> integer nSize, ;
> string lpFileName
>
>sExePath = alltrim(sys(16,1))
>sExePath = left(sExePath, len(sExePath) - 3) + 'INI'
>
>uname = ""
>slength = GetPrivateProfileString("StringSection", "str1", "anonymous", uname, 255, sExePath)
>messagebox("The returned string is : " + uname, 48, "Testing INI")
>
>I believe the problem has to do with the lpKeyName variable which is supposed to be an ANY Data Type, but VPF does not have that data type.
>Does anyone see how I could fix that problem?

Hi Pascal,

The declaration and call (using your example) should be:
* Declaration
Declare Integer GetPrivateProfileString in Win32API ;
  string lpApplicationName, ;
  string lpKeyName, ;
  string lpDefault, ;
  string @lpReturnedString, ;
  integer nSize, ;
  string lpFileName
* Initialize buffer to hold the return string
uname = SPACE(255)
slength = GetPrivateProfileString("StringSection", "str1", "anonymous", @uname, 255, sExePath)
IF slength > 0
  messagebox("The returned string is : " + LEFT(uname, slength), 48, "Testing INI")
ELSE
  messagebox("Call failed", 48, "Testing INI")
ENDIF
The fourth parameter (which holds the return value) must be declared and passed by reference.

hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform