windows IPropertyStore handler extension doesn't return property values - windows-shell

I'm trying to write a property handler for a file type our product creates I'm mostly there but the handler is failing to return any data via IPropertyStore::GetValue.
I can see via tracing/debugging that the Initialise method is being called and filling the store up with values.
But I can see that whenever GetValue is called although the key is being found in the store the variant has no data in it! if at that point I do something like:
InitPropVariantFromString(L"BLANK", pPropVar);
into the outval then it all works and BLANK will appear on the InfoTip.
Curiously if I write a test app that uses SHGetPropertyStoreFromParsingName and ask for the property I get the correct data back.
bit stumped really, anyone?
TIA

Fixed - my stupid.
I was defining my property keys incorrectly. Its appears that the whole property key union needs "filling"
like so
const PROPERTYKEY PK_TING={{0x96892702, 0xc272, 0x4792, 0xa2, 0x7, 0xdf, 0xe7, 0xd5, 0x60, 0xd6, 0xb8}, THE_PID};
is using both the guid and the pid of the PROPERTYKEY UNION.
sweetasanut.

Related

Problem with Objective-C marshalling an "optionals" property in Nativescript

I'm building a NativeScript plugin for iOS to integrate a card payment terminal as an external accessory. It is almost done, and working, but I have problem with passing one argument called "optionals". This is the whole code I'm trying to implement. It's the payworks framework for a Miura terminal. http://www.payworks.mpymnt.com/node/143
MPTransactionParameters *tp = [MPTransactionParameters chargeWithAmount:[NSDecimalNumber decimalNumberWithString:#"5.00"]
currency:MPCurrencyEUR
optionals:^(id<MPTransactionParametersOptionals> _Nonnull optionals) {
optionals.subject = #"Bouquet of Flowers";
optionals.customIdentifier = #"yourReferenceForTheTransaction";
}];
I cannot find a way of sending this "optionals" function.
In the generate typing metadata I see the MPTransactionParametersOptionals is a #protocol, but still don't know how to use it here as a parameter.
This is my current javascript code for the block
const tp = MPTransactionParameters.chargeWithAmountCurrencyOptionals(
amount,
MPCurrencyEUR,
function (optionals) {
console.log(optionals); //logs the newly created MPTransactionParameters instance, with set amount and currency properties, but cannot touch or set the optional properties.
}
);
The 3rd parameter of chargeWithAmountCurrencyOptionals() should be a function, but I'm doing it wrong, and searched everywhere in google how to do it but no success. I'm already trying for 2 days.
It is working, when the 3rd parameter is null, but I need the set the optional properties.
EDIT: adding the metadata. There are a lot of typings for MPtransactionParameters, so I decided to give you the whole file so you can search.
https://drive.google.com/open?id=1kvDoXtGbCoeCT20b9_t2stc2Qts3VyQx
EDIT2: Adding the typings:
https://drive.google.com/open?id=1lZ3ULYHbX7DXdUQMPoZeSfyEZrjItSOS

Passing Null value to a COM function from ruby

I am writing an utility that creates Requirements in Quality Center using OTA (Open Test Architecture) api and ruby.
OTA is written in VB and is exposed as COM functions.
To create a blank requirement, we have to use a method called AddItem. The OTA document describes the addItem as follow:
Visual Basic
Public Function AddItem( _
ByVal ItemData As Variant _
) As Object
ItemData:
Null. Creating a virtual Req object with Null ensures that you cannot then Post until all required fields are initialized.
My problem is, I want to pass VB's Null value from ruby to the addItem function. I have tried to pass nil but it is of no use.
Can anyone please help me to solve the above problem.
Thanks in advance.
Prasant Sutaria
The function takes a Variant, so you are being asked to pass a "Variant Null". A Variant Null is a Variant initialized with the special type of VT_NULL.
I don't know how you do that in Ruby, but with some help I can try guessing it looks something like this:
WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_NULL)
Does that help?

How to read pair in freemarker

