C#/Windows: Get localized default name of "New Folder" - c#

I am using a FileSystemWatcher to check if new directories are created in the watched one. If the user creates it per Explorer -> Rightclick -> New Folder at first a directory "New Folder" is created that the user can rename instantly. Nevertheless I get the Created event on "New Folder", which I can handle.
My problem is that running the software differently localized Windows machines makes it impossible to check against "New Folder". How can I get the name of new folder as used by the explorer in the current language.
Thanks.

See these:
Find localized Windows strings
http://blogs.msdn.com/b/oldnewthing/archive/2004/01/30/65013.aspx
What you need to do is discover the "ID" of the string that is used for "New Folder"....then you can use LoadString to load it from the string table resource inside Shell32.dll.
However, the ID isn't necessarily stable and has changed between editions of Windows.
For instance...XP has the string table set up as follows:
http://www.askvg.com/customize-new-folder-and-new-shortcut-text-in-windows-xp/
On Windows 7 64 bit...the "New Folder" string has an ID of 16888.
You can try 2 different ways to do this ID discovery:
1. By discovering the ID of the "New Folder" string in advance on each edition of Windows you want to support
You would need to write a utility that just called this function on each English/US edition of Windows (XP, Vista, Windows 7, etc)...to find out the ID.
UINT new_folder_id = FindResourceStringId(shell_handle, L"New Folder", 0x409);
You can then do a switch inside your code that used the correct ID depending on the current version of Windows that is running.
2. dynamically at runtime
By looking up the "New Folder" string in the English resource to find its ID. However this would need the English MUI language pack to be installed on the system.
Use this C# code to load a particular "string" given a particular ID.
http://khason.net/blog/how-to-load-unmanaged-native-resources-from-managed-c-code/
To test if your code is working....you could install the MUI language packs and could then attempt to load the string for a different locale.
http://www.microsoft.com/en-gb/download/details.aspx?id=22108
http://support.microsoft.com/kb/972813
http://www.froggie.sk/7lp64sp1.html
http://technet.microsoft.com/en-us/library/cc766472(v=ws.10).aspx
Alternatively you could use SHChangeNotifyRegister to listen to changes made "in the shell"...Explorer calls SHChangeNotify when it does certain things.
Use the code here:
http://www.codeproject.com/Articles/3054/Shell-Notifications-in-C
Use the suitable flags e.g. SHCNRF_ShellLevel, SHCNE_MKDIR.

Related

Specify a start menu name abbreviation for ClickOnce application

