#include "FiveWin.ch"
function Main()
local o := CreateObject( "ADOX.Table" )
// local pTypeInfo
if GetTypeInfoCount( o:hObj ) == 1 // There is info
// pTypeInfo = TOleAuto():New( GetTypeInfo( o:hObj ) )
if Len( GetTypeVars( o:hObj ) ) > 0
XBROWSER GetTypeVars( o:hObj ) TITLE "Variables"
endif
XBROWSER GetTypeFuncs( o:hObj ) TITLE "Functions"
endif
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include "c:\harbour\contrib\hbwin\hbwinole.h"
HB_FUNC( GETTYPEINFOCOUNT )
{
IDispatch * pDisp = hb_oleParam( 1 );
HRESULT lOleError;
UINT ctinfo;
lOleError = HB_VTBL( pDisp )->GetTypeInfoCount( HB_THIS( pDisp ), &ctinfo );
hb_retnl( ( lOleError == S_OK ) ? ctinfo: -1 );
}
static LPSTR WideToAnsi( LPWSTR cWide )
{
WORD wLen;
LPSTR cString = NULL;
wLen = WideCharToMultiByte( CP_ACP, 0, cWide, -1, cString, 0, NULL, NULL );
cString = ( LPSTR ) hb_xgrab( wLen );
WideCharToMultiByte( CP_ACP, 0, cWide, -1, cString, wLen, NULL, NULL );
return cString;
}
HB_FUNC( GETTYPEINFO )
{
IDispatch * pDisp = hb_oleParam( 1 );
ITypeInfo * pInfo;
if( HB_VTBL( pDisp )->GetTypeInfo( HB_THIS( pDisp ), 0, 0, &pInfo ) == S_OK )
hb_oleItemPut( hb_stackReturnItem(), ( IDispatch * ) pInfo );
else
hb_ret();
}
HB_FUNC( GETTYPEVARS )
{
IDispatch * pDisp = hb_oleParam( 1 );
ITypeInfo * pInfo;
HRESULT lOleError;
TYPEATTR * pta;
int i;
lOleError = HB_VTBL( pDisp )->GetTypeInfo( HB_THIS( pDisp ), 0, 0, &pInfo );
lOleError = HB_VTBL( pInfo )->GetTypeAttr( HB_THIS( pInfo ), &pta );
hb_reta( pta->cVars );
for( i = 0; i < pta->cVars; i++ )
{
BSTR bsName;
VARDESC * pVar;
char * pszName;
lOleError = HB_VTBL( pInfo )->GetVarDesc( HB_THIS( pInfo ), i, &pVar );
lOleError = HB_VTBL( pInfo )->GetDocumentation( HB_THIS( pInfo ), pVar->memid, &bsName, NULL, NULL, NULL );
pszName = WideToAnsi( bsName );
hb_storvclen( pszName, strlen( pszName ), -1, i + 1 );
hb_xfree( ( void * ) pszName );
HB_VTBL( pInfo )->ReleaseVarDesc( HB_THIS( pInfo ), pVar );
}
HB_VTBL( pInfo )->Release( HB_THIS( pInfo ) );
}
HB_FUNC( GETTYPEFUNCS )
{
IDispatch * pDisp = hb_oleParam( 1 );
ITypeInfo * pInfo;
HRESULT lOleError;
TYPEATTR * pta;
int i;
lOleError = HB_VTBL( pDisp )->GetTypeInfo( HB_THIS( pDisp ), 0, 0, &pInfo );
lOleError = HB_VTBL( pInfo )->GetTypeAttr( HB_THIS( pInfo ), &pta );
hb_reta( pta->cFuncs );
for( i = 0; i < pta->cFuncs; i++ )
{
BSTR bsName;
FUNCDESC * pfd;
char * pszName;
lOleError = HB_VTBL( pInfo )->GetFuncDesc( HB_THIS( pInfo ), i, &pfd );
// lOleError = HB_VTBL( pInfo )->GetNames( HB_THIS( pInfo ), pfd->memid, &bsName, 1, &uiNames );
lOleError = HB_VTBL( pInfo )->GetDocumentation( HB_THIS( pInfo ), pfd->memid, &bsName, NULL, NULL, NULL );
pszName = WideToAnsi( bsName );
hb_storvclen( pszName, strlen( pszName ), -1, i + 1 );
hb_xfree( ( void * ) pszName );
HB_VTBL( pInfo )->ReleaseFuncDesc( HB_THIS( pInfo ), pfd );
}
HB_VTBL( pInfo )->Release( HB_THIS( pInfo ) );
}
#pragma ENDDUMP