Re: Errors in TypeBrowser generated code
Stefan Zschocke <[email protected]>
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Organization | infoZoom |
| Message-ID | <[email protected]> |
Hi, in this case the object is not created the regular COM way via CoCreateInstance, but using an exported function from a DLL. I dont know jawin but I guess the Jawin-created engine object wraps a COM pointer somewhere. Assign the returne Iengine to this COM pointer in order to use the wrapper. Stefan http://www.jacozoom.com -----Ursprüngliche Nachricht----- Von: Discussion of Java/Win32/COM integration with Jawin [mailto:[email protected]] Im Auftrag von David Hay Gesendet: Donnerstag, 3. Februar 2005 17:17 An: [email protected] Betreff: Re: [JAWIN] Errors in TypeBrowser generated code Hi, >the dll may need to be registered for running using regsvr32 but didn't >the install do this? > >Can your dll be found in the Wiundows registry? No! That's the wierd part! It appears from the C++ code that I looked at that it is simply loaded from the dll, for which the specify the location - please see sample C++ code they supply below). So, my question is: how do I do the equivalent? How do I call that function in an unregistered dll not found in the registry, and then use the Jawin stub classes once I have the Engine created (their instructions note the following: "Engine Overview: This object is the top object of ABBYY FineReader Engine objects hierarchy and is the only xxx Engine externally creatable object. ... ... Repeated attempts to create the Engine object will return the same object. It is important to notice that the process of creation of the Engine object takes rather long time because it requires loading not only the FREngine.dll, but a whole set of other DLLs. Call the GetEngineObject exported function to create the Engine object. Call the DeinitializeEngine exported function to deinitialize the FineReader Engine") Do I just call that method from the DLL, cast it into the Engine object that Jawin created, and then use that to create the sub-objects. Many thanks!! David C++ sample code: BOOL LoadFREngine() { if( g_FREngine != 0 ) { // Already loaded return TRUE; } // First step: load FREngine.dll if( s_libraryHandle == 0 ) { // FREngine.dll path name is calculated based on current module file name char fileName[_MAX_PATH]; if( GetModuleFileName( 0, fileName, _MAX_PATH ) == 0 ) { return FALSE; } char drive[_MAX_DRIVE], path[_MAX_DIR]; _splitpath( fileName, drive, path, 0, 0 ); if( strlen( drive ) + strlen( path ) + strlen( FREngineDllRelativePath ) >= _MAX_PATH ) { return FALSE; // too long path } strcpy( fileName, drive ); strcat( fileName, path ); strcat( fileName, FREngineDllRelativePath ); s_libraryHandle = LoadLibraryEx( fileName, 0, LOAD_WITH_ALTERED_SEARCH_PATH ); if( s_libraryHandle == 0 ) { return FALSE; } } // Second step: obtain FineReader Engine object typedef HRESULT (STDAPICALLTYPE* GetEngineObjectFunc)( BSTR, BSTR, BSTR, FREngine::IEngine** ); GetEngineObjectFunc pGetEngineObject = (GetEngineObjectFunc)GetProcAddress( s_libraryHandle, "GetEngineObject" ); if( pGetEngineObject == 0 || pGetEngineObject( LoadDeveloperSN(), 0, 0, &g_FREngine ) != S_OK ) { UnloadFREngine(); return FALSE; } return TRUE; } > >David Hay wrote: > >>Hi Josh, >> >>Yep, please consider this me "yelling"!! >> >>I would really appreciate help, as I'm a novice with COM. >> >>How do I go about figuring out what Java source is required? I have >>C++ examples of how to call this, and obviously know what the method >>should do - but not sure how to link the 2 with Jawin. >> >>By the way, do you have any comments on my later email about the dll >>not being installed? After further reading, these methods are the >>only "exported functions", and are used to create/destroy the Engine - >>after that methods are just called on this singleton Engine object. >> >>Thanks, >> >>David >> >> >>On Thu, 3 Feb 2005 09:54:12 +1000, Josh Passenger >><[email protected]> wrote: >> >> >> >>>HI David, >>> >>>If you know what Java source is required, you can add a patch to the XSLT >>>for that type of type element. >>> >>>The XSLT files are currently very simplistic in the more obscure >>>areas of >>> >>> >>MS >> >> >>>COM, and are often just stubbed out. >>> >>>If you need some help with the XSLT just yell, as you can imagine, >>>implementing all of the code transformations up front was just not >>> >>> >>feasible, >> >> >>>we are relying on contributions from people on a 'need to' basis to >>>fill >>> >>> >>in >> >> >>>the rest of the transformations. >>> >>>Josh >>> >>> >>> >>>>The output is advanced for IDispatch base interfaces. The coclass stuff >>>>has not been developed but there are stylesheets that can have >>>>implementation increased. The marshaling of Jawin is not far enough for >>>>it though. >>>> >>>>David Hay wrote: >>>> >>>> >>>> >>>>>Hi, >>>>> >>>>>I have some errors that appear in the code that the TypeBrowser >>>>> >>>>> >>generates >> >> >>>>>- >>>>>the class is almost blank, and just has the following: >>>>> >>>>>public class Globals >>>>>{ >>>>>public static final GUID = ""; >>>>> >>>>> >>>>>public void GetEngineObject() >>>>>{ >>>>> >>>>>} >>>>> >>>>>public void DeinitializeEngine() >>>>>{ >>>>> >>>>>} >>>>> >>>>>} >>>>> >>>>>The XML in the TypeBrowser is as follows: >>>>> >>>>><module name="Globals" description="xxx" helpFile="xxx" >>>>>helpReference="400" projectName="XXX" libraryFileName="XXX.tlb" >>>>>packageName="com.lexmark.olympus.action.ocr.jawin" >>>>>saveDirectory="c:\dev\olympus\prototype\src" javaEncoding=""> >>>>><function name="GetEngineObject" description="yyy" >>>>>helpFile="yyy.chm" helpReference="1100" >>>>>invokeKind="DISPATCH_METHOD" functionKind="FUNC_STATIC" >>>>>paramCount="4" optionalParamCount="0" vTableOffset="0"> <return >>>>>propertyType="25" typeName="int" typeString="VT_HRESULT" >>>>>typePointer="VT_PHRESULT" javaString="int" >>>>>javaObjectType="java.lang.Integer" javaSignature="V" >>>>>javaNativeString="jint" javaNativeArray="jintArray" >>>>>cppString="DWORD" cppDirect="VTS_HRESULT" >>>>>cppPointer="VTS_PHRESULT"> >>>>> <idl flag="null"/> >>>>> </return> >>>>> <parameter name="DeveloperSN" type="8" typeName="String" >>>>>typeString="VT_BSTR" typePointer="VT_PBSTR" javaString="String" >>>>>javaObjectType="java.lang.String" javaSignature="" >>>>>javaNativeString="jstring" javaNativeArray="jobjectArray" >>>>>cppString="CComBSTR" cppDirect="VTS_BSTR" cppPointer="VTS_PBSTR"> >>>>> </parameter> >>>>> <parameter name="Reserved1" type="8" typeName="String" >>>>>typeString="VT_BSTR" typePointer="VT_PBSTR" javaString="String" >>>>>javaObjectType="java.lang.String" javaSignature="" >>>>>javaNativeString="jstring" javaNativeArray="jobjectArray" >>>>>cppString="CComBSTR" cppDirect="VTS_BSTR" cppPointer="VTS_PBSTR"> >>>>> <modifier flag="NONE"/> >>>>> <modifier flag="IN"/> >>>>> <modifier flag="OPT"/> >>>>> <modifier flag="HAS_DEFAULT"/> >>>>> <idl flag="null"/> >>>>> </parameter> >>>>> <parameter name="Reserved2" type="8" typeName="String" >>>>>typeString="VT_BSTR" typePointer="VT_PBSTR" javaString="String" >>>>>javaObjectType="java.lang.String" javaSignature="" >>>>>javaNativeString="jstring" javaNativeArray="jobjectArray" >>>>>cppString="CComBSTR" cppDirect="VTS_BSTR" cppPointer="VTS_PBSTR"> >>>>> <modifier flag="NONE"/> >>>>> <modifier flag="IN"/> >>>>> <modifier flag="OPT"/> >>>>> <modifier flag="HAS_DEFAULT"/> >>>>> <idl flag="null"/> >>>>> </parameter> >>>>> <parameter name="Engine" type="26" typeString="VT_PTR" >>>>>typePointer="VT_PPTR" javaString="void" >>>>> >>>>> >>javaObjectType="java.lang.Object" >> >> >>>>>javaSignature="V" javaNativeString="jobject" >>>>>javaNativeArray="jobjectArray" cppString="void*" >>>>>cppDirect="VTS_PTR" cppPointer="VTS_PPTR"> >>>>> <pointer type="26" typeString="VT_PTR" typePointer="VT_PPTR" >>>>>javaString="void" >>>>> >>>>> >>javaObjectType="java.lang.Object" >> >> >>>>>javaSignature="V" javaNativeString="jobject" >>>>>javaNativeArray="jobjectArray" cppString="void*" >>>>>cppDirect="VTS_PTR" cppPointer="VTS_PPTR"> >>>>> <pointer type="26" >>>>>typeString="VT_USERDEFINED" typePointer="VT_PVARIANT" >>>>> >>>>> >>javaString="Object" >> >> >>>>>javaObjectType="java.lang.Object" javaSignature="" >>>>>javaNativeString="jobject" javaNativeArray="jobjectArray" >>>>>cppString="COleVariant" cppDirect="VTS_VARIANT" >>>>> >>>>> >>cppPointer="VTS_PVARIANT"> >> >> >>>>> </pointer> >>>>> </pointer> >>>>> <modifier flag="NONE"/> >>>>> <modifier flag="OUT"/> >>>>> <modifier flag="RETVAL"/> >>>>> <idl flag="null"/> >>>>> </parameter> >>>>></function> >>>>><function name="DeinitializeEngine" description="zzz" >>>>>helpFile="zzz.chm" helpReference="1101" >>>>>invokeKind="DISPATCH_METHOD" functionKind="FUNC_STATIC" >>>>>paramCount="0" optionalParamCount="0" vTableOffset="0"> <return >>>>>propertyType="25" typeName="int" typeString="VT_HRESULT" >>>>>typePointer="VT_PHRESULT" javaString="int" >>>>>javaObjectType="java.lang.Integer" javaSignature="V" >>>>>javaNativeString="jint" javaNativeArray="jintArray" >>>>>cppString="DWORD" cppDirect="VTS_HRESULT" >>>>>cppPointer="VTS_PHRESULT"> >>>>> <idl flag="NONE"/> >>>>> </return> >>>>></function> >>>>></module> >>>>> >>>>>Does anyone know what the problem is, and if there is a workaround? >>>>> >>>>>many thanks, >>>>> >>>>>David >>>>> >>>>> >>>>> >>>>> >>>>> >> >> >>