Get IShellItem for Quick Access? - winapi

This failes with 0x80070057:
SHCreateItemFromParsingName(L"::{679F85CB-0220-4080-B29B-5540CC05AAB6}", NULL, IID_PPV_ARGS(&psi))
While this works for "My Computer":
SHCreateItemFromParsingName(L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", NULL, IID_PPV_ARGS(&psi))
Am I using the wrong GUID for Quick Access?

Note this GUID (CLSID_HomeFolder) is not officially documented.
You must use this type of parsing name instead for it to work (shell: is a url scheme):
SHCreateItemFromParsingName(L"shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}", NULL, IID_PPV_ARGS(&psi));

Related

Arduino Parse Cloud Code

I am trying to pass a variable (emailAddress) to Parse Cloud Code from Arduino.
ParseCloudFunction cloudFunction;
cloudFunction.setFunctionName("SendEmail");
cloudFunction.add("email", emailAddress);
ParseResponse response2 = cloudFunction.send();
However, Parse sees this as a Boolean...
E2015-08-19T16:17:14.622Z]v10 Ran cloud function SendEmail for user XXXXXXXX with:
Input: {"email":true}
Result: Uh oh, something went wrong
Anyone know how to pass the variable without sending as a Boolean?
I had a similar problem and i think i've just solved it.
If you change the datatype for the email address to char* (i'm assuming you were using a string before) then it should work.
I'm not 100% sure why but i think its to do with referencing a pointer. I think parse.com requires a pointer to reference a variable and so a 'String' does not have that and parse.com only sees a boolean. Anyway this may not be quite correct but all i know is when i changed my String to char* it worked!
I took the inspiration from this documentation from Parse http://parse.com/docs/arduino/api/class_parse_object_create.html
Hope it works!

Grails define custom error message for command object

I am writing a Grails (2.3.3 currently) application and have created a validateable command object similar to the following:
#Validateable
class MyCustomCommand {
String name
static constraints = {
name blank: false
}
}
In my i18n/messages.properties file I defined the following properties to override the default error messages.
MyCustomCommand.name.blank=Name must be provided.
MyCustomCommand.name.null=Name must be provided.
Which per the Grails documentation should be of the format [Class Name].[Property Name].[Constraint Code] as I have done. When I run my application if I leave the value blank I still get the default message for a null property.
I also tried following the example of the default messages and defining them a follows, but still get the default message.
MyCustomCommand.name.blank.message=Name must be provided.
MyCustomCommand.name.null.message=Name must be provided.
I am assuming that I am missing something simple here, but have yet to stumble upon what. Any suggestions on what I am doing incorrectly?
It is simple indeed. Message should look like:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.
//className.propertyName.blank (camelCase with first letter of class name lower)
So, as I anticipated it was something simple. I was using the defaults as an example which used null where as what I really needed was nullable. Which does make sense as that matches the constraint name.
Therefore the correct version is:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.

ResourceManager.GetString() not returning value

I am trying to implement multiple language support for my web project. I am new to it.
I am not able to get the resource file value by using ResourceManager.GetString() function. I am passing the name and current CuluralInfo. The resource file present in my App_GlobalResources are Sample.resx, Sample.en-us.resx, Sample.zh-cn.resx and Sample.ar-sa.resx. I am having a name field named "Heading1" and its value in all the resource files
My code is like
string Heading1= Resources.Global.ResourceManager.GetString(("Heading1", Thread.CurrentThread.CurrentCulture);
But it is always returning null value. Please help me to get the solution for this problem
Thanks
San
I found the problem
The code should be like
string Heading1= Resources.Sample.ResourceManager.GetString(name, culture_object);

SecTrustedApplicationCreateFromPath being too smart?

I've got an application that also configures and runs a daemon. I am trying to give both the daemon and the application access permissions to the keychain item. The basic code:
SecKeychainItemRef item;
// create a generic password item
SecTrustedApplicationRef appRef[2];
SecAccessRef ref;
SecTrustedApplicationCreateFromPath( NULL, &appRef[0] );
SecTrustedApplicationCreateFromPath( DAEMON_PATH, &appRef[1] );
CFArrayRef trustList = CFArrayCreate( NULL, ( void *)appRef, sizeof(appRef)/sizeof(*appRef), NULL );
SecAccessCreate( descriptor, trustList, &ref );
SecKeychainItemSetAccess( item, ref );
The keychain entry is created, however the only application listed in the Keychain Access tool as always having access is the main application. Let's call it FOO.app. DAEMON_PATH points to the absolute path of the daemon which is in the application bundle -- call it FOO.daemon.
If I manually go within Keychain Access and select the daemon, it does get added to the list.
Any idea on how to get SecTrustedApplicationCreateFromPath to honor the full/absolute path?
If you need an answer today...
I tried to replace access object for existing keychain item with no success, too. So, I decided to modify existing access object rather than replace it, and this approach works well.
The following pseudocode demonstrates the idea. Declarations, CFRelease()s and error checking are stripped for clarity sake.
SecKeychainItemCopyAccess(item, &accessObj);
SecAccessCopySelectedACLList(accessObj, CSSM_ACL_AUTHORIZATION_DECRYPT, &aclList);
assert(CFArrayGetCount(aclList) == 1);
acl = (SecACLRef)CFArrayGetValueAtIndex(aclList, 0);
SecACLCopySimpleContents(acl, &appList, &desc, &prompt_selector);
SecTrustedApplicationCreateFromPath(MY_APP_PATH, &app);
newAppList = CFArrayCreate(NULL, (const void**)&app, 1, NULL);
SecACLSetSimpleContents(acl, newAppList, desc, &psel);
SecKeychainItemSetAccess(item, accessObj);
I used SecAccessCopySelectedACLList to search for an ACL object with an appropriate authorization tag. You may require some other way for ACL filtering.
The straightforward access object creation must be more tricky, you are to create the same ACL structure as Keychain Access app does, rather than use default SecAccessCreate()'s ACLs. I couldn't cope with that way.

How to run ShellExecute on shell object clsid?

Shell explorer on Windows define global objects such as ::{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0 which is a link to the user "internet browser". I got these value from a shortcut that is drag&dropped over my application, but I can't find how to use it to open it...
I'd like to get information about what this object is too.
Does someone know how to ask Windows about what this object is ?
Does someone know how to open it ?
I have found that these objects can be found by reading from the registry at :
initString = HLCR\CLSID\\{CLSID\}\PersistentBag\InitString
openCommand = HKLM\Software\Clients\{initString}\shell\open\command
Usually its not a good idea to read directly from the registry. I'd be please to have a cleaner way to read these values.
Thanks.
Apparently you need to fill in a SHELLEXECUTEINFO structure, with the fMask field set to SEE_MASK_CLASSKEY, the lpVerb field set to "open" and the lpClass set to your GUID.
However, I never got the damn thing to work. Instead I used a file of the correct type to use in a CreateProcess call.
HINSTANCE h = FindExecutable("blank.htm", NULL, buffer);
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
char url[MAX_PATH];
sprintf(url, "\"%s\" %s", buffer, (LPCTSTR)m_url);
CreateProcess(NULL, url, NULL, NULL, FALSE, 0 , NULL, NULL, &si, &pi);
Which opens the app that is defined as the default viewer for files of type .htm.
From "Creating Shell Extensions with Shell Instance Objects" at http://msdn.microsoft.com/en-us/library/ms997573.aspx it is told that
Whereas a traditional shell extension requires a DLL to implement the object, a shell instance object retrieves everything it needs to know from the registry.
It seems to be safe to read the informations from the registry as it is the documented solution to create them.

Resources