我用代码创建了一个快捷方式,默认的是加载资源文件的图标,请问下如何能代码更改图标呢,创建代码如下:
void CreateOnDesktop(char *path)
{
IShellLink *pShellLink;//定义IShellLink指针
IPersistFile *pPersiitFile;//定义Ipersistfile指针
HRESULT hResult;//初始化com
char savePath[MAX_PATH];
int len=0;
OLECHAR widePath[MAX_PATH];
int Appid = 0;
char *appname = NULL;
char linkname[MAX_PATH];
char pFileName[MAX_PATH];
HMODULE module;
static char * username = NULL;
static char * password = NULL; //static char *
static char * domain = NULL;
static char * srvaddr = NULL;
static char * appid = NULL;
char cmdline[MAX_PATH];
char iconpath[MAX_PATH];
HICON hicon = LoadIcon(NULL,IDI_FONT);
username = g_loginInfo.username;
password = g_loginInfo.password;
domain = g_loginInfo.domain;
srvaddr = g_loginInfo.serveraddress;
appid = GetAppId();
module = GetModuleHandle(0);
GetModuleFileName(module, pFileName, MAX_PATH); //得到应用程序exe的路径
memset(cmdline,0,MAX_PATH);
strcat(cmdline,username);
strcat(cmdline," ");
strcat(cmdline,password);
strcat(cmdline," ");
strcat(cmdline,domain);
strcat(cmdline," ");
strcat(cmdline,srvaddr);
strcat(cmdline," ");
strcat(cmdline,appid);
//hResult =CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
appname = GetAppName();
memset(iconpath,0,MAX_PATH);
GetCurrentDirectory(MAX_PATH,iconpath);
Appid = atoi(appid);
strcat(iconpath,"\\FreeAppInfor");
memset(linkname,0,MAX_PATH);
strcat(linkname,"\\");
strcat(linkname,appname);
strcat(linkname,".lnk");
//if (hResult==S_OK)
//{//初始化成功则申请组件对象并获得IShellLink接口指针
hResult=CoCreateInstance(&CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IShellLink,
(void **)&pShellLink);
if (hResult==S_OK)
{//获得IShellLink接口指针成功则查询并获得IPersistFile接口指针
hResult=pShellLink->lpVtbl->QueryInterface(pShellLink,
&IID_IPersistFile,
&pPersiitFile);
if (hResult==S_OK)
{
hResult=pShellLink->lpVtbl->SetPath(pShellLink,pFileName);//指明被创建快捷方式文件路径
pShellLink->lpVtbl->SetArguments(pShellLink,cmdline); //设置命令行参数
pShellLink->lpVtbl->SetDescription(pShellLink,"Shortcut Config.sys");//设置快捷方式图标的文本