How get program to follow path thru shortcuts?

G

Guest

Hello. Ive got a VC++ program. Inside the program Ive got some code that
has a full file path:

C:\aa\bb\cc\dd\file.txt

One of the folders in that path (cc) is a shortcut pointing to some other
folder far away.

The program doesnt seem to follow the shortcut. Im used to Unix, where
shortcuts are indistinguishable from folders (or files) and you cannot have a
shortcut and a folder with the same name in the same location. But Windows
treats things differently, as in:

C:\aa\bb\cc // a shortcut
and
C:\aa\bb\cc // a real folder

are both permitted to exist side-by-side. On Windows, apparently, the
shortcuts are really files with a .lnk suffix; and shortcuts are not treated
as "strongly" as in Unix. I guess shortcuts are only followed by Windows
Explorer GUI when a user cllicks on them?

My question is: Is there a way to create a shortcut so it behaves exactly
like a folder, and a program that accesses the shortcut will just pass
magically through it (to the target folder the shortcut points to) as if the
shortcut was a real folder?

Thanks in advance for any replies.
 
C

Carl Daniel [VC++ MVP]

noleander said:
Hello. Ive got a VC++ program. Inside the program Ive got some code
that has a full file path:

C:\aa\bb\cc\dd\file.txt

One of the folders in that path (cc) is a shortcut pointing to some
other folder far away.

The program doesnt seem to follow the shortcut. Im used to Unix,
where shortcuts are indistinguishable from folders (or files) and you
cannot have a shortcut and a folder with the same name in the same
location. But Windows treats things differently, as in:

C:\aa\bb\cc // a shortcut
and
C:\aa\bb\cc // a real folder

are both permitted to exist side-by-side. On Windows, apparently, the
shortcuts are really files with a .lnk suffix; and shortcuts are not
treated as "strongly" as in Unix. I guess shortcuts are only
followed by Windows Explorer GUI when a user cllicks on them?

My question is: Is there a way to create a shortcut so it behaves
exactly like a folder, and a program that accesses the shortcut will
just pass magically through it (to the target folder the shortcut
points to) as if the shortcut was a real folder?

A shortcut is just that - a file that contains a reference to another file.
It's not the least bit like a symbolic link (or hard link) in Unix.

The NTFS filesystem does support symbolic links and hard links (through
volume mount points), but there's not a lot of end-user support them since
they're rarely used. You can create them programaticaly though. See if
these references get you where you need to be:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createhardlink.asp

http://www.codeproject.com/w2k/junctionpoints.asp?df=100&forumid=75&exp=0&select=354644#The_Solution

There are other articles out on the web if you do some searching.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top