In summary: I searched MSDN and thought to create my own SetValue
but I can\'t find any sourcecode for it. It\'s not in a DLL, its like InitPropVariantFromStr
Solved, I had to use VTBL: https://github.com/Noitidart/_scratchpad/blob/master/IPropertyStore%20COM%20jsctypes.js
The order of the defintions in the Vtbl
matter big time. So make sure its correct if you want to do something with Vtbl
s
var IPropertyStoreVtbl = new ctypes.StructType('IPropertyStoreVtbl');
var IPropertyStore = new ctypes.StructType('IPropertyStore', [{
'lpVtbl': IPropertyStoreVtbl.ptr
}]);
this.IPropertyStorePtr = new ctypes.PointerType(IPropertyStore);
IPropertyStoreVtbl.define(
[{ //start inherit from IUnknown
'QueryInterface': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr,
this.REFIID, // riid
this.VOIDPTR // **ppvObject
]).ptr
}, {
'AddRef': ctypes.FunctionType(ctypes.stdcall_abi,
this.ULONG, [
IPropertyStore.ptr
]).ptr
}, {
'Release': ctypes.FunctionType(ctypes.stdcall_abi,
this.ULONG, [
IPropertyStore.ptr
]).ptr
}, { //end inherit from IUnknown //start IPropertyStore
'GetCount': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr,
this.DWORD.ptr // *cProps
]).ptr
}, {
'GetAt': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr,
this.DWORD, // iProp
this.PROPERTYKEY.ptr //*pkey
]).ptr
}, {
'GetValue': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr,
this.REFPROPERTYKEY, // key
this.PROPVARIANT.ptr // *pv
]).ptr
}, {
'SetValue': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr,
this.REFPROPERTYKEY, // key
this.REFPROPVARIANT // propvar
]).ptr
}, {
'Commit': ctypes.FunctionType(ctypes.stdcall_abi,
this.HRESULT, [
IPropertyStore.ptr
]).ptr
}]
);
Then to get the IPropertyStore
of a window:
var ppsPtr = new ostypes.IPropertyStorePtr();
var hr_SHGetPropertyStoreForWindow = _dec('SHGetPropertyStoreForWindow')(cHwnd, IID_IPropertyStore.address(), ppsPtr.address());
checkHRESULT(hr_SHGetPropertyStoreForWindow, 'SHGetPropertyStoreForWindow');
var pps = ppsPtr.contents.lpVtbl.contents;
now you can use IPropertyStore :: SetValue
and IPropertyStore :: Release
but make sure to pass the ppsPtr
as first argument to them then the remaining arguments are what you would expect: var hr = pps.SetValue(ppsPtr, firstArgOf_SetValue, secondArgOf_SetValue)
adding copy paste runnable script from scratchpad. Copy and paste this: http://pastebin.mozilla.org/8429999
this will do the equivalent of this XPCOM:
var win = Services.wm.getMostRecentWindow(null);
Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar).setGroupIdForWindow(win, 'Contoso.Scratch')
Yes its long but the good thing about it is, there is no XPCOM to set RelaunchCommand
and RelaunchIconResource
etc. Thats why js-ctypes is needed.