views:

123

answers:

2

I've been looking over the following VB code:

http://www.codeproject.com/KB/vb/toggleNetworkConn.aspx

If you look under "The Methods", you'll see that he does a test to see whether or not the shell item verb is either "En&able" or "Disa&ble" - it looks pretty obvious that these are the same text strings that are listed in the right-click context menu in Network Connections. The obvious problem with this approach (as pointed out by someone in the comments on CodeProject as well) is that this is English-specific; depending on what language the OS is running, it's going to use different words. The programmers response was to potentially use the index of the verb, but this is arguably worse than the original solution, since you would then be performing some arbitrary operation if it wasn't the correct command (and I don't believe it's guaranteed to be in a particular order in the verb list).

So my question, is it possible to get from the system (via some call or the registry) the OS-language specific text for Enable and Disable? I've searched the registry for both strings without any success, but I thought someone with more multi-language experience might have the answer. Also, I'm not using VB (I'll be using C++) so don't worry about doing it in any particular language - API calls or pseudo code is fine. I also need the solution to work on both XP and Vista (and hopefully Windows 7 as well). Thanks!

A: 

It looks like the text for the verbs might be handled via Registry String Redirection. You'll need to identify the CLSID for the connections component. I poked around but didn't find any verbs registered for the network connections CLSIDs I came across though...

sean e
A: 

The closest thing I've found is part of IShellFolder, specifically GetCommandString() which returns a universal string describing an action - in this case it literally returns "enable" or "disable". The problem with this particular API is while it works, it doesn't actually return anything on XP - apparently while it's available on older OSs, it's really only useful on Vista or greater.

Mark