-
-
[求助]com智能指针疑问
-
发表于:
2015-10-15 16:50
3722
-
#include "stdafx.h"
#include "atlcomcli.h"
#import " C:\\Users\\Documents\\Visual Studio 2008\\Projects\\NewCom\\NewCom\\Debug\\NewCom.dll" no_namespace
int main()
{
CoInitialize(NULL);
IWinComPtr pWinCom=NULL;
pWinCom.CreateInstance(__uuidof(WinCom));
int a=pWinCom->Sqrt2(5);
printf("sum=%d.",a);
CoUninitialize();
return 0;
}
/*
int main()
{
CoInitialize(NULL);
CLSID clsid;
CLSIDFromProgID(OLESTR("NewCom.WinCom.1"),&clsid);
CComPtr<IWinCom> pIWinCom;//智能指针
pIWinCom.CoCreateInstance(clsid);
int a=pIWinCom->Sqrt2(5);
printf("sum=%d.",a);
pIWinCom.Release();
CoUninitialize();
return 0;
}
*/
上面这个main会在return 后崩溃在下面的语句
mainret = main(argc, argv, envp);
,而下面的main不会崩溃,是为何呢?
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!