- Code: Select all Expand view RUN
- #include "FiveWin.ch"
function Main()
local oShell := CreateObject( "Shell.Application" )
local oInterface := GetInterface( oShell, "{000214D0-0000-0000-C000-000000000046}" ) // "IShellDispatch"
? oInterface:ClassName
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <hbstack.h>
IDispatch * hb_oleItemGet( PHB_ITEM pItem );
PHB_ITEM hb_oleItemPut( PHB_ITEM pItem, IDispatch * pDisp );
static wchar_t * AnsiToWide( const char * szString )
{
int iLen;
wchar_t * szWide;
iLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szString, -1, NULL, 0 );
szWide = ( wchar_t* ) hb_xgrab( iLen * sizeof( wchar_t ) );
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szString, -1, szWide, iLen );
return szWide;
}
HB_FUNC( GETINTERFACE )
{
IDispatch * pDisp = hb_oleItemGet( hb_param( 1, HB_IT_ANY ) );
IID riid;
IDispatch * pInterface = NULL;
wchar_t * cIID = AnsiToWide( hb_parc( 2 ) );
if( IIDFromString( ( LPOLESTR ) cIID, &riid ) == S_OK )
{
MessageBox( 0, "ok", "ok", 0 );
if( pDisp->lpVtbl->QueryInterface( pDisp, &riid, ( void** ) &pInterface ) == S_OK )
{
hb_oleItemPut( hb_stackReturnItem(), pInterface );
}
}
hb_xfree( cIID );
}
#pragma ENDDUMP