oleview: Added open TypeLib file functionality.

This commit is contained in:
Piotr Caban 2006-07-02 13:04:26 +02:00 committed by Alexandre Julliard
parent fa7e97e80d
commit ecd514d5d6
6 changed files with 56 additions and 11 deletions

View File

@ -95,6 +95,7 @@ STRINGTABLE
IDS_ABOUT "OleView - OLE/COM Object Viewer"
IDS_ABOUTVER "version 1.0"
IDS_TYPELIBTITLE "ITypeLib viewer"
IDS_OPEN "Open"
IDM_BIND, "Bind to file via a File Moniker"
IDM_TYPELIB, "Open a TypeLib file and view the contents"

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = oleview.exe
APPMODE = -mwindows -municode
IMPORTS = comctl32 shell32 oleaut32 ole32 user32 advapi32 kernel32
IMPORTS = comdlg32 comctl32 shell32 oleaut32 ole32 user32 advapi32 kernel32
EXTRALIBS = -luuid
EXTRADEFS = -DUNICODE

View File

@ -108,6 +108,7 @@ typedef struct
HWND hTree;
HWND hEdit;
HWND hStatusBar;
WCHAR wszFileName[MAX_LOAD_STRING];
}TYPELIB;
extern GLOBALS globals;
@ -138,7 +139,7 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName);
void ReleaseInst(HTREEITEM item);
/* typelib.c */
BOOL CreateTypeLibWindow(HINSTANCE hInst);
BOOL CreateTypeLibWindow(HINSTANCE hInst, WCHAR *wszFileName);
BOOL TypeLibRegisterClass(void);
/* interface.c */

View File

@ -25,6 +25,13 @@ static WCHAR wszRegEdit[] = { 'r','e','g','e','d','i','t','.','e','x','e','\0' }
static WCHAR wszFormat[] = { '<','o','b','j','e','c','t','\n',' ',' ',' ',
'c','l','a','s','s','i','d','=','\"','c','l','s','i','d',':','%','s','\"','\n',
'>','\n','<','/','o','b','j','e','c','t','>','\0' };
WCHAR wszFilter[] = { 'T','y','p','e','L','i','b',' ','F','i','l','e','s',' ',
'(','*','t','l','b',';','*','o','l','b',';','*','.','d','l','l',';',
'*','.','o','c','x',';','*','.','e','x','e',')','\0',
'*','.','t','l','b',';','*','.','o','l','b',';','*','.','d','l','l',';',
'*','.','o','c','x','*','.','e','x','e','\0',
'A','l','l',' ','F','i','l','e','s',' ','(','*','.','*',')','\0',
'*','.','*','\0','\0' };
INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -124,6 +131,22 @@ INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM
return FALSE;
}
void InitOpenFileName(HWND hWnd, OPENFILENAME *pofn, WCHAR *wszFilter,
WCHAR *wszTitle, WCHAR *wszFileName)
{
memset(pofn, 0, sizeof(OPENFILENAME));
pofn->lStructSize = sizeof(OPENFILENAME);
pofn->hwndOwner = hWnd;
pofn->hInstance = globals.hMainInst;
pofn->lpstrTitle = wszTitle;
pofn->lpstrFilter = wszFilter;
pofn->nFilterIndex = 0;
pofn->lpstrFile = wszFileName;
pofn->nMaxFile = MAX_LOAD_STRING;
pofn->Flags = OFN_HIDEREADONLY;
}
void CopyClsid(HTREEITEM item)
{
TVITEM tvi;
@ -380,10 +403,21 @@ int MenuCommand(WPARAM wParam, HWND hWnd)
vis ? MF_UNCHECKED : MF_CHECKED);
ResizeChild();
break;
case IDM_TYPELIB:
{
OPENFILENAME ofn;
static WCHAR wszTitle[MAX_LOAD_STRING];
static WCHAR wszName[MAX_LOAD_STRING];
LoadString(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle));
InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName);
if(GetOpenFileName(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
break;
}
case IDM_VIEW:
hSelect = TreeView_GetSelection(globals.hTree);
if(IsInterface(hSelect)) InterfaceViewer(hSelect);
else CreateTypeLibWindow(globals.hMainInst);
else CreateTypeLibWindow(globals.hMainInst, NULL);
break;
case IDM_EXIT:
DestroyWindow(hWnd);

View File

@ -29,6 +29,8 @@
#define IDS_ABOUT 20
#define IDS_ABOUTVER 21
#define IDS_OPEN 30
#define IDM_BIND 100
#define IDM_TYPELIB 101
#define IDM_SYSCONF 102

View File

@ -30,7 +30,6 @@ void AddToStrW(WCHAR *wszDest, const WCHAR *wszSource)
int PopulateTree(void)
{
TVITEM tvi;
TVINSERTSTRUCT tvis;
ITypeLib *pTypeLib;
ITypeInfo *pTypeInfo, *pRefTypeInfo;
@ -64,9 +63,6 @@ int PopulateTree(void)
const WCHAR wszVT_BSTR[] = { 'B','S','T','R',' ','\0' };
const WCHAR wszVT_CY[] = { 'C','U','R','R','E','N','C','Y',' ','\0' };
memset(&tvi, 0, sizeof(TVITEM));
tvi.hItem = TreeView_GetSelection(globals.hTree);
U(tvis).item.mask = TVIF_TEXT|TVIF_CHILDREN;
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
U(tvis).item.pszText = wszText;
@ -74,15 +70,14 @@ int PopulateTree(void)
tvis.hInsertAfter = (HTREEITEM)TVI_LAST;
tvis.hParent = TVI_ROOT;
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
if(FAILED((hRes = LoadTypeLib(((ITEM_INFO*)tvi.lParam)->path, &pTypeLib))))
if(FAILED((hRes = LoadTypeLib(typelib.wszFileName, &pTypeLib))))
{
WCHAR wszMessage[MAX_LOAD_STRING];
WCHAR wszError[MAX_LOAD_STRING];
LoadString(globals.hMainInst, IDS_ERROR_LOADTYPELIB,
wszError, sizeof(WCHAR[MAX_LOAD_STRING]));
wsprintfW(wszMessage, wszError, ((ITEM_INFO*)tvi.lParam)->path, hRes);
wsprintfW(wszMessage, wszError, typelib.wszFileName, hRes);
MessageBox(globals.hMainWnd, wszMessage, NULL, MB_OK|MB_ICONEXCLAMATION);
return 1;
}
@ -261,11 +256,23 @@ BOOL TypeLibRegisterClass(void)
return TRUE;
}
BOOL CreateTypeLibWindow(HINSTANCE hInst)
BOOL CreateTypeLibWindow(HINSTANCE hInst, WCHAR *wszFileName)
{
WCHAR wszTitle[MAX_LOAD_STRING];
LoadString(hInst, IDS_TYPELIBTITLE, wszTitle, sizeof(WCHAR[MAX_LOAD_STRING]));
if(wszFileName) lstrcpyW(typelib.wszFileName, wszFileName);
else
{
TVITEM tvi;
memset(&tvi, 0, sizeof(TVITEM));
tvi.hItem = TreeView_GetSelection(globals.hTree);
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
lstrcpyW(typelib.wszFileName, ((ITEM_INFO*)tvi.lParam)->path);
}
globals.hTypeLibWnd = CreateWindow(wszTypeLib, wszTitle,
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInst, NULL);