From 1875150758eafc123ecdaed62cbb01e5479278c9 Mon Sep 17 00:00:00 2001 From: Laurent Ganier Date: Fri, 17 Oct 2003 09:49:15 +0000 Subject: [PATCH] [ 807263 ] Preprocessing patch --- Src/Common/dllproxy.c | 2 ++ Src/Common/dllproxy.h | 5 +++++ Src/Common/lwdisp.c | 19 +++++++++++++------ Src/Common/lwdisp.h | 5 +++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Src/Common/dllproxy.c b/Src/Common/dllproxy.c index 2a7605f70..d30220a52 100644 --- a/Src/Common/dllproxy.c +++ b/Src/Common/dllproxy.c @@ -38,6 +38,8 @@ DATE: BY: DESCRIPTION: rely on _alloca(); may also work with GCC */ +// RCS ID line follows -- this is updated by CVS +// $Id$ #if defined(_MSC_VER)&&!defined(NO_ALLOCA_RECOVERY)||defined(ALLOCA_RECOVERY) #undef ALLOCA_RECOVERY diff --git a/Src/Common/dllproxy.h b/Src/Common/dllproxy.h index 2823a4d56..01719bc94 100644 --- a/Src/Common/dllproxy.h +++ b/Src/Common/dllproxy.h @@ -1,3 +1,6 @@ +#ifndef __DLLPROXY_H__ +#define __DLLPROXY_H__ + struct DllProxy_ModuleState { // error messages exposed here just in case anybody desires localization... @@ -36,3 +39,5 @@ EXTERN_C struct DllProxy_ModuleState POLARITY DllProxy_ModuleState; extern struct {HMODULE DLL;CHAR SIG[sizeof#P MODULE + (sizeof MODULE == 1 ? MAX_PATH : 0)];} __declspec(dllimport) NAME; #undef POLARITY + +#endif //__DLLPROXY_H__ \ No newline at end of file diff --git a/Src/Common/lwdisp.c b/Src/Common/lwdisp.c index 012922907..2b36388e5 100644 --- a/Src/Common/lwdisp.c +++ b/Src/Common/lwdisp.c @@ -31,6 +31,8 @@ DATE: BY: DESCRIPTION: 2003/08/05 J.Tucht change some names for use with MFC */ +// RCS ID line follows -- this is updated by CVS +// $Id$ //#define _WIN32_IE 0x0300 //#define _WIN32_WINNT 0x0400 @@ -95,6 +97,12 @@ void mycpyt2a(LPCTSTR tsz, char * adest, int limit) #endif } +/** + * + * @Note We can use this code with unregistered COM DLL + * For VC++ DLL, we need a custom CComTypeInfoHolder as the default one search the registry + * For VB DLL, instance can not be shared accross thread, one must be created for each thread + */ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) { void *pv = 0; @@ -109,7 +117,7 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) sc=CoCreateInstance(&clsid, 0, CLSCTX_ALL, &IID_IDispatch, &pv); } } - else if (PathMatchSpec(source, _T("*.ocx"))) + else if (PathMatchSpec(source, _T("*.ocx")) || PathMatchSpec(source, _T("*.dll"))) { ITypeLib *piTypeLib; mycpyt2w(source, wc, DIMOF(wc)); @@ -128,7 +136,7 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) if SUCCEEDED(sc=piTypeInfo->lpVtbl->GetDocumentation(piTypeInfo, MEMBERID_NIL, &bstrName, 0, 0, 0)) { LPCTSTR name = B2T(bstrName); - if (pTypeAttr->typekind == TKIND_COCLASS && lstrcmp(name, progid) == 0) + if (pTypeAttr->typekind == TKIND_COCLASS && lstrcmpi(name, progid) == 0) { IClassFactory *piClassFactory; EXPORT_DLLPROXY @@ -136,7 +144,7 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) Dll, "", HRESULT(NTAPI*DllGetClassObject)(REFCLSID,REFIID,IClassFactory**); ); - mycpyt2a(source, Dll.SIG, sizeof(Dll.SIG)); + mycpyt2a(source, Dll.SIG+strlen(Dll.SIG), sizeof(Dll.SIG)-strlen(Dll.SIG)); if SUCCEEDED(sc=DLLPROXY(Dll)->DllGetClassObject(&pTypeAttr->guid, &IID_IClassFactory, &piClassFactory)) { sc=piClassFactory->lpVtbl->CreateInstance(piClassFactory, 0, &IID_IDispatch, &pv); @@ -164,7 +172,6 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) if (PathMatchSpec(source, _T("*.sct"))) { MultiByteToWideChar(CP_ACP, 0, "script:", -1, wc, DIMOF(wc)); - mycpyt2w(source, wc+wcslen(wc), DIMOF(wc)-wcslen(wc)); } else @@ -198,7 +205,7 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCTSTR progid) if FAILED(sc) { pv = 0; -// ReportError(sc, MB_ICONSTOP|MB_TASKMODAL); + ReportError(sc, MB_ICONSTOP|MB_TASKMODAL); } return (LPDISPATCH)pv; } @@ -210,7 +217,7 @@ STDAPI invokeV(LPDISPATCH pi, VARIANT *ret, DISPID id, LPCCH op, VARIANT *argv) WORD wFlags = HIBYTE((UINT_PTR)op); DISPPARAMS dispparams; UINT nArgErr = (UINT)-1; - EXCEPINFO excepInfo; + EXCEPINFO excepInfo = {0}; dispparams.cArgs = LOBYTE((UINT_PTR)op); dispparams.cNamedArgs = 0; if (wFlags & (DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF)) diff --git a/Src/Common/lwdisp.h b/Src/Common/lwdisp.h index 4a455910d..b462091ba 100644 --- a/Src/Common/lwdisp.h +++ b/Src/Common/lwdisp.h @@ -1,3 +1,6 @@ +#ifndef __LWDISP_H__ +#define __LWDISP_H__ + #ifdef __cplusplus extern "C"{ #endif @@ -236,3 +239,5 @@ struct LWRet: public VARIANT // Sorry, no extra support for plain old C... #endif + +#endif //__LWDISP_H__ \ No newline at end of file -- 2.11.0