I would like to specify an abbreviated Start Menu name for a click once application similar to SQL Server Management Studio (SSMS) or Microsoft Test Manager (MTM). The goal is to have the ability to hit Windows key + r, type the first letter of each word in the application name, and run (ex: type 'MCD' to launch 'Model Car Designer').
NOTE: I don't simply want to change the Start Menu name.
It just boiled down to creating a new key in the registry. This blog post helped get me down the right path.
The new key I created had the same path as my application but I named the key the acronym ('MCD' in the question's example).

Multilanguage application in C#

I am currently building an application in C# which supports French, English and Spanish. I am using resource files (.resx) to store my text following this method I found online. Right now, the resource files I have are the following : TextLabels.resx, TextLabels.en.resx, TextLabels.fr.resx and TextLabels.es.resx.
I use the following method to link my the resource to my form :
manager = new ResourceManager("MyProject.TextLabels", typeof(MyForm).Assembly);
to change the labels when I have selected a new language, I created a refresh method changes the Text attributes of my containers with the method :
Text = manager.GetString("MY_STRING_VARIABLE", culture);
Also, I make sure to change the culture used when the user clicks on the desired using the following method :
culture = CultureInfo.CreateSpecificCulture("es"); //changes the culture to spanish
So here is my problem : I use a 64 bit Windows 7 computer installed in English (I am not sure if it matters) and this method works fine, all my labels are changed in the desired language. The problem occurs when I try use my project on my colleague's computer which is a Windows 7 32 bits computer in French. Using his computer, it looks as if the program (that I have compiled with Visual Studio 2012) can only find the default resource file (TextLabels.resx). So I am at a loss here and wondering 1. Is the 32 bit system or French installation of Windows the reason of my problem or is it something else and how can I make my application work on his machine?
If you are generating localized binaries, be sure that they get deployed with the app.
They would be in the /bin/Debug and /bin/Release folders.

Set Process 'image name' and 'description' wtih C#

I want to go into as much detail as possible so this question is easily understood and answer-able
Essentially I need a way set up the process name and process description with C# on the applications startup.
Here is an example of what I would like changing;
Note: I want to set my OWN C# applications image and description with CODE.
I want to be able to change the following things in my application on startup.
Image Name in the Processes list, as well as the Description in the Processes list.
So far in my C# application i can set the process name with the properties but id rather be able to set it with some sort of code snippet (as well as the description).
I hope this has been a information question and you good clever people at stackoverflow can help.
You can't change the image name. It's the name of your executable file.
The process description, however, can be changed on your C# project assembly info:
Right click on your C# project in Visual Studio > Properties > Application > Assembly information > Title.
You can't change the description at runtime from code: the OS loads the description at startup from the Version Information file resource.
The Image Name property is the name of the executable itself (ie Foobar.exe), the Description property is the Title of the application in the Assembly Information dialogue box, as shown below:
At this point, when you run your program, you will see two entries into the task manager as shown below:
One will say the name you specified in the Title box, the other will say vshost32.exe as the description. To fix this, untick the option called Enable the Visual Studio hosting process in the project properties page.
As close as I can come to an answer is to pragmatically create a new executable with the desired name and description launch that executable then allow your launch process to die.
Try using your application as a 'host' for another app.
As soon as the application is launched, it downloads a file from a dropbox link (a direct download link) and saves it locally, (In the temp folder probably).
Then our application launches that application and then kills itself with maybe an error.
now the process running on that one would be gone, and we have a new process with our set title and description. Easy!

start .net application from start menu search

bla.exe (application alias) points to a .net application called wpfapp1.exe.
When i add a key&value to eg. this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\bla.exe
and then start application using Run -> bla.exe it starts
however when i start application using windows search i get an "windows cannot find wpfapp1.exe. make sure you typed the name correctly, and then try again."
I have successfully identified problem: this error only occurs to .net applications while native one start normally (eg. firefox.exe).
So is there any .net config that i've missed during development?
From MSDN:
The App Paths key is not used when
computing the DLL search path.
Maybe you're missing some dependent DLL...
I don't really understand your "points to" or if Windows search is specific to using the explorer search or using the start menu search.
I've had a similar problem with another application that the search could not find at all, neither in Explorer or Start menu (since it did not have an indexed folder to locate it) and solved it with a simple shortcut.
If you can create a shortcut of your application in your start menu or some other indexed folder, like a %PATH% folder, Windows search should be able to pick it up and then you can name your shortcut to whatever you want, for instance bla.exe.

How to create a shortcut using wix that could change depending on a user's system

I have created a Wix installer that places 3 shortcuts onto the desktop. One of these shortcuts references the user's DVD Drive. Is there a way to dynamically set the target of this shortcut based on that drive letter? Would a custom action be the way to go? If so how would I change the target of a shortcut using that custom action. I have been writing my custom actions in C# and would hope to continue doing so.
Thanks for any help.
You can set the target of a shortcut with the value of a property. For example, the following will take the value of the MYSTUFF property as the target:
<Shortcut Id="MyStuffShortcut" Name='My Stuff' Target="[MYSTUFF]" />
There is no standard windows installer property for "the DVD drive". I'm not sure what that would even mean if there were multiple DVD drives. You can use ROOTDRIVE to refer to the local drive with the most free space. You can use SourceDir to refer to the root of the drive where the installer is being executed from.

Categories