非MFC中使用SysAllocString函数
#include <windows.h>
#include <winnt.h>
#include <oleauto.h>
//其实BSTR原型就是 unsigned short*
BSTR __stdcall lzj1()
{
char *str="阿杰软件工作室-编写日期:2010-12-23";
return SysAllocString((BSTR)str);
}
int main(int argc, char* argv[])
{
printf("%s\n",lzj1());
return 0;
}调试环境:VC6
如果提示#include <oleauto.h> 头文件有错误
错误信息:error C2146: syntax error : missing ';' before identifier 'IID_StdOle'
请打开oleauto.h头文件直接将以下语句注释上保存下就OK了;
//EXTERN_C const IID IID_StdOle;
页:
[1]