1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #include "stdafx.h" #include "ATL1.h" #include "ATL1_i.c"
int main() { ITest * pITest; HRESULT hResult;
if (CoInitialize(NULL) != S_OK) { printf("Initialize COM library failed!n"); return -1; }
GUID ATL1CLSID; hResult = ::CLSIDFromProgID(L"ATL1.Test", &ATL1CLSID);
if (hResult != S_OK) { printf("Can't find the ATL1 CLSID!n"); return -2; }
hResult = CoCreateInstance(ATL1CLSID, NULL, CLSCTX_INPROC_SERVER, IID_ITest, (void **)&pITest); if (hResult != S_OK) { printf("Create object failed!n"); return -2; }
printf("Call ITest interface's functions...n"); double k; double *ans = &k; pITest->getArea(3, 4, 5, ans); printf("3,4,5=%.2lfn",*ans); printf("Test over...n");
pITest->Release(); CoUninitialize();
return 0; }
|