HRESULT CreateLink(LPCSTR lpszPathObj, LPSTR lpszPathLink, LPSTR lpszDesc)
{
HRESULT hres;
IShellLink *psl;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
if(SUCCEEDED(hres))
{
IPersistFile *ppf;
psl->SetPath(lpszPathObj);
psl->SetDescription(lpszDesc);
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(SUCCEEDED(hres))
{
wchar_t wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz,
MAX_PATH);
hres = ppf->Save(wsz, true);
ppf->Release();
}
psl->Release();
CoUninitialize();
}
return hres;
}