CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 6 of 6

Thread: Composing directory with relative path

  1. #1
    Join Date
    May 2001

    Composing directory with relative path

    I've once seen a function that would take two strings, one being a path to a folder, and another being a relative path, and return new folder to which relative path was pointing to given the first string. Does anyone remember that function? It is not in the standard list of File I/O API's......

  2. #2
    Join Date
    Apr 2001
    San Diego CA
    Is GetModuleFilename what you are looking for

  3. #3
    Join Date
    May 2001
    Originally posted by voidspace
    Is GetModuleFilename what you are looking for

    Here is a better illustration... consider this function in pseudo lang...

    str ComposeDirFromRelative(str, str)

    and let's say it is called like this:

    ComposeDirFromRelative('C:\temp\subtemp', '.\..\subtemp2')

    will return C:\temp\subtemp2

  4. #4
    Join Date
    May 1999
    Southern California
    Do you need a full path for your relative path? Look at _fullpath. Also see _makepath.
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    May 2001
    Originally posted by Sam Hobbs
    Do you need a full path for your relative path? Look at _fullpath. Also see _makepath.
    _makepath is not it, but _fullpath is very close.....

    I guess I could do something like this:

    curdir = GetCurrentDirectory();
    _fullpath(dest, relativepath);

    and for the current version of the project it will probably do, but the problems with this approch are:

    in multithreaded environment, if other threads rely on current folder, this may screw them up.
    I'm writing a COM object, so "I don't know anything" about other threads, nor can I do mutual exclusion since I'm in my "own world".

    I believe the function that I saw would do almost what _fullpath does... It would take one more parameter, basepath, relative to which it will apply the relative path. It wasn't C run-time function... it looked more like a standard windows API... like SomeFunctionName().

  6. #6
    Join Date
    Nov 1999
    Dresden / Germoney

    shlwapi: PathXxxx functions

    shlwapi 4.71 (requires IE4, but see below) offers:

    PathCombine to concatenate two path's, and
    PathCanonicalize to "make it pretty".

    from MSDN:
    "All systems with Internet Explorer 4.0 or 4.01 will have the associated version of Comctl32.dll and Shlwapi.dll (4.71 or 4.72, respectively). However, for systems prior to Windows 98, Internet Explorer 4.0 and 4.01 can be installed with or without the integrated shell. If they are installed with the integrated shell, the associated version of Shell32.dll will be installed. If they are installed without the integrated shell, Shell32.dll is not updated. In other words, the presence of version 4.71 or 4.72 of Comctl32.dll or Shlwapi.dll on a system does not guarantee that Shell32.dll has the same version number. All Windows 98 systems have version 4.72 of Shell32.dll."

    So if you *can* let Nt3.51 and Windows 95 off the cliff, go ahead
    (Win95 isn't supported by MS anymore anyway, so there are only a few unlucky NT3.51'ers)


Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)