Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing target path from a shortcut file on a 64 bit system using 32 bit application

I'm trying to access the target path from a shortcut(.lnk) file on a 64bit machine using my 32 bit application. To get the path, I was using the following code.

WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(flexShortcut);
FLEXEXE = link.TargetPath;

This returns the path C:\Program Files (X86)\.. instead of C:\Program Files\..

Is there any work around for this?

like image 986
Jimesh Avatar asked Nov 13 '22 18:11

Jimesh


1 Answers

A trick to be used is to

  1. Get the file name from link.TargetPath
  2. Get the working directory from link.WorkingDirectory
  3. Append path
like image 136
Jimesh Avatar answered Nov 24 '22 01:11

Jimesh