Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I wrote a C# Application "Tool" to change the sShortDate RegKey entry("Control Panel\International") for the CurrentUser to a format which is used by another VB6 Application.

The Tool works on Win7 and the VB6 Application uses the new RegKey.

The problem comes into play when I use the Tool on Win-XP, then the VB6 Application ignores the change and uses the "old" RegKey entry for sShortDate.

When going to Control Panel > Regional Settings and just "re-applying" the sShortDate format which the Tool already set it to, then the VB6 Application uses it...

Why does the RegKey update work on Win7 for all applications started but not on Win-XP?
(I'm calling the user32.dll-SendMessageTimeoutA to let the applications know of the change)

Code Sample below:
C#
//Registry Logic
//Open Sub key
Microsoft.Win32.RegistryKey rkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
if (rkey != null)
{
 rkey.SetValue("sShortDate", dateFormat);
 //Close the Registry
 rkey.Close();
}
int dwError = 0;
SendMessageTimeoutA(m_hWnd, m_msg, 0, "International", SMTO_BLOCK, 10000, dwError);


Any idea why the VB6 Application is not taking the new RegKey entry value for the sShortDate would be of great help.

Kind regards,
TiCKoMasta
Posted
Comments
CHill60 21-Feb-13 10:29am    
Have you tried running the Tool and then using RegEdit to view the registry entry - it's less likely that VB6 is picking up the wrong regkey than the Tool is not actually updating the correct registry key - could be a permissions thing
Chris Reynolds (UK) 21-Feb-13 10:33am    
Worth using Process Monitor from Sysinternals http://technet.microsoft.com/en-gb/sysinternals/bb896645.aspx to see exactly what is happening. You'll then see exactly what keys are being written to and read from, also you'll see any permissions errors as noted by chill60 above. Well worth getting acquainted with that tool for this sort of problem.
TiCKoMasta 21-Feb-13 14:56pm    
Chris: Ok, thanks Chris will try using the Process Monitor.

Chill60: I have the regEdit open and can see that it does update the entry, it's just on Win-XP that it seems like it's not being used by the VB6 Application, but on Win7 the VB6 Application reads it fine. It's as if on Win-XP it's reading it from somewhere else than that specific RegKey entry. x_x
CHill60 21-Feb-13 18:50pm    
Definitely folllow the route that CR(UK) has suggested. Could also try writing it to machine level rather than User level ... have seen instances where my user id changed from PC to PC so could be looking at *wrong* user setting? systinternals tool will help with this

1 solution

Hi, found out what was going on.

For some reason you need to set an additional RegKey in Win-XP:

iDate

This RegKey seems to be combined with the sShortDate entry to handle DateFormating in VB6 on Win-XP.

The strange thing is is that it does not have to be set when using the same VB6 Application in Win7, so my guess is that the Windows7 has a internal API method that is different to the one used in Win-XP.

Thanks for the reply tho, hope this solution helps some lonely VB6 coder somewhere. :P

Kind regards,
TiCKoMasta
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900