Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 VB
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:
//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 21-Feb-13 5:22am
Comments
CHill60 at 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) at 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 at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 565
1 Maciej Los 359
2 Kornfeld Eliyahu Peter 309
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100