CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2001
    Location
    UK
    Posts
    8

    How to open file containing win32 env. variable

    Hi all,

    Does anyone know if there is a win32 API or similar that will resolve a file path containing environment varaibles on the fly?

    i.e. How do I open "%TEMP%\mydir\myfile.txt" ?

    Must I first parse what's between the %'s then try to resolve it with GetEnvironmentVariable() and build the file name before I open it?

    or is there an easier way?

    TIA.
    Al.


  2. #2
    Join Date
    Mar 2002
    Posts
    350

    Re: How to open file containing win32 env. variable

    The ExpandEnvironmentStrings function expands environment-variable strings and replaces them with their defined values.

    DWORD ExpandEnvironmentStrings(
    LPCTSTR lpSrc, // string with environment variables
    LPTSTR lpDst, // string with expanded strings
    DWORD nSize // maximum characters in expanded string
    );



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured