This is the easy step. The COM method we need is CoInitialize().
CoInitialize(0);
This function takes one parameter and that parameter is always a zero - a legacy from its origins in OLE. The CoInitialize function initializes the
COM library. You need to call this function before you do anything else. When we get into more sophisticated applications, we will be using the
extended version, CoInitializeEx.
Call CoUninitialize() when you're completely finished with COM. This function de-allocates the COM library. I often include these calls in the
InitInstance() and ExitInstance() functions of my MFC applications.
Most COM functions return an error code called an HRESULT. This error value contains several fields which define the severity, facility, and type
of error. We use the SUCCEEDED macro because there are several different success codes that COM can return. It's not safe to just check for
the normal success code (S_OK). We will discuss HRESULT's later in some detail.
0 comments:
Post a Comment