Question GetDateFormatEx - how to access Windows constants?

MarciaWalker

New Member
Hi all

I'm trying to get the system locale (not session) date format, and I want to use this windows API, which I believe should be instantiated as follows:

PROCEDURE GetDateFormatEx EXTERNAL "KERNEL32" :
DEFINE INPUT PARAMETER Locale AS LONG.
DEFINE INPUT PARAMETER dwFlags AS LONG.
DEFINE INPUT PARAMETER lpTime AS LONG.
DEFINE INPUT PARAMETER lpFormat AS LONG.
DEFINE INPUT-OUTPUT PARAMETER lpDateStr AS CHARACTER.
DEFINE INPUT PARAMETER cchDate AS LONG.
DEFINE INPUT PARAMETER lpCalendar AS LONG.
END PROCEDURE.

To run it I believe I should call it as follows:

RUN GetDateFormatEx( RD-LANGID ,
1,
0,
0,
INPUT-OUTPUT chDate,
LENGTH(chDate),
0
).

My question is how to fill the variable RD-LANGID with windows predefined values for LOCALE_NAME_USER_DEFAULT. How do I access these windows constants?

I'm using 10.2b with appbuilder.
 

Cringer

ProgressTalk.com Moderator
Staff member
You will have to create a constants library yourself. In your version the best way will be an include file I guess. In a modern version you could encapsulate them in an object.
 

TomBascom

Curmudgeon
There are also issues with 32 bit vs 64 bit architectures, Progress versions, and future-proofing relevant Windows API calls.

I have found this to be helpful:

Code:
if opsys begins "win" then
  do:
  
  &IF DECIMAL(SUBSTRING(PROVERSION,1,INDEX(PROVERSION,".") + 1)) < 11.3 &THEN
    run lib/windows32.p persistent.
  &ELSE  
    if process-architecture = 64 then  
      run lib/windows64.p persistent.
     else
      run lib/windows32.p persistent.   
  &ENDIF
  
  end.
    
return.

And this is helpful within lib/windows64.i:

Code:
&IF "{&PROCESS-ARCHITECTURE}" = "64" &THEN
  &global-define XINT           int64
  &global-define LONGINT        int64
  &global-define PUTLONGINT     PUT-INT64
  &global-define GETLONGINT     GET-INT64
 &ELSE
  &global-define XINT           integer
  &global-define LONGINT        long
  &global-define PUTLONGINT     PUT-LONG
  &global-define GETLONGINT     GET-LONG
&ENDIF
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
I'm sure you're already doing this Marcia, but do ensure that you document this OS dependency for future reference.

As part of an OS-certification project, I once had to find and document all of the external dependencies in a multi-million-line code base, because we needed to develop a test plan and no one had thought to track such things. E.g. system printer interaction, first-party and third-party DLL/SO integration, OS-COMMAND commands, system dialog invocation, COM automation, OCX controls, etc.

Technical debt isn't just about bad or outdated code. It's also about not knowing all the things your code might actually do.
 
Top