+ Reply to Thread
Results 1 to 2 of 2

Thread: How can I get full path that is returned by GetEnvironmentVariable?

  1. #1

    How can I get full path that is returned by GetEnvironmentVariable?

    How can I get proper path that is returned by GetEnvironmentVariable? GetEnvironmentVariable API returns path in following pattern: "C:\DOCUME~1\USerName\LOCALS~1\Temp". I want to make this in full path. Please advice. My example is:

    Code:
    CString GetEnvironmentVarValue(CString strEnvVarName)
    {
    	TCHAR szVarValue[MAX_PATH] = "" ;
    	GetEnvironmentVariable(strEnvVarName.GetBuffer(0), szVarValue, sizeof(szVarValue)) ;
    	return CString(szVarValue) ;
    }

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    43
    You can use GetLongPathName API as follows:

    Code:
    CString GetEnvironmentVarValue(CString strEnvVarName)
    {
    	TCHAR szVarValue[MAX_PATH] = "" ;
    	GetEnvironmentVariable(strEnvVarName.GetBuffer(0), szVarValue, sizeof(szVarValue)) ;
    	GetLongPathName(szVarValue, szVarValue, sizeof(szVarValue)) ;
    	return CString(szVarValue) ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts