Retrieve Windows symlink target in cC

414 Views Asked by At

I created a couple of symlinks....

The dir command is able to show the target as below


Directory of C:\abc

07/03/2020 04:58 AM link.txt [s:\naveen\ow.bat]

07/03/2020 05:01 AM link1.txt [c:\naveen\ow.bat]


I am trying to get the target value via C code

I am using the GetFinalPathNameByHandleA() API to achieve this.....

Different o/p for different i/p flag

VOLUME_NAME_NT

[C:\abc]a.exe link.txt The final path is: \Device\Mup\den00mce\c$\naveen\ow.bat

[C:\abc]a.exe link1.txt The final path is: \Device\HarddiskVolume5\naveen\ow.bat

VOLUME_NAME_DOS

[C:\abc]a.exe link.txt The final path is: \?\UNC\den00mce\c$\naveen\ow.bat

[C:\abc]a.exe link1.txt The final path is: \?\C:\naveen\ow.bat

VOLUME_NAME_GUID

[C:\abc]a.exe link.txt The final path is: --> this doesn't work, its not resolving for remote file

[C:\abc]a.exe link1.txt The final path is: \?\Volume{ebea43d1-9277-49bb-bb42-57bca6a7fdcc}\naveen\ow.bat

VOLUME_NAME_NONE

[C:]a.exe link.txt The final path is: \den00mce\c$\naveen\ow.bat

[C:]a.exe link1.txt

The final path is: \naveen\ow.bat --> I don't think it will be helpful as it's removing the volume name like c:, d: etc...

Note: s: is a remote drive I mapped using net use * \\abc\def

Do we have any APIs to get the o/p same as the output from dir shown above?

0

There are 0 best solutions below