Inspecting a WinRT IInspectable
We get three values. Searching for them in the registry we get:
{00000035-0000-0000-C000-000000000046} --> IActivationFactory
{50AC103F-D235-4598-BBEF-98FE4D1A3AD4} --> IToastNotificationManagerStatics
{7AB93C52-0E48-4750-BA9D-1A4113981847} --> IToastNotificationManagerStatics2
https://msdn.microsoft.com/en-us/library/windows/desktop/br205821(v=vs.85).aspx- Code: Select all Expand view
#include "FiveWin.ch"
function Main()
local pString, cIID, pFactory
RoInitialize( 1 )
pString = WinRTString( "Windows.UI.Notifications.ToastNotificationManager" )
// "50AC103F-D235-4598-BBEF-98FE4D1A3AD4"
cIID = Chr( 0x3F ) + Chr( 0x10 ) + Chr( 0xAC ) + Chr( 0x50 ) + ;
Chr( 0x35 ) + Chr( 0xD2 ) + Chr( 0x98 ) + Chr( 0x45 ) + ;
Chr( 0xBB ) + Chr( 0xEF ) + Chr( 0x98 ) + Chr( 0xFE ) + ;
Chr( 0x4D ) + Chr( 0x1A ) + Chr( 0x3A ) + Chr( 0xD4 )
RoGetActivationFactory( pString, cIID, @pFactory )
WindowsDeleteString( pString );
XBrowser( Inspectable_GetIids( pFactory ) )
RoUninitialize()
return nil
function WinRTString( cText )
local pString
WindowsCreateString( AnsiToWide( cText ), Len( cText ), @pString )
return pString
DLL FUNCTION RoInitialize( nType AS LONG ) AS LONG PASCAL LIB "combase.dll"
DLL FUNCTION RoUninitialize() AS VOID PASCAL LIB "combase.dll"
DLL FUNCTION WindowsCreateString( cWideText AS LPSTR, nLength AS LONG, @pString AS PTR ) ;
AS LONG PASCAL LIB "combase.dll"
DLL FUNCTION WindowsDeleteString( pString AS PTR ) AS LONG PASCAL LIB "combase.dll"
DLL FUNCTION WindowsGetStringRawBuffer( pString AS PTR, @nLength AS LONG ) AS LPSTR PASCAL LIB "combase.dll"
DLL FUNCTION RoGetActivationFactory( pString AS PTR, REFIID AS LPSTR, @pFactory AS PTR ) ;
AS LONG PASCAL LIB "combase.dll"
DLL FUNCTION RoActivateInstance( pString AS PTR, @pInstance AS PTR ) ;
AS LONG PASCAL LIB "combase.dll"
#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
typedef HANDLE HSTRING;
typedef interface IInspectable IInspectable;
typedef struct IInspectableVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE * QueryInterface )(
IInspectable * This,
REFIID riid,
void ** ppvObject );
ULONG ( STDMETHODCALLTYPE * AddRef )(
IInspectable * This );
ULONG ( STDMETHODCALLTYPE * Release )(
IInspectable * This);
HRESULT ( STDMETHODCALLTYPE * GetIids )(
IInspectable * This,
ULONG * iidCount,
IID ** iids );
HRESULT ( STDMETHODCALLTYPE * GetRuntimeClassName )(
IInspectable * This,
HSTRING * className );
HRESULT ( STDMETHODCALLTYPE * GetTrustLevel )(
IInspectable * This,
int * trustLevel );
END_INTERFACE
} IInspectableVtbl;
interface IInspectable
{
CONST_VTBL struct IInspectableVtbl * lpVtbl;
};
HB_FUNC( INSPECTABLE_GETIIDS )
{
IInspectable * pInsp = ( IInspectable * ) hb_parnl( 1 );
ULONG iidCount = 0;
IID * iids = NULL;
unsigned int i;
char buffer[ 80 ];
pInsp->lpVtbl->GetIids( pInsp, &iidCount, &iids );
hb_reta( iidCount );
for( i = 0; i < iidCount; i++ )
{
wsprintf( buffer,
"{%08lX-%04hX-%04hX-%02hX%02hX-%02hX%02hX%02hX%02hX%02hX%02hX}",
iids[ i ].Data1, iids[ i ].Data2, iids[ i ].Data3,
iids[ i ].Data4[ 0 ], iids[ i ].Data4[ 1 ], iids[ i ].Data4[ 2 ],
iids[ i ].Data4[ 3 ], iids[ i ].Data4[ 4 ], iids[ i ].Data4[ 5 ],
iids[ i ].Data4[ 6 ], iids[ i ].Data4[ 7 ] );
hb_storvc( ( const char * ) buffer, -1, i + 1 );
}
// We must clean iids memory
// CoTaskMemFree( iids );
}
#pragma ENDDUMP