I need to find some strings that the current version of Windows is using. For example, when I create a new folder, it is initially named \"New Folder\" on English Vista. I
If you want to handle 80% of the cases, you can start with "New Folder".
As I guess you're in an enterprise environment, you can get the folder names back into a storage, then after a week (or any time) you get through the names; update your app; release the new version which will please the users. (then later publish the results here)
You can preemptively test your app on a range of platform you're suspecting the users to use. to get a first series of folders names.
This will avoid the problem of dealing with code specific with each of the platform you're looking at.
EDIT Well I get a second thought about that, I guess you might want to warn the user about that "New Folder" if it wasn't rename after some time (say a minute)? then I guess you would need to add a list and a timer ...
Shamelessly cribbed from http://blogs.msdn.com/oldnewthing/archive/2004/01/30/65013.aspx. This is mostly correct but if there is a resource string of "New Folder something else" it will match that:
LPCWSTR FindStringResourceEx(HINSTANCE hinst,
UINT uId, UINT langId)
{
// Convert the string ID into a bundle number
LPCWSTR pwsz = NULL;
HRSRC hrsrc = FindResourceEx(hinst, RT_STRING,
MAKEINTRESOURCE(uId / 16 + 1),
langId);
if (hrsrc) {
HGLOBAL hglob = LoadResource(hinst, hrsrc);
if (hglob) {
pwsz = reinterpret_cast<LPCWSTR>
(LockResource(hglob));
if (pwsz) {
// okay now walk the string table
for (int i = 0; i < (uId & 15); i++) {
pwsz += 1 + (UINT)*pwsz;
}
pwsz+= 1;
}
}
}
return pwsz;
}
UINT FindResourceStringId(HMODULE resource_handle, LPCWSTR string, UINT langId)
{
UINT resource_id= -1;
for (int i= 0; i<65536; ++i)
{
LPCWSTR resource_string= FindStringResourceEx(resource_handle, i, langId);
if (resource_string && wcsncmp(resource_string, string, wcslen(string))==0)
{
resource_id= i;
}
}
return resource_id;
}
int main()
{
HMODULE shell_handle= LoadLibraryW(L"shell32.dll");
UINT new_folder_id= FindResourceStringId(shell_handle, L"New Folder", 0x409); // look for US English "New Folder" resource id.
}
This is not easy. These strings are private data for Windows Explorer, and as such they can (and probably do) change between releases. You can hack something up where you do a lot of version checking and read the appropriate resource string, but that seems like a losing battle. What are you trying to accomplish?
Unsure if there is a more elegant way or not (I couldn't seem to find one), but those strings are stored in %windir%\System32\Shell32.dll
. Theoretically, you could merely read that file in and extract the appropriate strings.
Seems a bit hacky-ish, but should get the job done. Here's a link to an article that discusses where they live in said file: http://www.askvg.com/customize-new-folder-and-new-shortcut-text-in-windows-xp/
Seems like there could or even should be an interface to them via the Windows API, but trolling through the documentation I couldn't find one. Perhaps you'll have more luck.