Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2004.01.13;
Скачать: [xml.tar.bz2];

Вниз

Ярлык   Найти похожие ветки 

 
Adil Aliyev   (2003-12-30 01:13) [0]

Как можно создать ярлык какого то файла через программы?


 
Adil Aliyev   (2003-12-30 12:59) [1]

Не кто не знает


 
Rouse_   (2003-12-30 13:26) [2]

uses ...ShlObj, ComObj, Registry, ActiveX;

function TForm1.CreateLinkDesktop(Const FileName : String) : String;
var
MyObject : IUnknown;
MySLink : IShellLink;
MyPFile : IPersistFile;
Directory : String;
WFileName : WideString;
MyReg : TRegIniFile;
begin
MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;
with MySLink do begin
SetPath(PChar(FileName));
SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
end;
MyReg := TRegIniFile.Create("Software\MicroSoft\Windows\CurrentVersion\Explorer") ;
Directory := MyReg.ReadString("Shell Folders","Desktop","");
WFileName := Directory+"\Test.lnk";
MyPFile.Save(PWChar(WFileName),False);
MyReg.Free;
end;


Желаю успехов


 
Dimman1   (2003-12-30 15:34) [3]

procedure MyCreateShortCut(sTarget,sIconFile:String;iIconIndex:Integer;sName:String);
(*
sTarget: String; { This is the path and name of the file that the shortcut is to point too }
sIconFile : String; { This is the path and name of the file that contains the icon (it can be an .exe or .ico file) }
iIconIndex : Integer; { The index of which icon to use in the specifiedfile }
sName : String; { The name for the shortcut including the path}
*)
var
slTemp: IShellLink;
pfTemp: IPersistFile;
begin
CoInitialize(nil);
try
// create an uninitialized IShellLink (a shortcut)
if CoCreateInstance(CLSID_ShellLink,nil,CLSCTX_INPROC_SERVER,IShellLink, slTemp) = S_OK then
begin
slTemp.SetPath(PChar(sTarget));
slTemp.SetIconLocation(PChar(sIconFile), iIconIndex);
//Get an IPersistFile interface (needed to specify the name of the Shortcut)
if slTemp.QueryInterface(IPersistFile, pfTemp) = S_OK then
if pfTemp.Save(StringToOleStr(sName), True) <> S_OK then
Application.MessageBox("Не могу создать ярлык","Ошибка!",mb_ok or MB_ICONSTOP);

// do not Release slTemp, it is done automatically by Delphi
end;
// deinitialize COM
finally
CoUninitialize;
end;
end;



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2004.01.13;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.008 c
6-37827
AlexanderSK
2003-11-10 16:54
2004.01.13
Несколько HTTP запросов один за одним


14-37858
Обезяна
2003-12-22 12:02
2004.01.13
Обезяна


14-37850
PaRL
2003-12-22 20:03
2004.01.13
Сертификация(Retra Tech)


3-37515
AndrewK
2003-12-17 13:29
2004.01.13
Как хранить в таблице значения разных типов


7-37962
alexus
2003-10-29 15:17
2004.01.13
фильтр-перехватчик на файловую систему





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский