Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETPRIVATEPROFILESTRING win32api
Message
From
17/10/2001 08:45:15
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
GETPRIVATEPROFILESTRING win32api
Miscellaneous
Thread ID:
00569488
Message ID:
00569488
Views:
92
I have a requirement to pull settings from an ini file created and maintained by another application that is NOT under MY control, so storing information in the registry is not an option. I'm using the function below to get the information which 99% of the time is successful. The problem I am having is with the return string--it is an extra byte longer so when I do a string comparison with the same characters stored in a variable in my VFP app-they do not match. If this function below returns variable xReturn and xReturn="GW38329" and I compare that with variable x which equals "GW38329" for instance, they will not match. In fact, the length of xReturn will be 8 and the len of x will be 7. Anyone have any ideas on how to convert the return the value? I've tried strconv() and isleading() to no avail. I've verified the codepages match so that should not be the problem. This works by the way using low-level file access FGETS(). Here is the function portion of my prg (I included the parameters section for information):


** GET_INI.PRG
PARAMETERS xinifile,xinisection,xiniitem

* GETPRIVATEPROFILESTRING win32api Parameters:
* xIniSection = pointer to a null-terminated string that specifies the name of the
* section containing the key name.
* xIniItem = Pointer to the null-terminated string specifying the name of the
* key whose associated string is to be retrieved.
* xDefaultItem = Pointer to a null-terminated default string.
* xReturn = Pointer to the buffer that receives the retrieved string.
* xSize = Specifies the size, in TCHARS, of the buffer pointed to by the
* xReturn parameter.
* xIniFile = Pointer to a null-terminated string that specifies the name of the
* the initialization file.

*--Retrieve the key's string
LOCAL xSize
xSize=0
xReturn=SPACE(255)
DECLARE integer GetPrivateProfileString IN Win32API AS GetINI ;
string xIniSection,string xIniItem,string xDefaultItem,;
string xReturn,integer xSize,string xIniFile
xSize=GETINI(@xIniSection,@xIniItem,"",@xReturn,LEN(xReturn)+1,xIniFile)
IF xSize>0 && did we successfully retrieve the key's string?
IF LEN(ALLTRIM(xReturn))=0
xreturn = ' '
RETURN xReturn
ENDIF
RETURN ALLTRIM(xReturn)
ELSE
xreturn = ' '
RETURN xReturn
ENDIF



Any help is greatly appreciated!
Tracy
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform