4 * Copyright 2006 Piotr Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 static const WCHAR wszCLSID[] = { 'C','L','S','I','D','\\','\0' };
25 static const WCHAR wszInProcServer32[] =
26 { 'I','n','P','r','o','c','S','e','r','v','e','r','3','2','\0' };
27 static const WCHAR wszOle32dll[] = { 'o','l','e','3','2','.','d','l','l','\0' };
28 static const WCHAR wszOleAut32dll[] =
29 { 'o','l','e','a','u','t','3','2','.','d','l','l','\0' };
30 static const WCHAR wszImplementedCategories[] =
31 { 'I','m','p','l','e','m','e','n','t','e','d',' ',
32 'C','a','t','e','g','o','r','i','e','s','\0' };
33 static const WCHAR wszAppID[] = { 'A','p','p','I','D','\\','\0' };
34 static const WCHAR wszTypeLib[] = { 'T','y','p','e','L','i','b','\\','\0' };
35 static const WCHAR wszInterface[] = { 'I','n','t','e','r','f','a','c','e','\\','\0' };
36 static const WCHAR wszComponentCategories[] = { 'C','o','m','p','o','n','e','n','t',
37 ' ','C','a','t','e','g','o','r','i','e','s','\\','\0' };
38 static const WCHAR wszGetPath[] = { '0','\\','w','i','n','3','2','\0' };
40 LPARAM CreateITEM_INFO(INT flag, const WCHAR *info, const WCHAR *clsid, const WCHAR *path)
44 reg = HeapAlloc(GetProcessHeap(), 0, sizeof(ITEM_INFO));
45 memset(reg, 0, sizeof(ITEM_INFO));
48 lstrcpyW(reg->info, info);
49 if(clsid) lstrcpyW(reg->clsid, clsid);
50 if(path) lstrcpyW(reg->path, path);
55 void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
60 WCHAR wszTitle[MAX_LOAD_STRING];
61 WCHAR wszMessage[MAX_LOAD_STRING];
62 WCHAR wszFlagName[MAX_LOAD_STRING];
63 WCHAR wszTreeName[MAX_LOAD_STRING];
64 WCHAR wszRegPath[MAX_LOAD_STRING];
65 const WCHAR wszFormat[] = { '\n','%','s',' ','(','$','%','x',')','\n','\0' };
67 COSERVERINFO remoteInfo;
72 memset(&tvi, 0, sizeof(TVITEM));
75 tvi.cchTextMax = MAX_LOAD_STRING;
76 tvi.pszText = wszTreeName;
78 memset(&tvis, 0, sizeof(TVINSERTSTRUCT));
79 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
80 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
81 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
82 U(tvis).item.pszText = tvi.pszText;
84 tvis.hInsertAfter = TVI_LAST;
86 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
88 if(!tvi.lParam || ((ITEM_INFO *)tvi.lParam)->loaded
89 || !(((ITEM_INFO *)tvi.lParam)->cFlag&SHOWALL)) return;
91 if(FAILED(CLSIDFromString(((ITEM_INFO *)tvi.lParam)->clsid, &clsid))) return;
95 remoteInfo.dwReserved1 = 0;
96 remoteInfo.dwReserved2 = 0;
97 remoteInfo.pAuthInfo = NULL;
98 remoteInfo.pwszName = wszMachineName;
100 qi.pIID = &IID_IUnknown;
102 CoCreateInstanceEx(&clsid, NULL, globals.dwClsCtx|CLSCTX_REMOTE_SERVER,
103 &remoteInfo, 1, &qi);
107 else hRes = CoCreateInstance(&clsid, NULL, globals.dwClsCtx,
108 &IID_IUnknown, (void **)&obj);
112 LoadString(globals.hMainInst, IDS_CGCOFAIL, wszMessage,
113 sizeof(WCHAR[MAX_LOAD_STRING]));
114 LoadString(globals.hMainInst, IDS_ABOUT, wszTitle,
115 sizeof(WCHAR[MAX_LOAD_STRING]));
117 #define CASE_ERR(i) case i: \
118 MultiByteToWideChar(CP_ACP, 0, #i, -1, wszFlagName, MAX_LOAD_STRING); \
123 CASE_ERR(REGDB_E_CLASSNOTREG);
124 CASE_ERR(E_NOINTERFACE);
125 CASE_ERR(REGDB_E_READREGDB);
126 CASE_ERR(REGDB_E_KEYMISSING);
127 CASE_ERR(CO_E_DLLNOTFOUND);
128 CASE_ERR(CO_E_APPNOTFOUND);
129 CASE_ERR(E_ACCESSDENIED);
130 CASE_ERR(CO_E_ERRORINDLL);
131 CASE_ERR(CO_E_APPDIDNTREG);
132 CASE_ERR(CLASS_E_CLASSNOTAVAILABLE);
134 LoadString(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, MAX_LOAD_STRING);
137 wsprintfW(&wszMessage[lstrlenW(wszMessage)], wszFormat,
138 wszFlagName, (unsigned)hRes);
139 MessageBox(globals.hMainWnd, wszMessage, wszTitle, MB_OK|MB_ICONEXCLAMATION);
143 ((ITEM_INFO *)tvi.lParam)->loaded = 1;
144 ((ITEM_INFO *)tvi.lParam)->pU = obj;
146 tvi.mask = TVIF_STATE;
147 tvi.state = TVIS_BOLD;
148 tvi.stateMask = TVIS_BOLD;
149 SendMessage(globals.hTree, TVM_SETITEM, 0, (LPARAM)&tvi);
151 tvi.mask = TVIF_TEXT;
152 hCur = TreeView_GetChild(globals.hTree, tree.hI);
157 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
161 hCur = TreeView_GetNextSibling(globals.hTree, hCur);
165 CLSIDFromString(((ITEM_INFO *)tvi.lParam)->clsid, &clsid);
166 hRes = IUnknown_QueryInterface(obj, &clsid, (void *)&unk);
170 IUnknown_Release(unk);
172 lstrcpyW(wszRegPath, wszInterface);
173 lstrcpyW(&wszRegPath[lstrlenW(wszRegPath)], ((ITEM_INFO *)tvi.lParam)->clsid);
174 U(tvis).item.lParam = CreateITEM_INFO(REGTOP|INTERFACE|REGPATH,
175 wszRegPath, ((ITEM_INFO *)tvi.lParam)->clsid, NULL);
176 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
178 hCur = TreeView_GetNextSibling(globals.hTree, hCur);
182 RefreshDetails(item);
185 void ReleaseInst(HTREEITEM item)
191 memset(&tvi, 0, sizeof(TVITEM));
193 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
195 if(!tvi.lParam) return;
197 pU = ((ITEM_INFO *)tvi.lParam)->pU;
199 if(pU) IUnknown_Release(pU);
200 ((ITEM_INFO *)tvi.lParam)->loaded = 0;
202 SendMessage(globals.hTree, TVM_EXPAND, TVE_COLLAPSE, (LPARAM)item);
204 cur = TreeView_GetChild(globals.hTree, item);
207 SendMessage(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)cur);
208 cur = TreeView_GetChild(globals.hTree, item);
211 tvi.mask = TVIF_CHILDREN|TVIF_STATE;
213 tvi.stateMask = TVIS_BOLD;
215 SendMessage(globals.hTree, TVM_SETITEM, 0, (LPARAM)&tvi);
218 BOOL CreateRegPath(HTREEITEM item, WCHAR *buffer, int bufSize)
224 memset(buffer, 0, sizeof(WCHAR[bufSize]));
225 memset(&tvi, 0, sizeof(TVITEM));
228 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
229 ret = (tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag & REGPATH);
233 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
235 if(tvi.lParam && (((ITEM_INFO *)tvi.lParam)->cFlag & (REGPATH|REGTOP)))
237 bufLen = lstrlenW(((ITEM_INFO *)tvi.lParam)->info);
238 memmove(&buffer[bufLen], buffer, sizeof(WCHAR[bufSize-bufLen]));
239 memcpy(buffer, ((ITEM_INFO *)tvi.lParam)->info, sizeof(WCHAR[bufLen]));
242 if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag & REGTOP) break;
244 if(!tvi.lParam) return FALSE;
246 tvi.hItem = TreeView_GetParent(globals.hTree, tvi.hItem);
251 void AddCOMandAll(void)
256 HKEY hKey, hCurKey, hInfo;
257 WCHAR valName[MAX_LOAD_STRING];
258 WCHAR buffer[MAX_LOAD_STRING];
259 WCHAR wszComp[MAX_LOAD_STRING];
263 memset(&tvi, 0, sizeof(TVITEM));
264 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_CHILDREN;
265 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
266 U(tvis).item.cChildren = 1;
267 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
269 if(RegOpenKey(HKEY_CLASSES_ROOT, wszCLSID, &hKey) != ERROR_SUCCESS) return;
275 if(RegEnumKey(hKey, i, valName, -1) != ERROR_SUCCESS) break;
277 if(RegOpenKey(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
279 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
280 tvis.hParent = tree.hAO;
282 if(RegOpenKey(hCurKey, wszInProcServer32, &hInfo) == ERROR_SUCCESS)
284 if(RegQueryValue(hInfo, NULL, buffer, &lenBuffer) == ERROR_SUCCESS
286 if(!memcmp(buffer, wszOle32dll, sizeof(WCHAR[9]))
287 ||!memcmp(buffer, wszOleAut32dll, sizeof(WCHAR[12])))
288 tvis.hParent = tree.hCLO;
293 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
295 if(RegQueryValue(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
296 U(tvis).item.pszText = buffer;
297 else U(tvis).item.pszText = valName;
299 U(tvis).item.lParam = CreateITEM_INFO(REGPATH|SHOWALL, valName, valName, NULL);
300 if(tvis.hParent) SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
302 if(RegOpenKey(hCurKey, wszImplementedCategories, &hInfo) == ERROR_SUCCESS)
304 if(RegEnumKey(hInfo, 0, wszComp, -1) != ERROR_SUCCESS) break;
308 if(tree.hGBCC) curSearch = TreeView_GetChild(globals.hTree, tree.hGBCC);
309 else curSearch = TreeView_GetChild(globals.hTree, TVI_ROOT);
313 tvi.hItem = curSearch;
314 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
316 if(tvi.lParam && !lstrcmpW(((ITEM_INFO *)tvi.lParam)->info, wszComp))
318 tvis.hParent = curSearch;
320 memmove(&valName[6], valName, sizeof(WCHAR[MAX_LOAD_STRING-6]));
321 memmove(valName, wszCLSID, sizeof(WCHAR[6]));
322 U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH|SHOWALL,
323 valName, &valName[6], NULL);
325 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
328 curSearch = TreeView_GetNextSibling(globals.hTree, curSearch);
331 RegCloseKey(hCurKey);
335 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hCLO);
336 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hAO);
339 void AddApplicationID(void)
343 WCHAR valName[MAX_LOAD_STRING];
344 WCHAR buffer[MAX_LOAD_STRING];
348 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
349 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
350 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
351 tvis.hParent = tree.hAID;
353 if(RegOpenKey(HKEY_CLASSES_ROOT, wszAppID, &hKey) != ERROR_SUCCESS) return;
359 if(RegEnumKey(hKey, i, valName, -1) != ERROR_SUCCESS) break;
361 if(RegOpenKey(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
363 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
365 if(RegQueryValue(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
366 U(tvis).item.pszText = buffer;
367 else U(tvis).item.pszText = valName;
369 RegCloseKey(hCurKey);
371 U(tvis).item.lParam = CreateITEM_INFO(REGPATH, valName, valName, NULL);
372 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
376 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hAID);
379 void AddTypeLib(void)
382 HKEY hKey, hCurKey, hInfoKey, hPath;
383 WCHAR valName[MAX_LOAD_STRING];
384 WCHAR valParent[MAX_LOAD_STRING];
385 WCHAR buffer[MAX_LOAD_STRING];
386 WCHAR wszVer[MAX_LOAD_STRING];
387 WCHAR wszPath[MAX_LOAD_STRING];
388 const WCHAR wszFormat[] = { ' ','(','%','s',' ','%','s',')','\0' };
389 const WCHAR wszFormat2[] = { '%','s','\\','%','s','\0' };
393 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
394 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
395 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
396 tvis.hParent = tree.hTL;
398 if(RegOpenKey(HKEY_CLASSES_ROOT, wszTypeLib, &hKey) != ERROR_SUCCESS) return;
404 if(RegEnumKey(hKey, i, valParent, -1) != ERROR_SUCCESS) break;
406 if(RegOpenKey(hKey, valParent, &hCurKey) != ERROR_SUCCESS) continue;
413 if(RegEnumKey(hCurKey, j, valName, -1) != ERROR_SUCCESS) break;
415 if(RegOpenKey(hCurKey, valName, &hInfoKey) != ERROR_SUCCESS) continue;
417 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
419 if(RegQueryValue(hInfoKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS
422 LoadString(globals.hMainInst, IDS_TL_VER, wszVer,
423 sizeof(WCHAR[MAX_LOAD_STRING]));
425 wsprintfW(&buffer[lstrlenW(buffer)], wszFormat, wszVer, valName);
426 U(tvis).item.pszText = buffer;
428 lenBuffer = MAX_LOAD_STRING;
429 RegOpenKey(hInfoKey, wszGetPath, &hPath);
430 RegQueryValue(hPath, NULL, wszPath, &lenBuffer);
433 else U(tvis).item.pszText = valName;
435 RegCloseKey(hInfoKey);
437 wsprintfW(wszVer, wszFormat2, valParent, valName);
438 U(tvis).item.lParam = CreateITEM_INFO(REGPATH, wszVer, valParent, wszPath);
440 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
442 RegCloseKey(hCurKey);
447 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hTL);
450 void AddInterfaces(void)
454 WCHAR valName[MAX_LOAD_STRING];
455 WCHAR buffer[MAX_LOAD_STRING];
459 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM;
460 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
461 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
462 tvis.hParent = tree.hI;
464 if(RegOpenKey(HKEY_CLASSES_ROOT, wszInterface, &hKey) != ERROR_SUCCESS) return;
470 if(RegEnumKey(hKey, i, valName, -1) != ERROR_SUCCESS) break;
472 if(RegOpenKey(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
474 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
476 if(RegQueryValue(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
477 U(tvis).item.pszText = buffer;
478 else U(tvis).item.pszText = valName;
480 RegCloseKey(hCurKey);
482 U(tvis).item.lParam = CreateITEM_INFO(REGPATH|INTERFACE, valName, valName, NULL);
483 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
488 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hI);
491 void AddComponentCategories(void)
495 WCHAR valName[MAX_LOAD_STRING];
496 WCHAR buffer[MAX_LOAD_STRING];
501 U(tvis).item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_CHILDREN;
502 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
503 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
504 if(tree.hGBCC) tvis.hParent = tree.hGBCC;
505 else tvis.hParent = TVI_ROOT;
506 U(tvis).item.cChildren = 1;
508 if(RegOpenKey(HKEY_CLASSES_ROOT, wszComponentCategories, &hKey) != ERROR_SUCCESS)
515 if(RegEnumKey(hKey, i, valName, -1) != ERROR_SUCCESS) break;
517 if(RegOpenKey(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
519 lenBuffer = sizeof(WCHAR[MAX_LOAD_STRING]);
520 lenBufferHlp = sizeof(WCHAR[MAX_LOAD_STRING]);
522 if(RegQueryValue(hCurKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS && *buffer)
523 U(tvis).item.pszText = buffer;
524 else if(RegEnumValue(hCurKey, 0, NULL, NULL, NULL, NULL,
525 (LPBYTE)buffer, &lenBufferHlp) == ERROR_SUCCESS && *buffer)
526 U(tvis).item.pszText = buffer;
529 RegCloseKey(hCurKey);
531 U(tvis).item.lParam = CreateITEM_INFO(REGTOP, valName, valName, NULL);
532 SendMessage(globals.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
537 SendMessage(globals.hTree, TVM_SORTCHILDREN, FALSE, (LPARAM)tree.hGBCC);
540 void AddBaseEntries(void)
543 WCHAR name[MAX_LOAD_STRING];
545 U(tvis).item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM;
546 /* FIXME add TVIF_IMAGE */
547 U(tvis).item.pszText = name;
548 U(tvis).item.cchTextMax = MAX_LOAD_STRING;
549 U(tvis).item.cChildren = 1;
550 tvis.hInsertAfter = (HTREEITEM)TVI_FIRST;
551 tvis.hParent = TVI_ROOT;
553 LoadString(globals.hMainInst, IDS_TREE_I, U(tvis).item.pszText,
554 sizeof(WCHAR[MAX_LOAD_STRING]));
555 U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszInterface, NULL, NULL);
556 tree.hI = TreeView_InsertItem(globals.hTree, &tvis);
558 LoadString(globals.hMainInst, IDS_TREE_TL, U(tvis).item.pszText,
559 sizeof(WCHAR[MAX_LOAD_STRING]));
560 U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszTypeLib, NULL, NULL);
561 tree.hTL = TreeView_InsertItem(globals.hTree, &tvis);
563 LoadString(globals.hMainInst, IDS_TREE_AID, U(tvis).item.pszText,
564 sizeof(WCHAR[MAX_LOAD_STRING]));
565 U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH, wszAppID, NULL, NULL);
566 tree.hAID = TreeView_InsertItem(globals.hTree, &tvis);
568 LoadString(globals.hMainInst, IDS_TREE_OC, U(tvis).item.pszText,
569 sizeof(WCHAR[MAX_LOAD_STRING]));
570 U(tvis).item.lParam = (LPARAM)NULL;
571 tree.hOC = TreeView_InsertItem(globals.hTree, &tvis);
574 tvis.hParent = tree.hOC;
575 LoadString(globals.hMainInst, IDS_TREE_AO, U(tvis).item.pszText,
576 sizeof(WCHAR[MAX_LOAD_STRING]));
577 U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszCLSID, NULL, NULL);
578 tree.hAO = TreeView_InsertItem(globals.hTree, &tvis);
580 LoadString(globals.hMainInst, IDS_TREE_CLO, U(tvis).item.pszText,
581 sizeof(WCHAR[MAX_LOAD_STRING]));
582 tree.hCLO = TreeView_InsertItem(globals.hTree, &tvis);
584 LoadString(globals.hMainInst, IDS_TREE_O1O, U(tvis).item.pszText,
585 sizeof(WCHAR[MAX_LOAD_STRING]));
586 U(tvis).item.lParam = (LPARAM)NULL;
587 tree.hO1O = TreeView_InsertItem(globals.hTree, &tvis);
589 LoadString(globals.hMainInst, IDS_TREE_GBCC, U(tvis).item.pszText,
590 sizeof(WCHAR[MAX_LOAD_STRING]));
591 U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH,
592 wszComponentCategories, NULL, NULL);
593 tree.hGBCC = TreeView_InsertItem(globals.hTree, &tvis);
595 SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)tree.hOC);
603 tvi.mask = TVIF_PARAM;
604 cur = TreeView_GetChild(globals.hTree, TVI_ROOT);
609 cur = TreeView_GetChild(globals.hTree, del);
611 if(!cur) cur = TreeView_GetNextSibling(globals.hTree, del);
614 cur = TreeView_GetPrevSibling(globals.hTree, del);
615 if(!cur) cur = TreeView_GetParent(globals.hTree, del);
618 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
622 if(((ITEM_INFO *)tvi.lParam)->loaded) ReleaseInst(del);
623 HeapFree(GetProcessHeap(), 0, (ITEM_INFO *)tvi.lParam);
626 SendMessage(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)del);
636 AddComponentCategories();
645 memset(&tree, 0, sizeof(TREE));
646 AddComponentCategories();
650 LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
655 globals.hTree = CreateWindow(WC_TREEVIEW, NULL,
656 WS_CHILD|WS_VISIBLE|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT,
657 0, 0, 0, 0, hWnd, (HMENU)TREE_WINDOW, globals.hMainInst, NULL);
661 if((int)wParam != TREE_WINDOW) break;
662 switch(((LPNMHDR)lParam)->code)
664 case TVN_ITEMEXPANDING:
665 CreateInst(((NMTREEVIEW *)lParam)->itemNew.hItem, NULL);
668 RefreshMenu(((NMTREEVIEW *)lParam)->itemNew.hItem);
669 RefreshDetails(((NMTREEVIEW *)lParam)->itemNew.hItem);
674 MoveWindow(globals.hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
677 return DefWindowProc(hWnd, uMsg, wParam, lParam);
682 HWND CreateTreeWindow(HINSTANCE hInst)
685 const WCHAR wszTreeClass[] = { 'T','R','E','E','\0' };
687 memset(&wct, 0, sizeof(WNDCLASS));
688 wct.lpfnWndProc = TreeProc;
689 wct.lpszClassName = wszTreeClass;
691 if(!RegisterClass(&wct)) return NULL;
693 return CreateWindowEx(WS_EX_CLIENTEDGE, wszTreeClass, NULL, WS_CHILD|WS_VISIBLE,
694 0, 0, 0, 0, globals.hPaneWnd, NULL, hInst, NULL);