While the examples in the OLE 2 Programmer's Reference were written in C++, the examples in this chapter were written in standard C. The following list describes some of the differences you will encounter.
For example, the CoCreateInstance function uses both a class ID reference (REFCLSID) and an interface ID reference (REFIID) as arguments. In C++, the call to this function can be written as:
CoCreateInstance(CLSID_ExcelApp, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, &pdispExcelApp);
In standard C, however, you must use the address-of operator with the first and fourth arguments:
CoCreateInstance(&CLSID_ExcelApp, NULL, CLSCTX_LOCAL_SERVER,
&IID_IDispatch, &pdispExcelApp);
For example, when you are done with an object you have created with the CoCreateInstance function, you should free it with the Release function. In C++, you can call this function directly:
pdisp->Release();
In standard C, you call the function using the lpVtbl pointer and pass in the dispatch object as the first argument:
(*(pdisp->lpVtbl->Release))(pdisp);