Hola DSK25.
Para crear los accesos directos podes hacer:
Código:
#include<shlobj.h>
#include<comobj.hpp>
void CreateShortcut(char *ExeFileName, char *LnkFileName)
{
IUnknown *UInterface;
IShellLink *ISlink;
IPersistFile *IPfile;
OleCheck(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL,
IID_IUnknown, (void**) &UInterface));
__try {
OleCheck(UInterface->QueryInterface(IID_IShellLink,(void**) &ISlink));
__try {
ISlink->SetPath(ExeFileName);
OleCheck(UInterface->QueryInterface(IID_IPersistFile,(void**) &IPfile));
__try {
IPfile->Save((WideString)LnkFileName, False);
}
__finally {
IPfile->Release();
}
}
__finally {
ISlink->Release();
}
}
__finally {
UInterface->Release();
}
}
Ejemplo de llamada:
Código:
void __fastcall TForm1::Button1Click(TObject *Sender)
}
char PathToShortcut[260];
char *ExeFileName = "C:\\MiPrograma.exe"; // ruta al programa
char *LnkFileName = "MiPrograma.lnk"; // nombre del a. directo
/* componer ruta a escritorio */
wsprintf(PathToShortcut,"%s%s%s", getenv("USERPROFILE"),
"\\Desktop\\", LnkFileName);
/* Crear acceso directo */
CreateShortcut(ExeFileName, PathToShortcut);
/* componer ruta a Menu de inicio */
ZeroMemory(PathToShortcut, sizeof(PathToShortcut));
wsprintf(PathToShortcut,"%s%s%s", getenv("APPDATA"),
"\\Microsoft\\Windows\\Start Menu\\Programs\\", LnkFileName);
/* Crear acceso directo */
CreateShortcut(ExeFileName, PathToShortcut);
}
Para evitar el error
"Multiple declaration for ..." , hace lo siguiente:
Project ->
Options ->
Directories/Conditionals ->
Conditional defines, click sobre el boton con puntos suspensivos (...), escribí
NO_WIN32_LEAN_AND_MEAN en el cuadro de edición y hace click sobre el botón
Add.
Saludos.