Date: | April 29, 2013 / year-entry #116 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20130429-00/?p=4523 |
Comments: | 2 |
Summary: | Today's Little Program takes the symbolic name for a shell property and returns a string suitable for display to the end-user, translated into the user's specified display language. #include |
Today's Little Program takes the symbolic name for a shell property and returns a string suitable for display to the end-user, translated into the user's specified display language. #include <windows.h> #include <ole2.h> #include <propsys.h> #include <propkey.h> #include <atlbase.h> #include <atlalloc.h> int __cdecl wmain(int argc, PWSTR argv[]) { CCoInitialize init; if (SUCCEEDED(init) && argc == 2) { CComPtr<IPropertyDescription> spdesc; if (SUCCEEDED(PSGetPropertyDescriptionByName( argv[1], IID_PPV_ARGS(&spdesc)))) { CComHeapPtr<wchar_t> spszName; if (SUCCEEDED(spdesc->GetDisplayName(&spszName))) { wprintf(L"%ls\n", static_cast<PWSTR>(spszName)); } } } return 0; }
Run this program with the string
System. The actual workings of the program is pretty straightward. We ask the property system for an interface that describes the property name, and ask that interface to give us the display name, which we print out. Nothing fancy here. The trick is just knowing that the function exists in the first place. |
Comments (2)
Comments are closed. |
Is there a function to list all registered properties, or all properties of an object?
The weird part is that it doesn't return a BSTR. Is there a reason for this?
BSTR
. This is not an automation interface. -Raymond]