COM, ATL

CoInitialize 역할

디버그정 2008. 7. 27. 00:06

HRESULT CoInitialize(
  LPVOID pvReserved
);

 

[개요]

COM이 초기 개발단계에서는 Single Thread Apartment(STA) 기반으로 설계가 되었다. 이런 이유로 인해서 CoInitialize 함수는 별도 쓰레드와 메모리 모델에 대한 옵션이 초기 단계에선 고려되지 않고, 다만 확장성을 위해서 LPVOID 부분을 남겨두었으나 이것 마저도 CoInitializeEx함수가 나오면서 필요가 없어졌다.

하는 역할은 COM 관련 DLL를 로딩해서 COM관련 명령어를 사용할수 있도록 해준다.

꼭 초기에 호출해주어야하는 함수다.

 

 

[Return Values]

-에러의 종류는 메모리 부분 에러(생성하는 과정),메모리 모델과 쓰레드 관련 에러,그외 기타

 

This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

S_OK

The COM library was initialized successfully on this thread.

S_FALSE

The COM library is already initialized on this thread.

RPC_E_CHANGED_MODE

A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). If running Windows 2000, this could also mean that a change from neutral-threaded apartment to single-threaded apartment occurred.

[출처] CoInitialize|작성자 푸른새