Using the Registry in Powerbuilder to check and change the short date format so it is compliant

Cut and Paste this code into your application object open event before the application actually opens

//Declare variables

string ls_longdate, ls_shortdate

int li_response

//Get the current shortdate settings

RegistryGet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", ls_shortdate)

//investigate if it is complaint

if Pos(ls_shortdate,"yyyy") = 0 then

//Check if user would like it changed

li_response = Messagebox( "Control Panel Caution", "Your short date setting will be changed to dd/mm/yyyy for Year 2000 compliance,&

~r~n Do you want to continue?" ,Question!,yesno!)

//Change the settings

if li_response =1 then

RegistrySet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", "dd/MM/yyyy")

Messagebox("Information","Your date settings have been changed successfully")

Else

//Warn user if they opted not to change and close application

Messagebox("Warning","The Application will not function properly unless you change your date settings to dd/mm/yyyy")

Halt close

Return

End if

Else

Messagebox ("Shortdate Info", "Passed") // this can be removed from the runtime application

Return

End if

Shortdate - Another copy

Email the Webmaster

Return to Powerbuilder Solutions Page