There's something wrong when call the import function with an out param?

 
#import "kernel32.dll"
int GetPrivateProfileStringA(string lpSection, string lpKey, string lpDefault, string lpReturnString, int dwSize, string lpFileName);

#import


The param "lpReturnString" is output type, it is so strange that,

when I call this function more than once, then I will get a result same as last time?

 

more desciption:

call more than once, return result is correct, but the first return string var's content will changed to the next call return value.

e.g.:


string sRet1="";

GetPrivateProfileStringA(......, sRet1, 255, sFileName);

Print("step1, sRet1=", sRet1);


string sRet2="";

GetPrivateProfileStringA(......, sRet2, 255, sFileName);

Print("step2, sRet1=", sRet1);


string sRet3="";

GetPrivateProfileStringA(......, sRet3, 255, sFileName);

Print("step3, sRet1=", sRet1);


after step1, the value of sRet1 is correct, but when step2 or step3 finished, the value of sRet1 had changed to sRet2 or sRet3!

I was confused now...

(and please notice that, if without init the out string parm using "" before calling the function, it will made the program crash...)

 

another problem: when I read 3 string key: sKey1, sKey2, sKey3, one by one,

if sKey3 not exists, then it will return the result of sKey2, not the default string I specify for skey3!

Reason: