如何用C语言实现在桌面创建一个文件的快捷方式
已经搞定了,代码如下:
void CreateOnDesktop()
{
IShellLink *pShellLink;//定义IShellLink指针
IPersistFile *pPersiitFile;//定义Ipersistfile指针
HRESULT hResult;//初始化com
char savePath[MAX_PATH];
int len=0;
OLECHAR widePath[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;
char cmdline[MAX_PATH];
username = g_loginInfo.username;
password = g_loginInfo.password;
domain = g_loginInfo.domain;
srvaddr = g_loginInfo.serveraddress;
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);
//hResult =CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
//if (hResult==S_OK)
//{//初始化成功则申请组件对象并获得IShellLink接口指针
hResult=CoCreateInstance(&CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IShellLink,