On Tue, 25 May 2010, Pritpal Bedi wrote: Hi Pritpal,
> Here is my Vouch32 ActiveX Server code compiled with xhb.com: > #pragma BEGINDUMP > #define CLS_Name "Vouch32.Vouch.1" > #define CLS_ID "{1F6C0963-1581-498a-9035-E75A0F546CA5}" > const char *g_RegTable[][3] = > { > //format is {key, value name, value } > { "CLSID\\" CLS_ID, 0, CLS_Name > }, > { "CLSID\\" CLS_ID "\\InprocServer32", 0, (const char*) -1 > }, > { "CLSID\\" CLS_ID "\\InprocServer32", "ThreadingModel", "Apartment" > }, > { "CLSID\\" CLS_ID "\\ProgId", 0, CLS_Name > }, > { CLS_Name, 0, CLS_Name > }, > { CLS_Name "\\CLSID", 0, CLS_ID } > }; > BOOL IsExportedSymbol( PHB_DYNS pDyn ) > { > if( pDyn->pSymbol >= symbols && pDyn->pSymbol <= symbols + > ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ) > { > return TRUE; > } > return FALSE; > } > > PHB_SYMB OleServerSymbols( USHORT *puiSymbols ) > { > *puiSymbols = (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ); > return symbols; > } > #pragma ENDDUMP I have no idea what exactly IsExportedSymbol() and OleServerSymbols() does in xHarbour. I can guess but I do not know the exact syntax. If you want then I can implement in Harbour compatibility layer but I would have to know xHarbour COM server user API. Now all I know about OLE in xHarbour.com comes from this page: http://xharbour.com/index.asp?page=add_on_oleserver&show_sub=7&show_i=1 > //-------------------------------------------------------------------// > REQUEST HB_GT_NUL > //-------------------------------------------------------------------// > #define DLL_PROCESS_ATTACH 1 > #define DLL_PROCESS_DETACH 0 > //-------------------------------------------------------------------// > PROCEDURE DllMain( hInstance, nReason ) > Local Instance := hInstance > SWITCH nReason > CASE DLL_PROCESS_ATTACH > Vwn_OutputDebugString( "Dll Loaded." ) > EXIT > CASE DLL_PROCESS_DETACH > Vwn_OutputDebugString( "Dll UNloaded." ) > EXIT > DEFAULT > Vwn_OutputDebugString( "UNEXPECTED nReaon in DllMain!" ) > END > RETURN > //-------------------------------------------------------------------// So in xHarbour DllMain() PRG function is executed just like in C. In the code I committed it's executed only when DLL is loaded and it should set at least server ID and name: WIN_OleServerInit( CLS_ID, CLS_Name ) Please note that CLS_ID and CLS_Name are PRG level #define values. > FUNCTION CreateInstance() > LOCAL oOleServer := Vouch32ActiveX() > ErrorBlock( {|e| Break( e ) } ) > Return oOleServer Next interesting extension. I guess that xHarbour checks if public function CreateInstance() exists and if yes the call it to create new OLE object. Has xHarbour other "special" functions which are used by OLE server code? In harbour you can reach the same functionality by passing pointer to Vouch32ActiveX object to WIN_OleServerInit(), i.e.: WIN_OleServerInit( CLS_ID, CLS_Name, Vouch32ActiveX() ) Vouch32ActiveX object does not use any instance variables so you can share the same object between many OLE objects. If you want to create new Vouch32ActiveX object for each OLE object then you should use codeblock as 3-rd WIN_OleServerInit() parameter which creates and returns such object, i.e.: WIN_OleServerInit( CLS_ID, CLS_Name, {|| Vouch32ActiveX() } ) It's not clear for me why you set errorBlock() inside this function and not in DllMain(). > CLASS Vouch32ActiveX > METHOD Vouch32Miscll() > METHOD Vouch32SetClientConsole() > METHOD Vouch32ServerPath() > METHOD Vouch32SetLicenseKey() [...] > ENDCLASS > METHOD Vouch32SetClientConsole CLASS Vouch32ActiveX > Return V32SetClient( .t. ) > METHOD Vouch32ServerPath() CLASS Vouch32ActiveX > Local c > c := Vwn_GetModuleFileName( Vwn_GetModuleHandle() ) > c := substr( c,1,rat( '\',c )-1 ) > Return c > METHOD Vouch32SetLicenseKey( cKey ) CLASS Vouch32ActiveX > VouchSetLicKey( cKey ) > Return Self > METHOD Vouch32PrintServer() CLASS Vouch32ActiveX > Return V32PrintPreview() > METHOD Vouch32CommServer() CLASS Vouch32ActiveX > Return V32CommServer() > METHOD Vouch32GraphicsServer() CLASS Vouch32ActiveX > Return V32Charts() [...] I guess that functions like V32PrintPreview() or V32CommServer() returns object and this objects are then used by other code as OLE objects. If V32PrintPreview() returns regular HVM object (is it true?) then xHb automatically translates it to OLE object. I haven't added such functionality but I can easy implement it. It seems to be interesting extension. Anyhow I would like to know if I guessed correctly. > Though I can makeout from olesrv1.prg how to convert, > can you quicky tell me how I construct the hash array to > populate method calls as objects on ole instance ? olesrv2.prg uses such hash array. But before you begin to change your code then I would like to know what API you used in xHarbour and maybe I'll create sth similar to reduce number of necessary modifications. For sure I do not plan to introduce as user API any C code encapsulated in #pragma BEGINDUMP/ENDDUMP or similar hacks but maybe many other things can be implemented. best regards, Przemek _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour