SiteKiosk Documentation
One Step Back

How to access the ISiteKiosk Interface




Codesamples on how to access the ISiteKiosk Interface from different programming languages.


    The SiteKiosk object can be accessed through the ISiteKiosk interface. The interface can only be retrieved from a running instance of SiteKiosk.

    To get the ISiteKiosk interface, you will need to ask the SiteKioskClassFactory for an interface. You will need the COM-Method CoGetClassObject(...) provided by the 'ole32.dll' Library. By calling CoGetClassObject(...) you will query an ISiteKioskFactory interface. This interface provides the method CreateSiteKiosk', that returns an ISiteKiosk-interface of the currently running SiteKiosk instance.
    The following examples show you how to get the current version of SiteKiosk via the ISiteKiosk interface in the following programming languages:

    Microsoft Visual Basic .NET

    Microsoft Visual C# .NET

    Borland Delphi 7

Microsoft Visual Basic .NET
    The following example shows how to access the SiteKiosk object from Microsoft Visual Basic .NET

    You will need to import the SiteKiosk Runtime Type Library to have access to the COM interfaces. Therefor, go to the menu 'Project' and select 'Add Reference'. Switch to the 'COM'-tab and select the entry 'SiteKioskRuntime 1.0 Type Library' from the list. Now, by clicking on the 'OK'-button, the COM interfaces will be imported to your project.

    Add the following import statements to the top of your source file:

    Copy to clipboard

    Imports SiteKioskRuntimeLib
    Imports System
    

    To import the CoGetClassObject() funtion from ole32.dll add the following code to your global namespace:

    Copy to clipboard

    Declare Function CoGetClassObject Lib "ole32.dll"
    (ByRef rclsid As Guid, ByVal dwClsContext As Integer,
    ByVal pServerInfo As IntPtr, ByRef riid As Guid,
    ByRef ppv As IntPtr) As Integer

    The following source code shows, how to get the version of the SiteKiosk instance. If SiteKiosk is not running, the function returns false. If SiteKiosk is running and the version is successfully read, the function return True and the parameter as_Value is filled with SiteKiosk's version.

    Copy to clipboard

    Private Function GetSiteKioskVersion(ByRef as_Version) As Boolean
    
        REM returns false, then SiteKiosk is not available
        REM otherwise, True is returned and as_Version will contain
        REM the current Siteiosk version
    
        Dim IID_ISiteKioskFactory As Guid
        Dim CLSID_SiteKioskFactory As Guid
        Dim IID_ISiteKiosk As Guid
    
        REM retrieve the needed interface-id's and class-id's
    
        IID_ISiteKioskFactory = GetType(SiteKioskFactory).GUID()
        CLSID_SiteKioskFactory = GetType(SiteKioskFactoryClass).GUID()
        IID_ISiteKiosk = GetType(SiteKiosk).GUID()
    
        REM get interface of SiteKioskFactory
    
        Dim li_Unk_ As IntPtr = New IntPtr
        Dim li_Hr As Integer = CoGetClassObject(CLSID_SiteKioskFactory,
    4, New IntPtr, IID_ISiteKioskFactory, li_Unk_) If li_Hr <> 0 Then REM sitekiosk is not running Return False End If REM convert the IntPtr to the requested interface Dim lr_SiteKioskFactory_ As SiteKioskFactory = System.Runtime.
    InteropServices.Marshal.GetObjectForIUnknown(li_Unk_) Dim li_ISiteKioskUnknown_ As IntPtr REM get an interface on the running instance of SiteKiosk lr_SiteKioskFactory_.CreateSiteKiosk(IID_ISiteKiosk,
    li_ISiteKioskUnknown_) If (li_ISiteKioskUnknown_.Equals(IntPtr.Zero)) Then REM SiteKiosk was not running and could not be launched Return False End If REM convert the returned IntPtr to the requested interface Dim lr_ISiteKiosk_ As ISiteKiosk = System.Runtime.InteropServices.
    Marshal.GetObjectForIUnknown(li_ISiteKioskUnknown_) REM read out the version of SiteKiosk Dim lk_Version As ISKVersion = lr_ISiteKiosk_.Version() as_Version = lk_Version.VersionString Return True End Function

