天下

记录修行的印记

COM调用

// atlcall.cpp : Defines the entry point for the console application.
//

#include 
"stdafx.h"
#import 
"AtlSample.tlb"

#include 
"Debug/atlsample.tlh"
using namespace AtlSampleLib;

int _tmain(int argc, _TCHAR* argv[])
{
    HRESULT hr;
    hr  
=::CoInitialize(NULL);
    IAccountPtr pAccount 
= NULL;
    pAccount.CreateInstance(__uuidof(Account));
    
if (FAILED(hr))
    {
        printf(
"(FAILED(hr) \r\n");
        ::CoUninitialize();
        
return 0;
    }
    BSTR buf;
    pAccount
->Post(100,&buf);
    ::SysFreeString(buf);
    pAccount.Release(); 
//必须先调用,否则::CoUninitialize()会有异常
    ::CoUninitialize();
    
return 0;
}

posted on 2012-06-08 21:46 天下 阅读(413) 评论(0)  编辑 收藏 引用 所属分类: COM/ATL


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论