Works fine with Harbour and xHarbour:
Important: In order to test it, a shortcut to the EXE
must be created in the start menu
toastb.prg
#include "FiveWin.ch"
#define Show 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 7
#define CreateToastNotification 聽 聽7
#define CreateToastNotifierWithId 聽8
#define Item 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 8
#define GetTemplateContent 聽 聽 聽 聽 9
#define CreateTextNode 聽 聽 聽 聽 聽 聽12
#define GetElementsByTagName 聽 聽 聽17
#define AppendChild 聽 聽 聽 聽 聽 聽 聽 23
function Main()
聽 聽Toast( "Hello world" )
return nil
function Toast( cFirstLine )
聽 聽local pString, cIID, pToastFactory
聽 聽local pXml, pNodeList, pXmlNode, pXmlText, pXmlNodeChild
聽 聽local pNotification, pNotificationFactory, pNotifier
聽 聽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, @pToastFactory )
聽 聽WindowsDeleteString( pString );
聽 聽WinRTMethod( pToastFactory, GetTemplateContent, 3, @pXml ) // 3: fourth template
聽 聽pString = WinRTString( "text" )
聽 聽WinRTMethod( pXml, GetElementsByTagName, pString, @pNodeList )
聽 聽WindowsDeleteString( pString )
聽 聽WinRTMethod( pNodeList, Item, 0, @pXmlNode )
聽 聽pString = WinRTString( "First line" )
聽 聽WinRTMethod( pXml, CreateTextNode, pString, @pXmlText )
聽 聽// pXmlText.As( ... );
聽 聽// WinRTMethod( pXmlText, 8, @pXmlNode )
聽 聽WinRTMethod( pXmlNode, AppendChild, pXmlText, @pXmlNodeChild )
聽 聽// 04124B20-82C6-4229-B109-FD9ED4662B53
聽 聽cIID = Chr( 0x20 ) + Chr( 0x4B ) + Chr( 0x12 ) + Chr( 0x04 ) + ;
聽 聽 聽 聽 聽 Chr( 0xC6 ) + Chr( 0x82 ) + Chr( 0x29 ) + Chr( 0x42 ) + ;
聽 聽 聽 聽 聽 Chr( 0xB1 ) + Chr( 0x09 ) + Chr( 0xFD ) + Chr( 0x9E ) + ;
聽 聽 聽 聽 聽 Chr( 0xD4 ) + Chr( 0x66 ) + Chr( 0x2B ) + Chr( 0x53 )
聽 聽pString = WinRTString( "Windows.UI.Notifications.ToastNotification" )
聽 聽RoGetActivationFactory( pString, cIID, @pNotificationFactory )
聽 聽WindowsDeleteString( pString )
聽 聽WinRTMethod( pNotificationFactory, CreateToastNotification, pXML, @pNotification )
聽 聽pString = WinRTString( cFirstLine )
聽 聽WinRTMethod( pToastFactory, CreateToastNotifierWithId, pString, @pNotifier )
聽 聽WindowsDeleteString( pString )
聽 聽WinRTMethod( pNotifier, Show, pNotification )
聽 聽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 RoGetActivationFactory( pString AS PTR, REFIID AS LPSTR, @pFactory AS PTR ) ;
聽 聽AS LONG PASCAL LIB "combase.dll"
#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
#ifndef HB_LONGLONG
聽 聽#define HB_LONGLONG long
聽 聽#define hb_storvnll hb_stornl
#endif
typedef void * ( __stdcall * PMETHOD0 )( void * );
typedef void * ( __stdcall * PMETHOD1 )( void *, void * );
typedef void * ( __stdcall * PMETHOD2 )( void *, void *, void * );
HB_FUNC( WINRTMETHOD ) // pInspectable, nMethod, params...
{
聽 聽IUnknown * unknown = ( IUnknown * ) hb_parnll( 1 );
聽 聽void * pMethod = ( ( void ** ) unknown->lpVtbl )[ hb_parnl( 2 ) - 1 ];
聽 聽IUnknown * pReturn;
聽 聽switch( hb_pcount() )
聽 聽{
聽 聽 聽 case 3:
聽 聽 聽 聽 聽if( HB_ISBYREF( 3 ) )
聽 聽 聽 聽 聽 聽 hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, &pReturn ) );
聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD1 ) pMethod )( unknown, ( IUnknown * ) hb_parnll( 3 ) ) );
聽 聽 聽 聽 聽break;
聽 聽 聽 case 4:
聽 聽 聽 聽 聽if( HB_ISBYREF( 4 ) )
聽 聽 聽 聽 聽 聽 hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), &pReturn ) );
聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 hb_retnll( ( HB_LONGLONG ) ( ( PMETHOD2 ) pMethod )( unknown, ( void * ) hb_parnll( 3 ), ( IUnknown * ) hb_parnll( 4 ) ) );
聽 聽 聽 聽 聽break;
聽 聽}
聽 聽if( HB_ISBYREF( 3 ) )
聽 聽 聽 hb_storvnll( ( HB_LONGLONG ) pReturn, 3 );
聽 聽if( HB_ISBYREF( 4 ) )
聽 聽 聽 hb_storvnll( ( HB_LONGLONG ) pReturn, 4 );
} 聽
#pragma ENDDUMP