1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
HRESULT ccn;
IShellLink *LNKn;
WORD cdic[MAX_PATH];
CoInitialize(NULL);
ccn = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink,(LPVOID *)& LNKn);
AnsiString zouro = ExtractFilePath(Application->ExeName);
AnsiString rezug = zouro + "\\ICLcreatico.ICL";
if(SUCCEEDED(ccn))
{
IPersistFile *actonun;
LNKn->SetPath("%windir%\\system32\\shutdown.exe -r -t 0");//Cible qui doit être ouvert
LNKn->SetDescription("Redémarrer");
LNKn->SetWorkingDirectory("%windir%");
LNKn->QueryInterface(IID_IPersistFile,(LPVOID *)&actonun);
LNKn->SetIconLocation(rezug.c_str(), 2);//Icone pour le raccourci
LPITEMIDLIST idlste;
if(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &idlste)== NOERROR)
{
char cBufln[MAX_PATH];
SHGetPathFromIDList(idlste, cBufln);
Label4->Caption = cBufln + AnsiString("\\Redémarrer.lnk");//Nom + chemin du raccourci sur le bureau
MultiByteToWideChar(CP_ACP, 0, Label4->Caption.c_str(), -1,(LPWSTR)cdic, MAX_PATH);
actonun->Save((LPWSTR)cdic, true);
}
}
} |
Partager