I'm having little trouble with reading pair.
So I'm creating my pair
private Pair<Integer, Integer> count(somethink) {
int c1 = 2;
int c2 = 4;
return new Pair<Integer, Integer>(c1, c2);
}
And 'sending' it to ftl via java
mv.addObject("counted", count(somethink));
I won't write everything how it sends because I don't think it really matters with my issue. So i'm recieving it in "ftl". Then I was trying to 'read' it.
<#list counted?keys as key>
<#spring.message "someMsg"/>(${key}/${counted[key]})
</#list>
After then I'm getting error
Expecting a string, date or number here, Expression x is instead a freemarker.ext.beans.SimpleMethodModel
As I suppose you don't iterate pairs (or I'm wrong?) I know its pair that contains only one key and one value but still I have to do send it that way and I thought its going be to similar to iterating through map, in Java I would use pair.first() and pair.second() but it doesn't work in ftl (yes I know it shouldn't work). I also tried to cast it to String by using ?string but it didnt work too
have you tried?
${counted.first()?xml}/${counted.second()?xml}
Assuming pair.first() and second() work in your Java code.
I'm not sure how the API of Pair looks, but with ?keys you probably unwillingly list its methods. Hence the error message; you try to print the method itself, not its return value. (As of the broken error message, because there's no x there, a FreeMarker update would help.) So as Caleryn says, just call the two methods. If you need to list this thing, you probably need to put it into a List or array, unless Pair implements List (or even just Collection) or Iterable. Or if this is a bigger issue in your project, FreeMarker has this pluggable configuration component, the ObjectWrapper, and with that you can tell FreeMarker to treat Pair-s as lists, and how. That needs some deeper understanding of FreeMarker though.

How to get the screen auto-rotate's status?

How to get the screen auto-rotate's status (disable or enable) by Regetry or ACPI in windows8?
I need to disable screen auto-rotate, and I will use winkey + O to change the screen auto-rotate control.
Does anyone have similar experiences?
Below maybe helpful if you want to change auto-rotate status:
//C++
typedef BOOL (WINAPI* SETAUTOROTATION)(BOOL bEnable);
SETAUTOROTATION SetAutoRotation = (SETAUTOROTATION)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), (LPCSTR)2507);
if(SetAutoRotation != NULL)
{
SetAutoRotation(TRUE);
}
or
//C#
[DllImport("user32.dll", EntryPoint = "#2507")]
extern static bool SetAutoRotation(bool bEnable);
SetAutoRotation(true);
I found the answer.
public enum tagAR_STATE : uint
{
AR_ENABLED = 0x0,
AR_DISABLED = 0x1,
AR_SUPPRESSED = 0x2,
AR_REMOTESESSION = 0x4,
AR_MULTIMON = 0x8,
AR_NOSENSOR = 0x10,
AR_NOT_SUPPORTED = 0x20,
AR_DOCKED = 0x40,
AR_LAPTOP = 0x80
}
[DllImport("user32.dll")]
public static extern bool GetAutoRotationState(ref tagAR_STATE input);
Hope that can help the other people.
This MSDN example appears to do the job, using what looks like an 'official' API call, SetDisplayAutoRotationPreferences, which is in User32.dll (not kernel.dll as the example states) and is defined in WinUser.h.
The advantage of this example over the other suggestions is that it first checks whether auto-rotation is supported and enabled first.
The registry and Windows+O hotkey work at the system level, tweaking a user setting. Applications aren't supposed to mess with it. There is an application-level way to set autorotation preferences, and once the user closes your app or switches to a different one, then their existing settings (or the other app's) take over.
MSDN has a good example of using the relevant APIs here: https://code.msdn.microsoft.com/windowsapps/Auto-Rotation-Preferences-87ae2902
If your app has only one autorotation preference that it keeps throughout its lifetime, then it is simplest to just set it in your manifest. There are a few options there that you don't get with the APIs such as supporting both landscape and landscape flipped.
Another alternative, and this is the one that seems to work consistently on my tablet. Check this registry key. You can also change the key and the device will immediately pick up the change:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AutoRotation
Setting: Enable
It's a DWORD, so set to 0 to disable auto-rotate or 1 to enable auto-rotate.
Now, if only I could find a way to force the app to work in Landscape mode only!...

AppScript issues with Cocoa NSString and AppleScript text types?

In one of my Applications I've added a few new properties to the document class of the Standard AppleScript suite. Some of these properties have the type text, others have the type boolean. I've written a "sdef" file and added if to the resources of my App.
But when I launch the App, there are messages in the Console like this:
.sdef warning for type 'text' attribute 'title' of class 'window' in
suite 'Standard Suite': AppleScript name references may not work for
this property because its type is not NSString-derived.
And when I actually try to get the value from such a new property with type text from within an AppleScript, it will fail. The correct method within my App is called, and it returns the correct value as NSString, but the AppleScript returns with an error. There's a message in the Console again:
Error while returning the result of a script command: the result
object... "the requested NSString value" ...could not be converted to
an Apple event descriptor of type 'text'. This instance of the class
'__NSCFString' returned nil when sent -objectSpecifier (is it not
overridden?) and there is no coercible type declared for the scripting
class 'text'.
Which probably means that it was not possible to convert the Cocoa NSString object into an AppleScript text object.
When I try to get the value from one of the new boolean properties, it works just fine.
What exactly do I need to do to convert a NSString object into an AppleScript text object?
I suspect you need to coerce the text parameter into a NSString.
I.e
Set sometextString to current application's NSString's stringwithTring:atext
Use it in your method
And to return it you do.
Return sometextString as text

Resources