بهروز عباسی
دوشنبه 22 اسفند 1390, 20:39 عصر
درود به تمام برنامه نویس های گل
من دارم یه کامپوننت ساده مینویسم اینم کدش هنگام کامپایل به این کد گیر میده LinkInfo.FullPathAndNameOfLinkFile :=FFileName;
اینم لیست برنامه:
unit PCshortcutTarget;
interface
uses
SysUtils, Classes,
ComObj , Activex, ShlObj,Windows;
type
PShellLinkInfoStruct = ^TShellLinkInfoStruct;
TShellLinkInfoStruct = record
FullPathAndNameOfLinkFile: array [0 .. MAX_PATH] of Char;
FullPathAndNameOfFileToExecute: array [0 .. MAX_PATH] of Char;
FindData: TWIN32FINDDATA;
end;
TPCShortcutTarget = class(TComponent)
private
FFileName: char;
procedure GetLinkInfo(lpShellLinkInfoStruct: PShellLinkInfoStruct);
protected
{ Protected declarations }
public
function Get_Target():string;
published
property FileName:char read FFileName write FFileName ;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('programming-Co', [TPCShortcutTarget]);
end;
{ TPCShortcutTarget }
procedure TPCShortcutTarget.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;
function TPCShortcutTarget.Get_Target: string;
var
LinkInfo: TShellLinkInfoStruct;
begin
LinkInfo.FullPathAndNameOfLinkFile :=FFileName;
GetLinkInfo(@LinkInfo);
Result:=(LinkInfo.FullPathAndNameOfFileToExecute);
end;
end.
من دارم یه کامپوننت ساده مینویسم اینم کدش هنگام کامپایل به این کد گیر میده LinkInfo.FullPathAndNameOfLinkFile :=FFileName;
اینم لیست برنامه:
unit PCshortcutTarget;
interface
uses
SysUtils, Classes,
ComObj , Activex, ShlObj,Windows;
type
PShellLinkInfoStruct = ^TShellLinkInfoStruct;
TShellLinkInfoStruct = record
FullPathAndNameOfLinkFile: array [0 .. MAX_PATH] of Char;
FullPathAndNameOfFileToExecute: array [0 .. MAX_PATH] of Char;
FindData: TWIN32FINDDATA;
end;
TPCShortcutTarget = class(TComponent)
private
FFileName: char;
procedure GetLinkInfo(lpShellLinkInfoStruct: PShellLinkInfoStruct);
protected
{ Protected declarations }
public
function Get_Target():string;
published
property FileName:char read FFileName write FFileName ;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('programming-Co', [TPCShortcutTarget]);
end;
{ TPCShortcutTarget }
procedure TPCShortcutTarget.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;
function TPCShortcutTarget.Get_Target: string;
var
LinkInfo: TShellLinkInfoStruct;
begin
LinkInfo.FullPathAndNameOfLinkFile :=FFileName;
GetLinkInfo(@LinkInfo);
Result:=(LinkInfo.FullPathAndNameOfFileToExecute);
end;
end.