#include <windows.h>
#include <shlobj.h>
int main() {
// Obtener el directorio del escritorio
TCHAR desktopPath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) {
// Crear la ruta completa del acceso directo
TCHAR shortcutPath[MAX_PATH];
PathCombine(shortcutPath, desktopPath, L"MiAccesoDirecto.lnk");
// Obtener la interfaz de la shell
IShellLink* pShellLink = NULL;
CoInitialize(NULL);
if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&pShellLink))) {
// Establecer el path del archivo al que apunta el acceso directo
pShellLink->SetPath(L"C:\\Ruta\\A\\Tu\\Programa.exe");
// Guardar el acceso directo en el escritorio
IPersistFile* pPersistFile;
if (SUCCEEDED(pShellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&pPersistFile))) {
pPersistFile->Save(shortcutPath, TRUE);
pPersistFile->Release();
}
pShellLink->Release();
}
CoUninitialize();
}
return 0;
}