DevMedia - asp.net, Java, Delphi, SQL e web Design, tudo em um só lugar!
Bem vindo a DevMedia!
LOGIN:     SENHA:
 
 

Delphi: Criando um atalho na area de trabalho

Como criar um atalho no desktop do Windows com Delphi

Inclua ActiveX, ComObj e ShlObj na clausula USES.


Veja os eventos do form codificados abaixo:

procedure TFMain.FormCreate(Sender: TObject);
var ItemIDList : PItemIDList;
begin

SetLength(DirDesktop,MAX_PATH);
SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOPDIRECTORY,ItemIDList);
SHGetPathFromIDList(ItemIdList,PChar(DirDesktop));
SetLength(DirDesktop,StrLen(PChar(DirDesktop)));

end;


procedure TFMain.BitBtn1Click(Sender: TObject);
var ShellLink : IShellLink;
PersistFile : IPersistFile;
NomeLnk : WideString;
begin

ShellLink := CreateComObject(CLSID_ShellLink) as IShellLink;
PersistFile := ShellLink as IPersistFile;
with ShellLink do begin

// Informe o Título do ícone
SetDescription(PChar('DESCRIÇÃO DO ATALHO'));

// Informe o Caminho e o Arquivo
SetPath(PChar('C:PASTAARQUIVO.EXE'));

// Argumentos para linha de comando, caso existam
SetArguments(PChar(''));

// Informe o Caminho e o Arquivo
SetWorkingDirectory(PChar(ExtractFilePath('C:PASTAARQUIVO.EXE')));
end;

// Informe o nome do Atalho
NomeLnk := DirDesktop+''+ChangeFileExt('DESCRIÇÃO DO ATALHO','.lnk');
PersistFile.Save(PWideChar(NomeLnk),False);

end;

fonte: http://www.delphidicas.com.br





    0 COMENTÁRIO

[Fechar]

Este post é fechado - você precisa ter acesso ao post para incluir um comentário.


Nenhum comentário foi postado - seja o primeiro a comentar!



[Este post ainda não foi associado a uma sequência]
Publicidade
Autor
Gladstone Matos

É diretor editorial na www.web03.net




Space do autor
Estatísticas #
Favorito:
Comentários:
Feedback:
Utilidade:
0   0
[Fechar]

Você precisa estar logado para dar um feedback.

Clique aqui para efetuar o login
[Fechar]


Este post está fechado. Saiba mais sobre a assinatura MVP!
web-03
DevMedia  |  Anuncie  |  Fale conosco
Hospedagem web por Porta 80 Web Hosting
2012 - Todos os Direitos Reservados a web-03