bool CreateQuickLaunchShortcut(String& destFile,String& shortCutName,String& arguments)

{

char szBuf[MAX_PATH];

LPITEMIDLIST lpItemIdList;

SHGetSpecialFolderLocation(0, CSIDL_APPDATA, &lpItemIdList);

SHGetPathFromIDList(lpItemIdList, szBuf);

String dir = String(szBuf) + "\\Microsoft\\Internet Explorer\\Quick Launch\\";

bool result = CreateShortcut(destFile,shortCutName,dir,arguments);

return result;

}

bool CreateShortcut(String& destFile,String& shortCutName,String& dir,String& arguments)

{

TShortcutCfg scConfig;

scConfig.strDestFile = destFile;

scConfig.strShortcutName = shortCutName;

scConfig.strArguments = arguments;

bool bReturn = true;

wchar_t wszBuf[MAX_PATH];

IShellLink *pShellLink;

AnsiString strShortcutFile;





strShortcutFile = dir + shortCutName + SHORTCUT_SUFFIX;





strShortcutFile.WideChar(wszBuf, MAX_PATH);





if(bReturn)

{

bReturn = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,

IID_IShellLink, (void **)&pShellLink) >= 0;





if(bReturn)

{

IPersistFile *ppf;

bReturn = pShellLink->QueryInterface(IID_IPersistFile, (void **)&ppf) >= 0;

if(bReturn)

{

// 目标文件

if(scConfig.strDestFile != EmptyStr)

bReturn = pShellLink->SetPath(scConfig.strDestFile.c_str()) >= 0;

// 参数

if(bReturn && scConfig.strArguments != EmptyStr)


bReturn = pShellLink->SetArguments(scConfig.strArguments.c_str()) >= 0;

// 显示图标

if(bReturn && scConfig.strIconFile != EmptyStr && FileExists(scConfig.strIconFile))

pShellLink->SetIconLocation(scConfig.strIconFile.c_str(),

scConfig.nIconIndex);

// 起始位置

if(bReturn && scConfig.strWorkingDir != EmptyStr)

pShellLink->SetWorkingDirectory(scConfig.strWorkingDir.c_str());

// 备注

if(bReturn && scConfig.strDescription != EmptyStr)

pShellLink->SetDescription(scConfig.strDescription.c_str());

// 快捷键

if(bReturn && scConfig.wHotKey != 0)

pShellLink->SetHotkey(scConfig.wHotKey);

// 运行方式

if(bReturn && scConfig.nShowCmd != 0)

pShellLink->SetShowCmd(scConfig.nShowCmd);





if(bReturn)

bReturn = (ppf->Save(wszBuf, TRUE) >= 0);





ppf->Release ();

}

pShellLink->Release ();

}

}

return bReturn;

}