// JP opened flex table

Click to See Complete Forum and Search --> : create shortcut


hafaka2000
March 9th, 2000, 01:26 PM
how can i create shortcut from my appliction
i am using a win95 & win98 platform

gougoul
April 4th, 2000, 12:18 PM
very easy....

gougoul
April 4th, 2000, 12:28 PM
There it is !!!

HRESULT hres;
hres = CoInitialize(NULL);

ITEMIDLIST *id;
char szFolderName[MAX_PATH];

if (Type == DESKTOP)
SHGetSpecialFolderLocation(NULL,CSIDL_DESKTOP,&id);
else if (Type == PROFILES)
SHGetSpecialFolderLocation(NULL,CSIDL_PROGRAMS,&id);
SHGetPathFromIDList(id,&szFolderName[0]);

CString Link = szFolderName+CString("\\")+LinkFileName;

if (!IsFolder) {
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(LPVOID*) &psl);
if (SUCCEEDED(hres)) {
IPersistFile* ppf;

psl->SetPath(Target);
psl->SetArguments(Arguments);

hres = psl->QueryInterface( IID_IPersistFile,
(LPVOID *) &ppf);

if (SUCCEEDED(hres)) {
CString Temp = Link;
Temp.MakeLower();
if (Temp.Find(".lnk")==-1)
Link += ".lnk";
WORD wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED, Link,-1,wsz,MAX_PATH);

// This is the link to remove....

hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
} // Otherwise, should create a dir, eh !!!
return hres;

//JP added flex table