[solved] SHGetPropertyStoreForWindow
Posted: Mon Oct 30, 2017 3:17 pm
Hi,
I'm trying to ultimately set DisableTouchWhenFullscreen to true so I can have a full screen app without being able to swipe open from the right. I don't want to set the device into kiosk mode as I just want it to be disabled when this app is running. I've not managed that so I tweaked things to try and read some values to see if the calls were working, and they dont seem to be.
Can you see any reasons why I'm unable to read anything from GetValue, or why GetCount returns 0?
I've taken bits of code from different places as noone seemingly has done this before (links are inline).
Your help is appreciated.
Julian
I'm trying to ultimately set DisableTouchWhenFullscreen to true so I can have a full screen app without being able to swipe open from the right. I don't want to set the device into kiosk mode as I just want it to be disabled when this app is running. I've not managed that so I tweaked things to try and read some values to see if the calls were working, and they dont seem to be.
Can you see any reasons why I'm unable to read anything from GetValue, or why GetCount returns 0?
I've taken bits of code from different places as noone seemingly has done this before (links are inline).
Your help is appreciated.
Julian
Code: Select all
;https://stackoverflow.com/questions/19889683/how-do-i-turn-off-windows-8-1-gestures-and-setting-charm-bar-on-my-touch-screen
;http://www.purebasic.fr/english/viewtopic.php?t=32319
Structure PROPVARIANT_CLIPDATA
cbSize.l
ulClipFmt.l
*pClipData.BYTE
EndStructure
Structure PROPVARIANT_BSTRBLOB
cbSize.l
*pData.BYTE
EndStructure
Structure PROPVARIANT_BLOB
cbSize.l
*pBlobData.BYTE
EndStructure
Structure PROPVARIANT_VERSIONEDSTREAM
guidVersion.GUID
*pStream.IStream
EndStructure
Structure PROPVARIANT_CAC
cElems.l
*pElems.BYTE
EndStructure
Structure PROPVARIANT_CAUB
cElems.l
*pElems.BYTE
EndStructure
Structure PROPVARIANT_CAI
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CAUI
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CAL
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAUL
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAFLT
cElems.l
*pElems.FLOAT
EndStructure
Structure PROPVARIANT_CADBL
cElems.l
*pElems.DOUBLE
EndStructure
Structure PROPVARIANT_CACY
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CADATE
cElems.l
*pElems.DOUBLE
EndStructure
Structure PROPVARIANT_CABSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CABSTRBLOB
cElems.l
*pElems.PROPVARIANT_BSTRBLOB
EndStructure
Structure PROPVARIANT_CABOOL
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CASCODE
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAPROPVARIANT
cElems.l
*pElems.PROPVARIANT
EndStructure
Structure PROPVARIANT_CAH
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CAUH
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CALPSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CALPWSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CAFILETIME
cElems.l
*pElems.FILETIME
EndStructure
Structure PROPVARIANT_CACLIPDATA
cElems.l
*pElems.PROPVARIANT_CLIPDATA
EndStructure
Structure PROPVARIANT_CACLSID
cElems.l
*pElems.CLSID
EndStructure
Structure PROPVARIANT Align #PB_Structure_AlignC
vt.w
wReserved1.w
wReserved2.w
wReserved3.w
StructureUnion
cVal.b
bVal.b
iVal.w
uiVal.w
lVal.l
ulVal.l
intVal.l
uintVal.l
hVal.q
uhVal.q
fltVal.f
dblVal.d
boolVal.w
scode.l
cyVal.q
date.d
filetime.FILETIME
*puuid.CLSID
*pclipdata.PROPVARIANT_CLIPDATA
bstrVal.i
bstrblobVal.PROPVARIANT_BSTRBLOB
blob.PROPVARIANT_BLOB
*pszVal
*pwszVal
*punkVal.IUnknown
*pdispVal.IDispatch
*pStream.IStream
*pStorage.IStorage
*pVersionedStream.PROPVARIANT_VERSIONEDSTREAM
*parray.SAFEARRAY
cac.PROPVARIANT_CAC
caub.PROPVARIANT_CAUB
cai.PROPVARIANT_CAI
caui.PROPVARIANT_CAUI
cal.PROPVARIANT_CAL
caul.PROPVARIANT_CAUL
cah.PROPVARIANT_CAH
cauh.PROPVARIANT_CAUH
caflt.PROPVARIANT_CAFLT
cadbl.PROPVARIANT_CADBL
cabool.PROPVARIANT_CABOOL
cascode.PROPVARIANT_CASCODE
cacy.PROPVARIANT_CACY
cadate.PROPVARIANT_CADATE
cafiletime.PROPVARIANT_CAFILETIME
cauuid.PROPVARIANT_CACLSID
caclipdata.PROPVARIANT_CACLIPDATA
cabstr.PROPVARIANT_CABSTR
cabstrblob.PROPVARIANT_CABSTRBLOB
calpstr.PROPVARIANT_CALPSTR
calpwstr.PROPVARIANT_CALPWSTR
capropvar.PROPVARIANT_CAPROPVARIANT
*pcVal.BYTE
*pbVal.BYTE
*piVal.WORD
*puiVal.WORD
*plVal.LONG
*pulVal.LONG
*pintVal.LONG
*puintVal.LONG
*pfltVal.FLOAT
*pdblVal.DOUBLE
*pboolVal.WORD
*pdecVal.VARIANT_DECIMAL
*pscode.LONG
*pcyVal.QUAD
*pdate.DOUBLE
*pbstrVal.INTEGER
*ppunkVal.INTEGER
*ppdispVal.INTEGER
*pparray.INTEGER
*pvarVal.PROPVARIANT
EndStructureUnion
EndStructure
Structure PROPERTYKEY
fmtid.GUID
pid.i
EndStructure
;http://purebasic.info/phpBB3ex/viewtopic.php?f=13&t=4112
Interface IPropertyStore Extends IUnknown ; https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb761474%28v=vs.85%29.aspx
Commit()
GetAt.l (iProp, *pkey.PROPERTYKEY)
GetCount(*cProps)
GetValue(key.PROPERTYKEY, *pv)
SetValue(key.PROPERTYKEY, *propvar)
EndInterface
Prototype.i SHGetPropertyStoreForWindow(hwnd.i, *riid.CLSID, ppv.l)
Prototype CLSIDFromString(str.p-bstr, *pClsID.CLSID)
Procedure CLSIDFromString(*string, *pClsID.CLSID)
hres = CLSIDFromString_(*string, *pClsID)
If hRes = #NOERROR
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
Procedure DoIt()
If OpenLibrary(0, "Shell32.dll")
SHGetPropertyStoreForWindow.SHGetPropertyStoreForWindow = GetFunction(0, "SHGetPropertyStoreForWindow")
Define *propstore.IPropertyStore
Define g.CLSID
ss.s = "{886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99}"
ok = CLSIDFromString(@ss, @g)
Debug("CLSID ok=" + ok)
ok = SHGetPropertyStoreForWindow(WindowID(0), @g, @*propstore)
Debug("SHGetPropertyStoreForWindow ok=" + Hex(ok))
If ok = 0
Define myKey.PropertyKey
; Define c.l
; ok = *propstore\GetCount(@c)
; Debug ("GetCount ok=" + Hex(ok))
; Debug ("c=" + c) ; nothing returned here
;cant use this nothing is returned above
;ok = *propstore\GetAt(0, myKey)
;Debug ("GetAt ok=" + Hex(ok))
;make sure these are correct
Debug("#VT_EMPTY=" + #VT_EMPTY)
Debug("#VT_BOOL=" + #VT_BOOL)
Debug("#VARIANT_TRUE=" + #VARIANT_TRUE)
Debug("#INPLACE_S_TRUNCATED=" + #INPLACE_S_TRUNCATED)
ss.s = "{32CE38B2-2C9A-41B1-9BC5-B3784394AA44}" ; System.EdgeGesture.DisableTouchWhenFullscreen
;ss.s = "{7D683FC9-D155-45A8-BB1F-89D19BCB792F}" ; System.Identity.DisplayName
ok = CLSIDFromString(@ss, @myKey\fmtid)
Debug("CLSID ok=" + ok)
myKey\pid = 2 ; System.EdgeGesture.DisableTouchWhenFullscreen
;myKey\pid = 100 ; System.Identity.DisplayName
Define propvar.PROPVARIANT
Define *pv.PROPVARIANT = @propvar
;https://msdn.microsoft.com/en-us/library/windows/desktop/bb761473%28v=vs.85%29.aspx
ok = *propstore\GetValue(@myKey, @pv)
Debug ("GetValue ok=" + Hex(ok))
;Define *pVar.PROPVARIANT = @pv
;pVar\vt = #VT_BOOL
;pVar\boolVal = #VARIANT_TRUE
;ok = *pPropStore.IPropertyStore\SetValue(pPropertyKey, pVar.PROPVARIANT)
;Debug("set ok=" + ok)
Debug("pv\vt=" + *pv\vt)
Debug("pv\boolVal=" + *pv\boolVal)
Debug("pv\bstrVal=" + *pv\bstrVal)
*propstore\Release()
EndIf
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 400, 100, "Test", #PB_Window_SystemMenu | #PB_Window_Maximize)
ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
Repeat
Event = WaitWindowEvent()
If event = #PB_Event_Gadget
hit = EventGadget()
If hit = 0
DoIt()
EndIf
EndIf
Until event = #PB_Event_CloseWindow
EndIf