2006-06-14 19:52:26 +02:00
|
|
|
/*
|
|
|
|
* OleView (tree.c)
|
|
|
|
*
|
|
|
|
* Copyright 2006 Piotr Caban
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2007-05-04 12:08:15 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-06-14 19:52:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
TREE tree;
|
|
|
|
static const WCHAR wszCLSID[] = { 'C','L','S','I','D','\\','\0' };
|
2006-06-14 20:09:12 +02:00
|
|
|
static const WCHAR wszInProcServer32[] =
|
|
|
|
{ 'I','n','P','r','o','c','S','e','r','v','e','r','3','2','\0' };
|
|
|
|
static const WCHAR wszOle32dll[] = { 'o','l','e','3','2','.','d','l','l','\0' };
|
|
|
|
static const WCHAR wszOleAut32dll[] =
|
|
|
|
{ 'o','l','e','a','u','t','3','2','.','d','l','l','\0' };
|
|
|
|
static const WCHAR wszImplementedCategories[] =
|
|
|
|
{ 'I','m','p','l','e','m','e','n','t','e','d',' ',
|
|
|
|
'C','a','t','e','g','o','r','i','e','s','\0' };
|
2006-06-14 19:52:26 +02:00
|
|
|
static const WCHAR wszAppID[] = { 'A','p','p','I','D','\\','\0' };
|
|
|
|
static const WCHAR wszTypeLib[] = { 'T','y','p','e','L','i','b','\\','\0' };
|
|
|
|
static const WCHAR wszInterface[] = { 'I','n','t','e','r','f','a','c','e','\\','\0' };
|
|
|
|
static const WCHAR wszComponentCategories[] = { 'C','o','m','p','o','n','e','n','t',
|
|
|
|
' ','C','a','t','e','g','o','r','i','e','s','\\','\0' };
|
2006-06-30 17:29:56 +02:00
|
|
|
static const WCHAR wszGetPath[] = { '0','\\','w','i','n','3','2','\0' };
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static LPARAM CreateITEM_INFO(INT flag, const WCHAR *info, const WCHAR *clsid, const WCHAR *path)
|
2006-06-14 19:52:26 +02:00
|
|
|
{
|
|
|
|
ITEM_INFO *reg;
|
|
|
|
|
2007-04-25 00:57:55 +02:00
|
|
|
reg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ITEM_INFO));
|
2006-06-14 19:52:26 +02:00
|
|
|
|
|
|
|
reg->cFlag = flag;
|
2006-06-22 11:43:02 +02:00
|
|
|
lstrcpyW(reg->info, info);
|
|
|
|
if(clsid) lstrcpyW(reg->clsid, clsid);
|
2006-06-30 17:29:56 +02:00
|
|
|
if(path) lstrcpyW(reg->path, path);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
|
|
|
return (LPARAM)reg;
|
|
|
|
}
|
|
|
|
|
2006-06-22 19:58:37 +02:00
|
|
|
void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
|
2006-06-14 19:53:47 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVITEMW tvi;
|
2006-06-14 19:53:47 +02:00
|
|
|
HTREEITEM hCur;
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-14 19:53:47 +02:00
|
|
|
WCHAR wszTitle[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszMessage[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszFlagName[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszTreeName[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszRegPath[MAX_LOAD_STRING];
|
|
|
|
const WCHAR wszFormat[] = { '\n','%','s',' ','(','$','%','x',')','\n','\0' };
|
|
|
|
CLSID clsid;
|
2006-06-22 19:58:37 +02:00
|
|
|
COSERVERINFO remoteInfo;
|
|
|
|
MULTI_QI qi;
|
2006-06-14 19:53:47 +02:00
|
|
|
IUnknown *obj, *unk;
|
|
|
|
HRESULT hRes;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&tvi, 0, sizeof(TVITEMW));
|
2006-06-14 19:53:47 +02:00
|
|
|
tvi.mask = TVIF_TEXT;
|
|
|
|
tvi.hItem = item;
|
|
|
|
tvi.cchTextMax = MAX_LOAD_STRING;
|
|
|
|
tvi.pszText = wszTreeName;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&tvis, 0, sizeof(TVINSERTSTRUCTW));
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = tvi.pszText;
|
2006-06-14 19:53:47 +02:00
|
|
|
tvis.hParent = item;
|
|
|
|
tvis.hInsertAfter = TVI_LAST;
|
|
|
|
|
2015-10-07 12:27:49 +02:00
|
|
|
if (!SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi)) return;
|
2006-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
if(!tvi.lParam || ((ITEM_INFO *)tvi.lParam)->loaded
|
|
|
|
|| !(((ITEM_INFO *)tvi.lParam)->cFlag&SHOWALL)) return;
|
|
|
|
|
|
|
|
if(FAILED(CLSIDFromString(((ITEM_INFO *)tvi.lParam)->clsid, &clsid))) return;
|
|
|
|
|
2006-06-22 19:58:37 +02:00
|
|
|
if(wszMachineName)
|
|
|
|
{
|
|
|
|
remoteInfo.dwReserved1 = 0;
|
|
|
|
remoteInfo.dwReserved2 = 0;
|
|
|
|
remoteInfo.pAuthInfo = NULL;
|
|
|
|
remoteInfo.pwszName = wszMachineName;
|
|
|
|
|
|
|
|
qi.pIID = &IID_IUnknown;
|
|
|
|
|
|
|
|
CoCreateInstanceEx(&clsid, NULL, globals.dwClsCtx|CLSCTX_REMOTE_SERVER,
|
|
|
|
&remoteInfo, 1, &qi);
|
|
|
|
hRes = qi.hr;
|
|
|
|
obj = qi.pItf;
|
|
|
|
}
|
|
|
|
else hRes = CoCreateInstance(&clsid, NULL, globals.dwClsCtx,
|
2006-06-14 19:53:47 +02:00
|
|
|
&IID_IUnknown, (void **)&obj);
|
|
|
|
|
|
|
|
if(FAILED(hRes))
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_CGCOFAIL, wszMessage,
|
2008-09-13 22:19:20 +02:00
|
|
|
sizeof(wszMessage)/sizeof(wszMessage[0]));
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_ABOUT, wszTitle,
|
2008-09-13 22:19:20 +02:00
|
|
|
sizeof(wszTitle)/sizeof(wszTitle[0]));
|
2006-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
#define CASE_ERR(i) case i: \
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, #i, -1, wszFlagName, MAX_LOAD_STRING); \
|
|
|
|
break
|
|
|
|
|
|
|
|
switch(hRes)
|
|
|
|
{
|
|
|
|
CASE_ERR(REGDB_E_CLASSNOTREG);
|
|
|
|
CASE_ERR(E_NOINTERFACE);
|
|
|
|
CASE_ERR(REGDB_E_READREGDB);
|
|
|
|
CASE_ERR(REGDB_E_KEYMISSING);
|
|
|
|
CASE_ERR(CO_E_DLLNOTFOUND);
|
|
|
|
CASE_ERR(CO_E_APPNOTFOUND);
|
|
|
|
CASE_ERR(E_ACCESSDENIED);
|
|
|
|
CASE_ERR(CO_E_ERRORINDLL);
|
|
|
|
CASE_ERR(CO_E_APPDIDNTREG);
|
|
|
|
CASE_ERR(CLASS_E_CLASSNOTAVAILABLE);
|
|
|
|
default:
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, sizeof(wszFlagName)/sizeof(wszFlagName[0]));
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
|
|
|
|
2006-06-22 11:43:02 +02:00
|
|
|
wsprintfW(&wszMessage[lstrlenW(wszMessage)], wszFormat,
|
2006-06-14 19:53:47 +02:00
|
|
|
wszFlagName, (unsigned)hRes);
|
2010-05-07 10:45:45 +02:00
|
|
|
MessageBoxW(globals.hMainWnd, wszMessage, wszTitle, MB_OK|MB_ICONEXCLAMATION);
|
2006-06-14 19:53:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
((ITEM_INFO *)tvi.lParam)->loaded = 1;
|
|
|
|
((ITEM_INFO *)tvi.lParam)->pU = obj;
|
|
|
|
|
|
|
|
tvi.mask = TVIF_STATE;
|
|
|
|
tvi.state = TVIS_BOLD;
|
|
|
|
tvi.stateMask = TVIS_BOLD;
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SETITEMW, 0, (LPARAM)&tvi);
|
2006-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
tvi.mask = TVIF_TEXT;
|
2010-05-07 10:45:29 +02:00
|
|
|
hCur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_CHILD, (LPARAM)tree.hI);
|
2006-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
while(hCur)
|
|
|
|
{
|
|
|
|
tvi.hItem = hCur;
|
2015-10-07 12:27:49 +02:00
|
|
|
if(!SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi) || !tvi.lParam)
|
2006-06-14 19:53:47 +02:00
|
|
|
{
|
2010-05-07 10:45:29 +02:00
|
|
|
hCur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_NEXT, (LPARAM)hCur);
|
2006-06-14 19:53:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLSIDFromString(((ITEM_INFO *)tvi.lParam)->clsid, &clsid);
|
|
|
|
hRes = IUnknown_QueryInterface(obj, &clsid, (void *)&unk);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hRes))
|
|
|
|
{
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
2006-06-22 11:43:02 +02:00
|
|
|
lstrcpyW(wszRegPath, wszInterface);
|
|
|
|
lstrcpyW(&wszRegPath[lstrlenW(wszRegPath)], ((ITEM_INFO *)tvi.lParam)->clsid);
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|INTERFACE|REGPATH,
|
2006-06-30 17:29:56 +02:00
|
|
|
wszRegPath, ((ITEM_INFO *)tvi.lParam)->clsid, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
2010-05-07 10:45:29 +02:00
|
|
|
hCur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_NEXT, (LPARAM)hCur);
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
2006-06-14 19:55:08 +02:00
|
|
|
|
|
|
|
RefreshMenu(item);
|
2006-06-14 19:55:46 +02:00
|
|
|
RefreshDetails(item);
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReleaseInst(HTREEITEM item)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVITEMW tvi;
|
2006-06-14 19:53:47 +02:00
|
|
|
HTREEITEM cur;
|
|
|
|
IUnknown *pU;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&tvi, 0, sizeof(TVITEMW));
|
2006-06-14 19:53:47 +02:00
|
|
|
tvi.hItem = item;
|
2015-10-07 12:27:49 +02:00
|
|
|
if(!SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi) || !tvi.lParam) return;
|
2006-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
pU = ((ITEM_INFO *)tvi.lParam)->pU;
|
|
|
|
|
|
|
|
if(pU) IUnknown_Release(pU);
|
|
|
|
((ITEM_INFO *)tvi.lParam)->loaded = 0;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_EXPAND, TVE_COLLAPSE, (LPARAM)item);
|
2006-06-14 19:53:47 +02:00
|
|
|
|
2010-05-07 10:45:29 +02:00
|
|
|
cur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_CHILD, (LPARAM)item);
|
2006-06-14 19:53:47 +02:00
|
|
|
while(cur)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)cur);
|
2010-05-07 10:45:29 +02:00
|
|
|
cur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_CHILD, (LPARAM)item);
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tvi.mask = TVIF_CHILDREN|TVIF_STATE;
|
|
|
|
tvi.state = 0;
|
|
|
|
tvi.stateMask = TVIS_BOLD;
|
|
|
|
tvi.cChildren = 1;
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SETITEMW, 0, (LPARAM)&tvi);
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
|
|
|
|
2006-06-14 20:09:12 +02:00
|
|
|
BOOL CreateRegPath(HTREEITEM item, WCHAR *buffer, int bufSize)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVITEMW tvi;
|
2006-06-14 20:09:12 +02:00
|
|
|
int bufLen;
|
2015-10-07 12:27:49 +02:00
|
|
|
BOOL ret = FALSE;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2014-03-25 11:27:12 +01:00
|
|
|
memset(buffer, 0, bufSize * sizeof(WCHAR));
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&tvi, 0, sizeof(TVITEMW));
|
2006-06-14 20:09:12 +02:00
|
|
|
tvi.hItem = item;
|
|
|
|
|
2015-10-07 12:27:49 +02:00
|
|
|
if (SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi))
|
|
|
|
ret = (tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag & REGPATH);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
2015-10-07 12:27:49 +02:00
|
|
|
if(!SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi)) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
if(tvi.lParam && (((ITEM_INFO *)tvi.lParam)->cFlag & (REGPATH|REGTOP)))
|
|
|
|
{
|
2006-06-22 11:43:02 +02:00
|
|
|
bufLen = lstrlenW(((ITEM_INFO *)tvi.lParam)->info);
|
2014-03-25 11:27:12 +01:00
|
|
|
memmove(&buffer[bufLen], buffer, (bufSize - bufLen) * sizeof(WCHAR));
|
|
|
|
memcpy(buffer, ((ITEM_INFO *)tvi.lParam)->info, bufLen * sizeof(WCHAR));
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag & REGTOP) break;
|
|
|
|
|
|
|
|
if(!tvi.lParam) return FALSE;
|
|
|
|
|
2010-05-07 10:45:29 +02:00
|
|
|
tvi.hItem = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
|
|
|
|
TVGN_PARENT, (LPARAM)tvi.hItem);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddCOMandAll(void)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
|
|
|
TVITEMW tvi;
|
2006-06-14 20:09:12 +02:00
|
|
|
HTREEITEM curSearch;
|
|
|
|
HKEY hKey, hCurKey, hInfo;
|
|
|
|
WCHAR valName[MAX_LOAD_STRING];
|
|
|
|
WCHAR buffer[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszComp[MAX_LOAD_STRING];
|
|
|
|
LONG lenBuffer;
|
|
|
|
int i=-1;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&tvi, 0, sizeof(TVITEMW));
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_CHILDREN;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
|
|
|
U(tvis).item.cChildren = 1;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(HKEY_CLASSES_ROOT, wszCLSID, &hKey) != ERROR_SUCCESS) return;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
tvis.hParent = tree.hAO;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hCurKey, wszInProcServer32, &hInfo) == ERROR_SUCCESS)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hInfo, NULL, buffer, &lenBuffer) == ERROR_SUCCESS
|
2006-06-14 20:09:12 +02:00
|
|
|
&& *buffer)
|
|
|
|
if(!memcmp(buffer, wszOle32dll, sizeof(WCHAR[9]))
|
|
|
|
||!memcmp(buffer, wszOleAut32dll, sizeof(WCHAR[12])))
|
|
|
|
tvis.hParent = tree.hCLO;
|
|
|
|
|
|
|
|
RegCloseKey(hInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
|
|
|
else U(tvis).item.pszText = valName;
|
2010-05-07 10:45:45 +02:00
|
|
|
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGPATH|SHOWALL, valName, valName, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
if(tvis.hParent) SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hCurKey, wszImplementedCategories, &hInfo) == ERROR_SUCCESS)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hInfo, 0, wszComp, sizeof(wszComp)/sizeof(wszComp[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
RegCloseKey(hInfo);
|
|
|
|
|
2010-05-07 10:45:29 +02:00
|
|
|
if(tree.hGBCC) curSearch = (HTREEITEM)SendMessageW(globals.hTree,
|
|
|
|
TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)tree.hGBCC);
|
|
|
|
else curSearch = (HTREEITEM)SendMessageW(globals.hTree,
|
|
|
|
TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(curSearch)
|
|
|
|
{
|
|
|
|
tvi.hItem = curSearch;
|
2015-10-07 12:27:49 +02:00
|
|
|
if(!SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi)) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2006-06-22 11:43:02 +02:00
|
|
|
if(tvi.lParam && !lstrcmpW(((ITEM_INFO *)tvi.lParam)->info, wszComp))
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
|
|
|
tvis.hParent = curSearch;
|
|
|
|
|
|
|
|
memmove(&valName[6], valName, sizeof(WCHAR[MAX_LOAD_STRING-6]));
|
|
|
|
memmove(valName, wszCLSID, sizeof(WCHAR[6]));
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH|SHOWALL,
|
2006-06-30 17:29:56 +02:00
|
|
|
valName, &valName[6], NULL);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-05-07 10:45:29 +02:00
|
|
|
curSearch = (HTREEITEM)SendMessageW(globals.hTree,
|
|
|
|
TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)curSearch);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hCurKey);
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hCLO);
|
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hAO);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddApplicationID(void)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-14 20:09:12 +02:00
|
|
|
HKEY hKey, hCurKey;
|
|
|
|
WCHAR valName[MAX_LOAD_STRING];
|
|
|
|
WCHAR buffer[MAX_LOAD_STRING];
|
|
|
|
LONG lenBuffer;
|
|
|
|
int i=-1;
|
|
|
|
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 20:09:12 +02:00
|
|
|
tvis.hParent = tree.hAID;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(HKEY_CLASSES_ROOT, wszAppID, &hKey) != ERROR_SUCCESS) return;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
|
|
|
else U(tvis).item.pszText = valName;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
RegCloseKey(hCurKey);
|
|
|
|
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGPATH, valName, valName, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hAID);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddTypeLib(void)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-30 17:29:56 +02:00
|
|
|
HKEY hKey, hCurKey, hInfoKey, hPath;
|
2006-06-14 20:09:12 +02:00
|
|
|
WCHAR valName[MAX_LOAD_STRING];
|
|
|
|
WCHAR valParent[MAX_LOAD_STRING];
|
|
|
|
WCHAR buffer[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszVer[MAX_LOAD_STRING];
|
2006-06-30 17:29:56 +02:00
|
|
|
WCHAR wszPath[MAX_LOAD_STRING];
|
2006-06-14 20:09:12 +02:00
|
|
|
const WCHAR wszFormat[] = { ' ','(','%','s',' ','%','s',')','\0' };
|
|
|
|
const WCHAR wszFormat2[] = { '%','s','\\','%','s','\0' };
|
|
|
|
LONG lenBuffer;
|
|
|
|
int i=-1, j;
|
|
|
|
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 20:09:12 +02:00
|
|
|
tvis.hParent = tree.hTL;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(HKEY_CLASSES_ROOT, wszTypeLib, &hKey) != ERROR_SUCCESS) return;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hKey, i, valParent, sizeof(valParent)/sizeof(valParent[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hKey, valParent, &hCurKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
j = -1;
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
j++;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hCurKey, j, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hCurKey, valName, &hInfoKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hInfoKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS
|
2006-06-14 20:09:12 +02:00
|
|
|
&& *buffer)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TL_VER, wszVer,
|
2008-09-13 22:19:20 +02:00
|
|
|
sizeof(wszVer)/sizeof(wszVer[0]));
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2006-06-22 11:43:02 +02:00
|
|
|
wsprintfW(&buffer[lstrlenW(buffer)], wszFormat, wszVer, valName);
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
2006-06-30 17:29:56 +02:00
|
|
|
|
|
|
|
lenBuffer = MAX_LOAD_STRING;
|
2010-05-07 10:45:45 +02:00
|
|
|
RegOpenKeyW(hInfoKey, wszGetPath, &hPath);
|
|
|
|
RegQueryValueW(hPath, NULL, wszPath, &lenBuffer);
|
2006-06-30 17:29:56 +02:00
|
|
|
RegCloseKey(hPath);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
2006-06-24 13:19:12 +02:00
|
|
|
else U(tvis).item.pszText = valName;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
RegCloseKey(hInfoKey);
|
|
|
|
|
|
|
|
wsprintfW(wszVer, wszFormat2, valParent, valName);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGPATH, wszVer, valParent, wszPath);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(hCurKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hTL);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddInterfaces(void)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-14 20:09:12 +02:00
|
|
|
HKEY hKey, hCurKey;
|
|
|
|
WCHAR valName[MAX_LOAD_STRING];
|
|
|
|
WCHAR buffer[MAX_LOAD_STRING];
|
|
|
|
LONG lenBuffer;
|
|
|
|
int i=-1;
|
|
|
|
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 20:09:12 +02:00
|
|
|
tvis.hParent = tree.hI;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(HKEY_CLASSES_ROOT, wszInterface, &hKey) != ERROR_SUCCESS) return;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
|
|
|
else U(tvis).item.pszText = valName;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
RegCloseKey(hCurKey);
|
|
|
|
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGPATH|INTERFACE, valName, valName, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hI);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddComponentCategories(void)
|
2006-06-14 20:09:12 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-14 20:09:12 +02:00
|
|
|
HKEY hKey, hCurKey;
|
2015-06-30 14:38:05 +02:00
|
|
|
WCHAR keyName[MAX_LOAD_STRING];
|
2006-06-14 20:09:12 +02:00
|
|
|
WCHAR valName[MAX_LOAD_STRING];
|
|
|
|
WCHAR buffer[MAX_LOAD_STRING];
|
|
|
|
LONG lenBuffer;
|
|
|
|
DWORD lenBufferHlp;
|
2015-06-30 14:38:05 +02:00
|
|
|
DWORD lenValName;
|
2006-06-14 20:09:12 +02:00
|
|
|
int i=-1;
|
|
|
|
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_CHILDREN;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 20:09:12 +02:00
|
|
|
if(tree.hGBCC) tvis.hParent = tree.hGBCC;
|
|
|
|
else tvis.hParent = TVI_ROOT;
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.cChildren = 1;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegOpenKeyW(HKEY_CLASSES_ROOT, wszComponentCategories, &hKey) != ERROR_SUCCESS)
|
2006-06-14 20:09:12 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2015-06-30 14:38:05 +02:00
|
|
|
if(RegEnumKeyW(hKey, i, keyName, sizeof(keyName)/sizeof(keyName[0])) != ERROR_SUCCESS) break;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2015-06-30 14:38:05 +02:00
|
|
|
if(RegOpenKeyW(hKey, keyName, &hCurKey) != ERROR_SUCCESS) continue;
|
2006-06-14 20:09:12 +02:00
|
|
|
|
|
|
|
lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
|
|
|
|
lenBufferHlp = sizeof(WCHAR[MAX_LOAD_STRING]);
|
2015-06-30 14:38:05 +02:00
|
|
|
lenValName = sizeof(WCHAR[MAX_LOAD_STRING]);
|
2006-06-14 20:09:12 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(RegQueryValueW(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
2015-06-30 14:38:05 +02:00
|
|
|
else if(RegEnumValueW(hCurKey, 0, valName, &lenValName, NULL, NULL,
|
2006-06-14 20:09:12 +02:00
|
|
|
(LPBYTE)buffer, &lenBufferHlp) == ERROR_SUCCESS && *buffer)
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = buffer;
|
2006-06-14 20:09:12 +02:00
|
|
|
else continue;
|
|
|
|
|
|
|
|
RegCloseKey(hCurKey);
|
|
|
|
|
2015-06-30 14:38:05 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, keyName, keyName, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hGBCC);
|
2006-06-14 20:09:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void AddBaseEntries(void)
|
2006-06-14 19:52:26 +02:00
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
TVINSERTSTRUCTW tvis;
|
2006-06-14 19:52:26 +02:00
|
|
|
WCHAR name[MAX_LOAD_STRING];
|
|
|
|
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM;
|
2006-06-14 19:52:26 +02:00
|
|
|
/* FIXME add TVIF_IMAGE */
|
2006-06-24 13:19:12 +02:00
|
|
|
U(tvis).item.pszText = name;
|
|
|
|
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
|
|
|
|
U(tvis).item.cChildren = 1;
|
2009-01-20 11:21:34 +01:00
|
|
|
tvis.hInsertAfter = TVI_FIRST;
|
2006-06-14 19:52:26 +02:00
|
|
|
tvis.hParent = TVI_ROOT;
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_I, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszInterface, NULL, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hI = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_TL, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszTypeLib, NULL, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hTL = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_AID, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH, wszAppID, NULL, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hAID = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_OC, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2008-11-02 00:26:07 +01:00
|
|
|
U(tvis).item.lParam = 0;
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hOC = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
tvis.hParent = tree.hOC;
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_AO, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszCLSID, NULL, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hAO = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_CLO, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hCLO = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_O1O, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2008-11-02 00:26:07 +01:00
|
|
|
U(tvis).item.lParam = 0;
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hO1O = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
LoadStringW(globals.hMainInst, IDS_TREE_GBCC, U(tvis).item.pszText,
|
2008-09-13 22:19:20 +02:00
|
|
|
MAX_LOAD_STRING);
|
2006-06-30 17:29:56 +02:00
|
|
|
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH,
|
|
|
|
wszComponentCategories, NULL, NULL);
|
2010-05-07 10:45:45 +02:00
|
|
|
tree.hGBCC = TreeView_InsertItemW(globals.hTree, &tvis);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)tree.hOC);
|
2006-06-14 19:52:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EmptyTree(void)
|
|
|
|
{
|
2017-02-05 23:28:01 +01:00
|
|
|
SendMessageW(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
|
2006-06-14 19:52:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddTreeEx(void)
|
|
|
|
{
|
|
|
|
AddBaseEntries();
|
2006-06-14 20:09:12 +02:00
|
|
|
AddComponentCategories();
|
|
|
|
AddCOMandAll();
|
|
|
|
AddApplicationID();
|
|
|
|
AddTypeLib();
|
|
|
|
AddInterfaces();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddTree(void)
|
|
|
|
{
|
|
|
|
memset(&tree, 0, sizeof(TREE));
|
|
|
|
AddComponentCategories();
|
|
|
|
AddCOMandAll();
|
2006-06-14 19:52:26 +02:00
|
|
|
}
|
|
|
|
|
2009-01-07 12:23:42 +01:00
|
|
|
static LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2006-06-14 19:52:26 +02:00
|
|
|
{
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2010-05-07 10:45:45 +02:00
|
|
|
globals.hTree = CreateWindowW(WC_TREEVIEWW, NULL,
|
2006-06-14 19:52:26 +02:00
|
|
|
WS_CHILD|WS_VISIBLE|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT,
|
|
|
|
0, 0, 0, 0, hWnd, (HMENU)TREE_WINDOW, globals.hMainInst, NULL);
|
|
|
|
AddTreeEx();
|
|
|
|
break;
|
2006-06-14 19:53:47 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
if((int)wParam != TREE_WINDOW) break;
|
|
|
|
switch(((LPNMHDR)lParam)->code)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
case TVN_ITEMEXPANDINGW:
|
|
|
|
CreateInst(((NMTREEVIEWW *)lParam)->itemNew.hItem, NULL);
|
2006-06-14 19:53:47 +02:00
|
|
|
break;
|
2010-05-07 10:45:45 +02:00
|
|
|
case TVN_SELCHANGEDW:
|
|
|
|
RefreshMenu(((NMTREEVIEWW *)lParam)->itemNew.hItem);
|
|
|
|
RefreshDetails(((NMTREEVIEWW *)lParam)->itemNew.hItem);
|
2006-06-14 19:55:08 +02:00
|
|
|
break;
|
2017-02-05 23:28:01 +01:00
|
|
|
case TVN_DELETEITEMW:
|
|
|
|
{
|
|
|
|
NMTREEVIEWW *nm = (NMTREEVIEWW*)lParam;
|
|
|
|
ITEM_INFO *info = (ITEM_INFO*)nm->itemOld.lParam;
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
if (info->loaded)
|
|
|
|
ReleaseInst(nm->itemOld.hItem);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-06-14 19:53:47 +02:00
|
|
|
}
|
|
|
|
break;
|
2006-06-14 19:52:26 +02:00
|
|
|
case WM_SIZE:
|
|
|
|
MoveWindow(globals.hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
|
|
|
|
break;
|
|
|
|
default:
|
2010-05-07 10:45:45 +02:00
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2006-06-14 19:52:26 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND CreateTreeWindow(HINSTANCE hInst)
|
|
|
|
{
|
2010-05-07 10:45:45 +02:00
|
|
|
WNDCLASSW wct;
|
2006-06-14 19:52:26 +02:00
|
|
|
const WCHAR wszTreeClass[] = { 'T','R','E','E','\0' };
|
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
memset(&wct, 0, sizeof(WNDCLASSW));
|
2006-06-14 19:52:26 +02:00
|
|
|
wct.lpfnWndProc = TreeProc;
|
|
|
|
wct.lpszClassName = wszTreeClass;
|
2015-10-07 12:27:30 +02:00
|
|
|
wct.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
|
|
wct.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
if(!RegisterClassW(&wct)) return NULL;
|
2006-06-14 19:52:26 +02:00
|
|
|
|
2010-05-07 10:45:45 +02:00
|
|
|
return CreateWindowExW(WS_EX_CLIENTEDGE, wszTreeClass, NULL, WS_CHILD|WS_VISIBLE,
|
2006-06-14 19:52:26 +02:00
|
|
|
0, 0, 0, 0, globals.hPaneWnd, NULL, hInst, NULL);
|
|
|
|
}
|