VC,JAVA,DELPHI高手向高手求助,急,急,急!!!!

t_xuyong 2002-07-29 04:16:30
有一段程序(在WINDOWS桌面上建快捷方式):

IShellLink *ppv=NULL;

HRESULT hres=CoCreateInstance (CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLinkA,(LPVOID *)ppv);

if(SUCCEEDED(hres))
{
ppv->SetPath(lpszPath);
。。。。。。
}else
{
MessageBox(NULL,"failed","good",MB_OK);
}

为什么CoCreateInstance函数调结束后,老是处于失败状态,即弹出 MessageBox,告诉我是FAILED呢?


...全文
11 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lqbn 2002-07-30
应该用(LPVOID *)&ppv
回复
bcb_fans 2002-07-29
if(SUCCEEDED(CoInitialize(NULL)))
{
//在这里做你的事
//....
CoUninitialize();
}

另:代码也有错误:

.....,(LPVOID *)ppv);

改为-->>>

.....,(LPVOID *)&ppv);//不要少了 &


回复
ThisTimeThree 2002-07-29
是不是用 (LPVOID *)&ppv, Instead
回复
t_xuyong 2002-07-29
Thank you ,but still have problem:
ppv最后的结果是NULL,这是怎么回事情呢?
回复
lqbn 2002-07-29
Return Values
S_OK
An instance of the specified object class was successfully created.
REGDB_E_CLASSNOTREG
A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.
CLASS_E_NOAGGREGATION
This class cannot be created as part of an aggregate.
E_NOINTERFACE
The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface.
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告