Microsoft Visual C# .NET
    The following example shows how to access the SiteKiosk object from Microsoft Visual C# .NET

    You will need to import the SiteKiosk Runtime Type Library to have access to the COM interfaces. Therefor, go to the menu 'Project' and select 'Add Reference'. Switch to the 'COM'-tab and select the entry 'SiteKioskRuntime 1.0 Type Library' from the list. Now, by clicking on the 'OK'-button, the COM interfaces will be imported to your project.

    Add the following source code to the top of your source file:

    Copy to clipboard

    using System.Runtime.InteropServices;
    using SiteKioskRuntimeLib;
    

    To import the CoGetClassObject() funtion from ole32.dll add the following code to your global namespace:

    Copy to clipboard

    [DllImport("ole32.dll", CallingConvention=CallingConvention.StdCall)] 
    
    public static extern int CoGetClassObject
    		( ref Guid rclsid
    		, uint dwClsContext
    		, IntPtr pServerInfo
    		, ref Guid riid
    		, out IntPtr ppv); 
    

    The following source code shows, how to get the version of the SiteKiosk instance. If SiteKiosk is not running, the function returns false. If SiteKiosk is running and the version is successfully read, the function return True and the parameter as_Value is filled with SiteKiosk's version.

    Copy to clipboard

    public bool GetSiteKioskVersion(ref string as_Version)
    {
       
       /*
           returns false, if SiteKiosk is not currently running
           return true, if SiteKiosk is running and sets 'as_Version'
           to the version of SiteKiosk
       */
       
    
       // initialize GUID's for classes and interfaces
       Guid lr_FactoryGuid = typeof(ISiteKioskFactory).GUID;
       Guid lr_FactoryClass = typeof(SiteKioskFactoryClass).GUID;
       Guid lr_SiteKioskGuid = typeof(ISiteKiosk).GUID;
    
       ISiteKiosk mk_pSiteKiosk;
    
       // try to get the ISiteKioskFactory interface of the instance
       // of SiteKioskFactoryClass
       IntPtr lk_FactoryPtr = new IntPtr();
       CoGetClassObject(ref lr_FactoryClass, 4, new IntPtr(),
    ref lr_FactoryGuid, out lk_FactoryPtr); if (lk_FactoryPtr == IntPtr.Zero) // SiteKiosk is not running return false; // convert the received IntPtr to the requested ISiteKioskFactory // interface ISiteKioskFactory lk_Factory = (ISiteKioskFactory)Marshal.
    GetObjectForIUnknown(lk_FactoryPtr); if (lk_Factory == null) return false; // call CreateSiteKiosk to get the ISiteKiosk interface of the // current instance of SiteKiosk IntPtr lk_SiteKioskPtr = new IntPtr(); lk_Factory.CreateSiteKiosk(ref lr_SiteKioskGuid, out lk_SiteKioskPtr); if (lk_SiteKioskPtr == IntPtr.Zero) return false; // convert the received IntPtr to the requested // ISiteKioskFactory interface mk_pSiteKiosk = (ISiteKiosk)Marshal.GetObjectForIUnknown
    (lk_SiteKioskPtr); if (mk_pSiteKiosk == null) return false; // get the version of SiteKiosk ISKVersion lr_SKVersion = (ISKVersion)mk_pSiteKiosk.Version; as_Version = lr_SKVersion.VersionString; return true; }

    Two code examples for C# projects using the SiteKiosk Object Model:
    Example with graphical user interface
    Example for a command line application

Borland Delphi 7
    The following example shows how to access the SiteKiosk object from Borland Delphi 7

    Before you can access the SiteKiosk Interfaces, you will have to import the Type Library. Click on Project in the menu and choose Import Type Library .... In the list, select SiteKiosk Runtim 1.0 Type Library (Version 1.0) and click on Create Unit. Now, the file 'SiteKioskRuntimeLib_TLB.pas' will be created automatically and is added to your project. Delphi uses a global variable called 'Application' that conflicts with an Enumerated value in SiteKiosk and therefor causes errors when compiling the project. Open 'SiteKioskRuntimeLib_TLB.pas' and search for the occurance of the 'Application' value ( line 197: Application = $00000003; ). Now, either change the name or delete the entire row. Now, your delphi project should be able to compile properly.

    You need to link your project to the 'ActiveX' unit and to the 'SiteKioskRuntimeLib_TLB' unit. 'ActiveX' implements the CoGetClassObject(...) function and SiteKioskRuntimeLib_TLB implements the CLSID's, IID's and interfaces of the SiteKiosk type library. Assure, that your uses-section contains the following code lines:

    Copy to clipboard

    uses
      ActiveX, SiteKioskRuntimeLib_TLB;
    

    The following source code shows, how to get the version of the SiteKiosk instance. If SiteKiosk is not running, the function returns false. If SiteKiosk is running and the version is successfully read, the function return True and the parameter as_Value is filled with SiteKiosk's version.

    Copy to clipboard

    function GetSiteKioskVersion(var as_Version : WideString) : Boolean;
    var
      lr_SiteKioskFactory_ : ISiteKioskFactory;
      lr_ISiteKiosk_ : ISiteKiosk;
      lr_Version_ : ISKVersion;
      lr_IUnknown_ : IUnknown;
      lr_IDispatch_ : IDispatch;
      
    begin
      GetSiteKioskVersion := false;
    
      // get interface of the SiteKioskClass-Factory
      CoGetClassObject(CLASS_SiteKioskFactory, 4, nil,
    IID_ISiteKioskFactory, lr_IUnknown_); if (lr_IUnknown_ = nil) then exit; // SiteKiosk is not running // convert the return value of type IUnknown to the needed interface lr_IUnknown_.QueryInterface(IID_ISiteKioskFactory,
    lr_SiteKioskFactory_); // get the interface of the running instance of SiteKiosk lr_SiteKioskFactory_.CreateSiteKiosk(IID_ISiteKiosk,
    pointer(lr_ISiteKiosk_)); if (lr_ISiteKiosk_ = nil) then exit; // get the version's IDispatch interface lr_IDispatch_ := lr_ISiteKiosk_.Version; if (lr_IDispatch_ = nil) then exit; // query IDispatch for the ISKVersion interface lr_IDispatch_.QueryInterface(IID_ISKVersion, lr_Version_); if (lr_Version_ = nil) then exit; as_Version := lr_Version_.VersionString; GetSiteKioskVersion := true; end;

Applies to
    SiteKiosk v5.0 (and later versions).

Back to topBack to top

© 1997-2008 PROVISIO - Chicago, USA & Muenster, Germany - SiteKiosk DevTeam