Local Settings\Application Data directory

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Local Settings\Application Data directory

Post by Marc Vanzegbroeck »

Hello,

How can I retrieve the %USERPROFILE%\Local Settings\Application Data directory?

Thanks,
Marc
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post by dutch »

Dear Marc,

You can use GetEnv() as in Clipper function.

Code: Select all

GETENV("USERPROFILE")

*------------------------*
Function GetEnv(VarString)
  Local OutBuf:=space(200),VarLen:=0

  VarLen:=GetEnv2(ALLTRIM(VarString),Outbuf,200)
  * If the value return is greater than the initial buffer we have to increase
  * it to receive the value but I limit the length to 3000
  if VarLen > 200 .and. VarLen <=3000
    Outbuf:=SPACE(VarLen)
    GetEnv2(ALLTRIM(VarString),Outbuf,Varlen)
  elseif VarLen > 3000
    MSGINFO("Can't retrieve, the value is too long")
    VarLen:=0
  endif
Return Left(OutBuf,Varlen)

DLL32 FUNCTION GetEnv2( lpName AS LPSTR, lpBuffer AS LPSTR, nSize AS DWORD) ;
               AS DWORD PASCAL FROM "GetEnvironmentVariableA" LIB "Kernel32.DLL"
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post by Marc Vanzegbroeck »

Thanks Dutch,

Its's working!!

Regards,
Marc
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post by dutch »

Cheer!
My pleasure,
Dutch
Post Reply