From 0377d1642de0b944f7fc12796d6bfafeb2ef9e6d Mon Sep 17 00:00:00 2001 From: Laurent Ganier Date: Mon, 3 Nov 2003 22:11:10 +0000 Subject: [PATCH] PATCH: [ 833188 ] clever and explicit error report in TypeLib --- Src/Common/lwdisp.c | 36 +++++++++++++++++++++++++++++++++++- Src/readme.txt | 4 ++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Src/Common/lwdisp.c b/Src/Common/lwdisp.c index 2b36388e5..6e7304dda 100644 --- a/Src/Common/lwdisp.c +++ b/Src/Common/lwdisp.c @@ -159,6 +159,15 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) } piTypeLib->lpVtbl->Release(piTypeLib); } + else + { + // no error if no interface (normal dll) + if (PathMatchSpec(source, _T("*.dll")) && sc == TYPE_E_CANTLOADLIBRARY) + sc = 0; + // no error if the format is too old + if (sc == TYPE_E_UNSUPFORMAT) + sc = 0; + } } else { @@ -201,11 +210,36 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) sc=CoGetObject(wc, &bind_opts, &IID_IDispatch, &pv); } } + // no error if the interface does not exist + if (sc == MK_E_INTERMEDIATEINTERFACENOTSUPPORTED || sc == E_UNEXPECTED) + sc = 0; } if FAILED(sc) { + // report error + LPSTR bareErrorText = ReportError(sc, 0); + if (source) + { + // append the source name + LPTSTR errorText; + errorText = malloc((strlen(bareErrorText)+1+_tcslen(source)+1)*sizeof(TCHAR)); +#ifdef UNICODE + MultiByteToWideChar(CP_ACP, 0, bareErrorText, -1, errorText, strlen(bareErrorText)+1); +#else + strcpy(errorText, bareErrorText); +#endif + _tcscat(errorText, "\n"); + _tcscat(errorText, source); + MessageBox(0, errorText, 0, MB_ICONSTOP|MB_TASKMODAL); + free (errorText); + } + else + { + MessageBoxA(0, bareErrorText, 0, MB_ICONSTOP|MB_TASKMODAL); + } + LocalFree(bareErrorText); + // no valid dispatch pv = 0; - ReportError(sc, MB_ICONSTOP|MB_TASKMODAL); } return (LPDISPATCH)pv; } diff --git a/Src/readme.txt b/Src/readme.txt index 18e51d6c6..597555449 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2003-11-03 Laoran + PATCH: [ 833188 ] clever and explicit error report in TypeLib + common: lwdisp.c + 2003-11-03 Kimmo PATCH: [ 834526 ] Check that file exist before executing in ShellExtension ShellExtension: ShellExtension.dsp WinMergeShell.h WinMergeShell.cpp -- 2.11.0