# How to access the ISiteKiosk Interface The following is a C# code sample to demonstrate how to access the ISiteKiosk Interface from other 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 example shows you how to get the current version of SiteKiosk via the ISiteKiosk interface in the C# programming languages. 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:
    using System.Runtime.InteropServices;
    using SiteKioskRuntimeLib;
To import the CoGetClassObject() funtion from ole32.dll add the following code to your global namespace:
    [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.
    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 = Guid.Parse("1CA0D073-4ABB-4D06-B318-BFFDE38E4903");
       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 Applies to SiteKiosk v9.0 (and later versions). Back to top