Running Object Table.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- #define _WIN32_DCOM
- #include <windows.h>
- #include <iostream.h>
- #include <stdio.h>
- void main()
- {
- CoInitialize(NULL);
- IRunningObjectTable* pRunningObjectTable;
- GetRunningObjectTable(NULL, &pRunningObjectTable);
- IEnumMoniker* pEnumMoniker;
- pRunningObjectTable->EnumRunning(&pEnumMoniker);
- IMoniker* pMoniker;
- IBindCtx* pBindCtx;
- OLECHAR* moniker_name;
- while(pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK)
- {
- CreateBindCtx(0, &pBindCtx);
- pMoniker->GetDisplayName(pBindCtx, NULL, &moniker_name);
- wprintf(L"DisplayName is %sn", moniker_name);
- CoTaskMemFree(moniker_name);
- DWORD mkSys;
- pMoniker->IsSystemMoniker(&mkSys);
- switch(mkSys)
- {
- case MKSYS_NONE:
- cout << "Custom moniker" << endl;
- break;
- case MKSYS_GENERICCOMPOSITE:
- cout << "Composite moniker" << endl;
- break;
- case MKSYS_FILEMONIKER:
- cout << "File moniker" << endl;
- break;
- case MKSYS_ANTIMONIKER:
- cout << "Anti moniker" << endl;
- break;
- case MKSYS_ITEMMONIKER:
- cout << "Item moniker" << endl;
- break;
- case MKSYS_POINTERMONIKER:
- cout << "Pointer moniker" << endl;
- break;
- case MKSYS_CLASSMONIKER:
- cout << "Class moniker" << endl;
- break;
- default:
- cout << "Unknown system moniker" << endl;
- }
- pMoniker->Release();
- pBindCtx->Release();
- }
- pRunningObjectTable->Release();
- pEnumMoniker->Release();
- CoUninitialize();
- }