崩溃,一个数据类型怎么就出错?(在线等)
用atl向导做组件,就添加了一个方法:实验目的是输出一个字符串
STDMETHODIMP CgetPwd::getTest(VARIANT *p)
{
*p.vt=VT_BSTR;
*p.bstrVal=SysAllocString(L"Hello,你好");
return S_OK;
}
编译时出现下列错误:
F:\webroot\kjmCom\getPwd.cpp(30) : error C2228: left of '.vt' must have class/struct/union type
F:\webroot\kjmCom\getPwd.cpp(31) : error C2228: left of '.bstrVal' must have class/struct/union type
以为缺少头文件,搜索百度和google,资料奇少
看到有人写加#include <OAIDL.H>或#include <comdef.h>,
都加了,结果没用.