BOOL CreateLink(LPSTR szPath,LPSTR szLink)
{
CoInitialize(NULL);
HRESULT hres;
IShellLink* psl;
IPersistFile* ppf;
WORD wsz[MAX_PATH];
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void**)&psl);
if(FAILED(hres))
return FALSE;
psl->SetPath(szPath);
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(FAILED(hres))
return FALSE;
MultiByteToWideChar(CP_ACP, 0, szLink, -1, wsz, MAX_PATH);
hres = ppf->Save(wsz, STGM_READWRITE);
ppf->Release();
psl->Release();
CoUninitialize();
return TRUE;
}这个函数是用来创建快捷方式的。VC6,在非unicode工程中工作正常,但在unicode工程中报错:
error C2664: 'SetPath' : cannot convert parameter 1 from 'char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
这个如何解决啊?
{
CoInitialize(NULL);
HRESULT hres;
IShellLink* psl;
IPersistFile* ppf;
WORD wsz[MAX_PATH];
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void**)&psl);
if(FAILED(hres))
return FALSE;
psl->SetPath(szPath);
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(FAILED(hres))
return FALSE;
MultiByteToWideChar(CP_ACP, 0, szLink, -1, wsz, MAX_PATH);
hres = ppf->Save(wsz, STGM_READWRITE);
ppf->Release();
psl->Release();
CoUninitialize();
return TRUE;
}这个函数是用来创建快捷方式的。VC6,在非unicode工程中工作正常,但在unicode工程中报错:
error C2664: 'SetPath' : cannot convert parameter 1 from 'char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
这个如何解决啊?
解决方案 »
- 鼠标单击问题?
- 在view类中无法响应toolbar的问题
- 为什么我保存不了listBox中的内容?
- 在vc的创建 MFC APPWIZARD EXE 程序里,为什么在最后的选择view的基类里没有CHtmlView类?
- 走正道赚不了大钱,不如去当恐怖分子,炸美国和日本大使馆!
- 还有一个问题。关于工具栏的图标颜色问题
- 如果我要在一个位图上用鼠标画一条比较粗的线,请问如何实现背景位图上被这条线挡住的区域 能有半透明效果????????????
- 输入框中为何第一次运行的时候没有光标闪烁,怎么解决,有图。
- m_wndToolBar.CreateEx()函数的使用?
- 困扰我良久的问题:Freecell和Sol到底有没有调用cards.dll?
- 已注册控件怎么知道它的路径
- 用VC做什么毕业设计比较有意义?
程序中使用TCHAR代替char,用_T("string")的形式使用字符串常量。
error C2664: 'MultiByteToWideChar' : cannot convert parameter 3 from 'unsigned short *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
下面一行
hres = ppf->Save(szLink, STGM_READWRITE);