PDA

View Full Version : بدست آوردن مسیر برنامه از طریق شرت کات آن



بهروز عباسی
یک شنبه 14 اسفند 1390, 14:11 عصر
درود به همه برنامه نویس های گل:لبخند:

من میخوام آدرس یک شرت کات به برنامه بدم از طریق شرت کات ادرس فایل اصلی رو بدست بیارم

ممنون از کمک

سعید صابری
چهارشنبه 17 اسفند 1390, 15:25 عصر
http://delphi.about.com/od/windowsshellapi/l/aa072704a.htm

بهروز عباسی
چهارشنبه 17 اسفند 1390, 19:23 عصر
دوست عزیز ممنون از کمک منظور من این مثال شمانبود

منظور من اینه:
اگه مثلاً این شرت کات من باشه روی دستکاپ FinalBuilder 7 Embarcadero Edition.lnk
من میخوام این ادرس که ادرس فایل FinalBuilder7.exe هست رو به دست بیارم

ادرس در این مثال اینه:"C:\Program Files (x86)\FinalBuilder 7 EE\FinalBuilder7.exe"
ممنون میشم دوستان کمک کنن.

سعید صابری
چهارشنبه 17 اسفند 1390, 19:48 عصر
در اون لینک دقیقا همین کار را توضیح داده بودند.

بهروز عباسی
چهارشنبه 17 اسفند 1390, 20:39 عصر
من برنامه ای که گذاشته بودن روی سایت رو دانلود کردم ولی فقط مسیر شرت کات رو برمی گردونه
اینم بگم من از Win7 استفاده میکنم وقتی روی باتون Read target from lnk کلیک میکنم فقط یه مسیج خالی میده

باXp هم تست کردم همین بود لطفاًکمک کنید

Felony
دوشنبه 22 اسفند 1390, 06:35 صبح
type
PShellLinkInfoStruct = ^TShellLinkInfoStruct;
TShellLinkInfoStruct = record
FullPathAndNameOfLinkFile: array [0 .. MAX_PATH] of Char;
FullPathAndNameOfFileToExecute: array [0 .. MAX_PATH] of Char;
FindData: TWIN32FINDDATA;
end;

procedure GetLinkInfo(lpShellLinkInfoStruct: PShellLinkInfoStruct);
var
ShellLink: IShellLink;
PersistFile: IPersistFile;
AnObj: IUnknown;
begin
// access to the two interfaces of the object
AnObj := CreateComObject(CLSID_ShellLink);
ShellLink := AnObj as IShellLink;
PersistFile := AnObj as IPersistFile;

// Opens the specified file and initializes an object from the file contents.
PersistFile.Load
(PWChar(WideString(lpShellLinkInfoStruct^.FullPath AndNameOfLinkFile)), 0);
with ShellLink do
begin
// Retrieves the path and file name of a Shell link object.
GetPath(lpShellLinkInfoStruct^.FullPathAndNameOfFi leToExecute,
SizeOf(lpShellLinkInfoStruct^.FullPathAndNameOfLin kFile),
lpShellLinkInfoStruct^.FindData, SLGP_UNCPRIORITY);
end;
end;

استفاده :


var
LinkInfo: TShellLinkInfoStruct;
begin
LinkInfo.FullPathAndNameOfLinkFile :=
'C:\Users\Mojtaba\Desktop\Borland C++‎.lnk';
GetLinkInfo(@LinkInfo);
ShowMessage(LinkInfo.FullPathAndNameOfFileToExecut e);

کتابخانه های ComObj , Activex, ShlObj رو به پروژتون اضافه کنید .