45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:怎么样通过VC创建快捷方式?

怎么样通过VC创建快捷方式?

2016-09-05 06:41:48 来源:www.45fan.com 【

怎么样通过VC创建快捷方式?

创建快捷方式

2004-5-12 0:15:49阅读24次

创建快捷方式

HRESULT CreateLink(LPCSTR lpszPathObj,

LPSTR lpszPathLink,

LPSTR lpszDesc)

{

HRESULT hres;

IShellLink* psl;

CoInitialize(NULL);

// Get a pointer to the IShellLink interface.

hres = CoCreateInstance(CLSID_ShellLink, NULL,

CLSCTX_INPROC_SERVER,

IID_IShellLink,

(void **)&psl);

if (SUCCEEDED(hres))

{

IPersistFile* ppf;

// Set the path to the shortcut target and add the

// description.

psl->SetPath(lpszPathObj);

psl->SetDescription(lpszDesc);

// Query IShellLink for the IPersistFile interface for saving the

// shortcut in persistent storage.

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

if (SUCCEEDED(hres))

{

WORD wsz[MAX_PATH]; // Ensure that the string is ANSI.

MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,wsz, MAX_PATH);

// Save the link by calling IPersistFile::Save.

hres = ppf->Save(wsz, TRUE);

ppf->Release();

}

psl->Release();

}

return hres;

}
 

本文地址:http://www.45fan.com/a/question/72511.html
Tags: 学习 创建 资料收集
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部