CoCreateInstance问题
#include "..\Simple_ATL\Simple_ATL.h"#include <iostream.h>// Copy the following from the Simple_ATL_i.c file// from the Simple_ATL project directoryconst IID IID_IFirst_ATL = {0x8958F781,0xC2B1,0x497B,{0x8C,0x46,0x48,0x30,0xE3,0x8A,0xDA,0x71}};const CLSID CLSID_First_ATL = {0x146EC893,0xDA14,0x41BC,{0xAF,0x12,0x19,0xB7,0x6B,0x61,0xCE,0x23}};void main(void){ // Declare and HRESULT and a pointer to the Simple_ATL interface HRESULT hr=S_FALSE; IFirst_ATL *IFirstATL=NULL; // Now we will intilize COM hr = CoInitialize(0); // Use the SUCCEEDED macro and see if we can get a pointer // to the interface if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER, IID_IFirst_ATL, (void**)&IFirstATL); cout<<GetLastError()<<endl; // If we succeeded then call the AddNumbers method, if it failed // then display an appropriate message to the user. if(SUCCEEDED(hr)) { long ReturnValue; IFirstATL->AddNumbers(5, 7, &ReturnValue); cout << "The answer for 5 + 7 is: " << ReturnValue << endl; IFirstATL->Release(); } else { cout << "CoCreateInstance Failed." << endl; } } // Uninitialize COM CoUninitialize();}