#include <comdef.h>
--------------------------------------------------
char *file = "d:\\crctab.txt";
IShellLink* pLink;
IPersistFile* pPersistFile;
LPMALLOC ShellMalloc;
LPITEMIDLIST DesktopPidl;
char DesktopDir[MAX_PATH];
if(FAILED(SHGetMalloc(&ShellMalloc)))
return;
if(FAILED(SHGetSpecialFolderLocation(NULL,CSIDL_DESKTOPDIRECTORY,&Desk
topPidl)))
return;
if(!SHGetPathFromIDList(DesktopPidl, DesktopDir))
{
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
return;
}
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
if(SUCCEEDED(CoInitialize(NULL)))
{
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SE
RVER, IID_IShellLink, (void **) &pLink)))
{
pLink->SetPath(file);
pLink->SetDescription("这是快捷方式的说明");
pLink->SetShowCmd(SW_SHOW);
if(SUCCEEDED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPers
istFile)))
{
strcat(DesktopDir,"\\bcbshortcut.lnk"); // 建立在桌面
if(SUCCEEDED(pPersistFile->Save(_bstr_t(DesktopDir), TRUE)))
MessageBox("Lnk Saved!","OK");
pPersistFile->Release();
}
pLink->Release();
}
CoUninitialize();
}
这是一段BCB的,改改就行了
--------------------------------------------------
char *file = "d:\\crctab.txt";
IShellLink* pLink;
IPersistFile* pPersistFile;
LPMALLOC ShellMalloc;
LPITEMIDLIST DesktopPidl;
char DesktopDir[MAX_PATH];
if(FAILED(SHGetMalloc(&ShellMalloc)))
return;
if(FAILED(SHGetSpecialFolderLocation(NULL,CSIDL_DESKTOPDIRECTORY,&Desk
topPidl)))
return;
if(!SHGetPathFromIDList(DesktopPidl, DesktopDir))
{
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
return;
}
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
if(SUCCEEDED(CoInitialize(NULL)))
{
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SE
RVER, IID_IShellLink, (void **) &pLink)))
{
pLink->SetPath(file);
pLink->SetDescription("这是快捷方式的说明");
pLink->SetShowCmd(SW_SHOW);
if(SUCCEEDED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPers
istFile)))
{
strcat(DesktopDir,"\\bcbshortcut.lnk"); // 建立在桌面
if(SUCCEEDED(pPersistFile->Save(_bstr_t(DesktopDir), TRUE)))
MessageBox("Lnk Saved!","OK");
pPersistFile->Release();
}
pLink->Release();
}
CoUninitialize();
}
这是一段BCB的,改改就行了
create Links to a File (in Startmenu and Autostart).
create Links to a File (in Startmenu and Autostart).
http://nowcan.yeah.net