-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMyScriptSite.cpp
More file actions
53 lines (49 loc) · 1.44 KB
/
CMyScriptSite.cpp
File metadata and controls
53 lines (49 loc) · 1.44 KB
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
44
45
46
47
48
49
50
51
52
53
#include "stdafx.h"
#include "CMyScriptSite.h"
void GetScriptEngines(CSimpleArray<CString> & vv)
{
// get the component category manager for this machine
ICatInformation* pci = 0;
HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
0, CLSCTX_SERVER, IID_ICatInformation, (void**)&pci);
if (SUCCEEDED(hr))
{
CLSID catid = { 0 };
//hr = CLSIDFromString(CT2COLE(_T("{F0B7A1A2-9847-11cf-8F20-00805F2CD064}")), &catid); //CATID_ActiveScriptParser
hr = CLSIDFromString(CT2COLE(_T("{F0B7A1A1-9847-11cf-8F20-00805F2CD064}")), &catid); // CATID_ActiveScript
ATLASSERT(SUCCEEDED(hr));
// get the list of parseable script engines
CATID rgcatidImpl[1];
rgcatidImpl[0] = catid;// CATID_ActiveScriptParse;
IEnumCLSID* pec = 0;
hr = pci->EnumClassesOfCategories(1, rgcatidImpl, 0, 0,
&pec);
if (SUCCEEDED(hr))
{
// print the list of CLSIDs to the console as ProgIDs
enum { CHUNKSIZE = 16 };
CLSID rgclsid[CHUNKSIZE];
ULONG cActual;
do
{
hr = pec->Next(CHUNKSIZE, rgclsid, &cActual);
if (FAILED(hr))
break;
if (hr == S_OK)
cActual = CHUNKSIZE;
for (ULONG i = 0; i < cActual; i++)
{
OLECHAR* pwszProgID = 0;
if (SUCCEEDED(ProgIDFromCLSID(rgclsid[i], &pwszProgID)))
{
CString X = pwszProgID;
vv.Add(X);
CoTaskMemFree(pwszProgID);
}
}
} while (hr != S_FALSE);
pec->Release();
}
pci->Release();
}
}