那么如果在STA套间里面创建MTA对象,又如何?
看这段代码:
// TestCom.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <atlbase.h>
#include <atlcom.h>
#include "../MyCOM/MyCOM_i.h"
#include "../MyCOM/MyCOM_i.c"
#include <iostream>
#include <thread>
using namespace std;
void WorkThread()
{
CoInitialize(0);
WCHAR temp[100] = { 0 };
swprintf_s(temp, L"thread tid: %d\n", ::GetCurrentThreadId());
::OutputDebugStringW(temp);
{
CComPtr<IMyRect> spRect;
HRESULT hr = spRect.CoCreateInstance(CLSID_MyRect, NULL, CLSCTX_INPROC_SERVER);
hr = spRect->Draw(CComBSTR(L"red"));
}
CoUninitialize();
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(0);
WCHAR temp[100] = {0};
swprintf_s(te