Skip to main content

[archive] GetProfileStringA shortdate format

  • April 13, 2010
  • 6 replies
  • 0 views

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!

6 replies

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
after more research, I found a better way to get what I am after...


CALL "Kernel32.dll".
CALL "GetSystemDefaultLCID"
    GIVING WS-LCID
END-CALL.
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetLocaleInfoA" USING
    BY VALUE WS-LCID,
    BY VALUE LOCALE_SSHORTDATE
    BY REFERENCE WS-DATE-FORMAT
    BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
According to API documentation, size is supposed to be passed by value, not reference. Hence, change this line:
BY REFERENCE WS-SIZE
to
BY VALUE WS-SIZE

You don't list your declaration of data items in the GetLocaleInfo example, but at least WS-SIZE has the same issue here.

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
According to API documentation, size is supposed to be passed by value, not reference. Hence, change this line:
BY REFERENCE WS-SIZE
to
BY VALUE WS-SIZE

You don't list your declaration of data items in the GetLocaleInfo example, but at least WS-SIZE has the same issue here.

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
According to API documentation, size is supposed to be passed by value, not reference. Hence, change this line:
BY REFERENCE WS-SIZE
to
BY VALUE WS-SIZE

You don't list your declaration of data items in the GetLocaleInfo example, but at least WS-SIZE has the same issue here.

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
According to API documentation, size is supposed to be passed by value, not reference. Hence, change this line:
BY REFERENCE WS-SIZE
to
BY VALUE WS-SIZE

You don't list your declaration of data items in the GetLocaleInfo example, but at least WS-SIZE has the same issue here.


Thanks Gisle

What is the general rule for when to use by reference and by value? Or is there one? :-)

[Migrated content. Thread originally posted on 13 April 2010]

I'm trying to grab the Short date format from the api windows XP Pro (in windows you can get to this thru control panel - regional and language settings - Customize - Date).

Can anyone see what's wrong with this code? all I seem to be getting is back is just some random string of text like "1 Lists1048".

77 WS-DATE-FORMAT  PIC X(11)   VALUE IS SPACES.       
77 WS-SIZE               PIC X(4) COMP-N. 

CALL "Kernel32.dll".
MOVE SPACES TO WS-DATE-FORMAT.
SET WS-SIZE TO SIZE OF WS-DATE-FORMAT.
CALL "GetProfileStringA" USING
        BY REFERENCE "Intl",
        BY REFERENCE "sShortDate",
        BY REFERENCE "",
        BY REFERENCE WS-DATE-FORMAT
        BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-DATE-FORMAT REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "Kernel32.dll".


The reason I want this is because the stupid MS DTPIcker control lets you customize the date, but when you set the MINDATE or MAXDATE on it, then it needs to be in the format from the regional settings, the MIN and MAX date on the control don't use your custom date format!
Difficult, because of a lot of inconsistency. By large, when a variabletype (or name) is prefixed with LP that would be BY REFERENCE, by concequence, no such prefix means BY VALUE.
If an asterix is in the suffix of the datatype or a prefix to the dataname, this also indicates BY REFERENCE.