Search Unity

Disable Charms Bar

Discussion in 'Windows' started by Subliminalman, Jul 6, 2015.

  1. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    I created an application that is set up in a museum as a kiosk. Users are not supposed to be able to interact with anything outside the application itself but because we are using Windows 8.1 they have access to the Charms Bar. We have tried a lot of things including a Native Plugin (which could still work but it is crashing the app right now).

    I really need help because the app is live currently and people have accidentally opened the charms bar already.


    Also here is the plugin I wrote based off of Microsoft example code. (Currently crashes the app).
    Disable.cpp
    Code (csharp):
    1.  
    2. #include "stdafx.h"
    3. #include <string>
    4. #include <propkey.h>
    5. #include <propsys.h>
    6. #include <cstdlib>
    7.  
    8. #define DLLExport __declspec (dllexport)
    9.  
    10. namespace DisableCharms
    11. {  
    12.     extern "C"
    13.     {
    14.         DLLExport std::string DisableCharmsBar()
    15.         {
    16.             HWND window;
    17.             window = FindWindow(NULL, TEXT("ABCD"));
    18.  
    19.             std::string msg = "FoundWindow";
    20.  
    21.             if (window != 0)
    22.             {
    23.  
    24.                 IPropertyStore* pPropStore;
    25.                 HRESULT hrReturnValue = SHGetPropertyStoreForWindow(window, IID_PPV_ARGS(&pPropStore));
    26.                 if (SUCCEEDED(hrReturnValue))
    27.                 {
    28.                     PROPVARIANT var;
    29.                     var.vt = VT_BOOL;
    30.                     var.boolVal = VARIANT_TRUE;
    31.                     hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
    32.                     pPropStore->Release();
    33.                 }            
    34.             }
    35.  
    36.  
    37.             msg = "Could not find window: ";
    38.             msg += winName;
    39.  
    40.             return msg;
    41.         }
    42.     }
    43. }
    44.  
    CharmsBar.cs
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Runtime.InteropServices;
    5.  
    6. public class CharmsBar : MonoBehaviour {
    7.  
    8.     [DllImport ("DisableDLL")]
    9.     private static extern string DisableCharmsBar();
    10.  
    11.     // Use this for initialization
    12.     void Awake () {
    13.         string log = DisableCharmsBar();
    14.  
    15.         Debug.Log (log);
    16.     }
    17. }
    18.  
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,900
    Why are you not disabling it in PC settings? Because this doesn't something the application should control
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    You should also run WACK on your app immediately. I have doubts that those functions you call from plugin are allowed.
    Check the call convention on your exported function, it should be __stcall and I think that depends on the placement of dllexport (before or after the return type).
     
  4. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    The charms bar access via swiping seems to be impossible to disable unless you are at a very low level. What we did eventually is just kill out the explorer.exe completely so the user cannot access anything besides the app.