#include <windows.h>
#include <objbase.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
IRunningObjectTable *pROT = 0;
IEnumMoniker *pEnum = 0;
IBindCtx *pCtx = 0;
IMoniker *pMon = 0;
ULONG fetched = 0;
GetRunningObjectTable(0, &pROT);
pROT->lpVtbl->EnumRunning(pROT, &pEnum);
CreateBindCtx(0, &pCtx);
while (pEnum->lpVtbl->Next(pEnum, 1, &pMon, &fetched) == S_OK) {
LPOLESTR name = NULL;
if (SUCCEEDED(pMon->lpVtbl->GetDisplayName(pMon, pCtx, 0, &name))) {
wprintf(L"%s\n", name);
CoTaskMemFree(name);
}
pMon->lpVtbl->Release(pMon);
}
pCtx->lpVtbl->Release(pCtx);
pEnum->lpVtbl->Release(pEnum);
pROT->lpVtbl->Release(pROT);
CoUninitialize();
return 0;
}
Compile with:
cl rot_enum.c ole32.lib
What you'll actually see - on my comp the output looks like:

Top comments (0)