News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Quebec or French CANADA Time

Started by herge, September 04, 2013, 03:13:12 PM

Previous topic - Next topic

herge

 
HI PQ Fans:

PQ is code for Province of Quebec i e P.Q.

I had a bit of trouble with the LCID because I typed the wrong number
and then of course the GetDateFormat was FORD i e wrong and eax had
zero in it and I digress?

I typed 3064 instead of 3084?

Top secret code while not any more?

; REM CDNFRENC.ASM  Wednesday, September 24, 2008 2:30 PM
; Modified Wednesday, September 04, 2013 7:06:39 AM
; by herge - Show System Date & Time
include \masm32\include\masm32rt.inc
INCLUDE \masm32\include\DateTime.inc
INCLUDELIB \masm32\lib\DateTime.lib

.data
stm  SYSTEMTIME<>
YourLCID   dd  3084; French CANADA - Google LCID Country Name?
; i e Google "LCID French CANADA" or "LCID USA, LCID UK"
; USA is America i e USA, UK is England, Scotland, Wales, etc.
; USA is 1033, UK is 2057
; You mant an entry from MicroSoft?
; IF YourLCID is bad the GetDateFormat Does Not Work?
;    org stm; Must be eight words
;wYear dw 0
;wMonth dw 0
;wToDay dw 0 ; Sunday 0 to Saturday 6
;wDay    dw 0
;wHour   dw 0
;;wMinute dw 0
;wSecond dw 0
;wKsecond dw 0
pzTitle    db " Montreal Time << "
date_buf   db 128 dup (0)
time_buf   db 32 dup (0)
           db 0
FirstSpace db " "           
StdOutBuf  db 128 dup(0)

           db 0
dateformat db " dddd, MMMM, dd, yyyy", 0
timeformat db "hh:mm tt",0
           db 0
CrLf        db    13, 10, 0
            db    0
        align 8
                         
.code
        align 8
PCrLf   proc
        invoke   StdOut, addr CrLf
        ret
PCrLf   endp
        align 8
   
start:
     invoke   GetLocalTime, addr stm
     invoke GetDateFormat, YourLCID, DATE_LONGDATE, 0, 0, addr date_buf, SIZEOF date_buf
     mov   ecx, offset date_buf
     add   ecx, eax; add length returned by GetDateFormat
     mov   byte ptr [ecx-1], " " ; replace null with space
     invoke   GetTimeFormat, 0, 0, \
            0, ADDR timeformat, ecx, sizeof time_buf
     invoke   StdOut, ADDR pzTitle
     invoke   MessageBox, 0, addr pzTitle, addr pzTitle, MB_OK

     cld    ; Direction Flag Up
     mov    esi, offset StdOutBuf
     INVOKE CurrentTimeZoneName, esi
     inc    eax; -1 is Error?
     jz     err_tz
     mov    esi, offset StdOutBuf
       
@@:     
     lodsb
     and    al, al
     jnz    @B
ALabel:     
     mov    word ptr [esi], 0A0Dh ; This is OD0AH - Trust Me!
     add    esi, 2; length of word in bytes
     mov    byte ptr [ esi ], 0
     mov    esi, offset FirstSpace
     invoke StdOut, esi
     call   PCrLf; New Line i e Cr, Lf   
     inkey  " $$ Wait for KeyBoard - Hit Space Bar to End Process $$ ", 13, 10
     invoke ExitProcess, 0
     ret
     align 8
err_tz:
     print   " Time Zone Not Set ",7,13,10; 7 = Bell Noise i e Alarm
     exit
     ret
     align 8
end_here    equ $   
    end start




Je me souviens - it's on all Quebec License Plates
means I remember or Do not Forget.


I worked as an Co-op student @ Royal Bank, Place Ville Marie,
Montreal, P.Q., CANADA. You have a great view from 25th Flloor.




Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge


Hi  LCID 3084 fans:

A program that don't work, but you will get some error messages and
some beeps? It will compile nice i e no error messages I hope.

it's called CRASH.ASM and will print an Error message for GetDateFormat
function.

CRASH.ASM REM CRASH.ASM  Wednesday, September 24, 2008 2:30 PM
; Modified Thursday, September 05, 2013 9:06:30 AM
; by herge - Show System Date & Time
include \masm32\include\masm32rt.inc
INCLUDE \masm32\include\DateTime.inc
INCLUDELIB \masm32\lib\DateTime.lib

.data
stm  SYSTEMTIME<>
YourLCID   dd  3064; French CANADA - Google LCID Country Name? was 3084
; i e Google "LCID French CANADA" or "LCID USA, LCID UK"
; USA is America i e USA, UK is England, Scotland, Wales, etc.
; USA is 1033, UK is 2057
; French CANADA 3084
; English CANADA 4105
; You mant an entry from MicroSoft?
; IF YourLCID is bad the GetDateFormat Does Not Work?
;    org stm; Must be eight words
;wYear dw 0
;wMonth dw 0
;wToDay dw 0 ; Sunday 0 to Saturday 6
;wDay    dw 0
;wHour   dw 0
;;wMinute dw 0
;wSecond dw 0
;wKsecond dw 0
pzTitle    db " Montreal Time << "
date_buf   db 128 dup (0)
time_buf   db 32 dup (0)
           db 0
FirstSpace db " "           
StdOutBuf  db 128 dup(0)

           db 0
dateformat db " dddd, MMMM, dd, yyyy", 0
timeformat db "hh:mm tt",0
           db 0
CrLf        db    13, 10, 0
            db    0
GetDateFormatMessage    equ $
        db " $$ ERROR_INSUFFICIENT_BUFFER $$ ",7 , 0
        db " $$ ERROR_INVALID_FLAGS $$ ", 7, 0
        db " $$ ERROR_INVALID_PARAMETER $$ ", 7,0
        db  0
        align 8
                         
.code
        align 8
PCrLf   proc
        invoke   StdOut, addr CrLf
        ret
PCrLf   endp
        IF 0
        From \masm32\help\WIN32.HLP
        GEtDateFormat Return Values

;If the function succeeds, the return value is the number of bytes (ANSI version) or characters (Unicode version) written to the lpDateStr buffer, or if the cchDate parameter is zero, the number of bytes or characters required to hold the formatted date string.
;If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:

; NOTE You need a semi colon before all if (s) even in comments?? This is a semi colon ;

ERROR_INSUFFICIENT_BUFFER
ERROR_INVALID_FLAGS
ERROR_INVALID_PARAMETER

ENDIF

CX_TH proc
; ESI > Table
; ECX is entry in table we
; want.
; find cx_th entry in table
      test  ecx, ecx
jz cx_th_exit
dec ecx ; is it first entry
jz cx_th_exit; is first then exit
@@:
lodsb
and al,al ; is byte equal zero
jnz @B; search for zero
dec ecx
jnz @B; find cx_th zero
cx_th_exit:
; cx_th zero found exit
ret
CX_TH endp

    align   8
P   proc    uses    ecx ; Print to Console ESI
    invoke  StdOut, esi
    ret
P   endp

        align 8
GetDateFormatXE:
     call   GetLastError
     push   eax
     inkey  "$$ GetDateformat Exit on Error $$",7 , 13, 10 
     pop    eax
     mov    ecx, 1
     cmp    eax, ERROR_INSUFFICIENT_BUFFER
     jz     GetDateFormatXEP
     inc    ecx
     cmp    eax, ERROR_INVALID_FLAGS
     jz     GetDateFormatXEP
     inc    ecx
     cmp    eax, ERROR_INVALID_PARAMETER
GetDateFormatXEP:
     push   eax
     mov    esi, offset GetDateFormatMessage
     call   CX_TH
     call   PCrLf   
     call   P
     call   PCrLf   
     inkey  " ** Press Space Bar to END ** "
     pop    eax       
     invoke   ExitProcess, eax
     ret
     align  8
start:
     invoke   GetLocalTime, addr stm
     invoke GetDateFormat, YourLCID, DATE_LONGDATE, 0, 0, addr date_buf, SIZEOF date_buf
     and    eax,eax
     jz     GetDateFormatXE     
     mov    ecx, offset date_buf
     add    ecx, eax; add length returned by GetDateFormat
     mov    byte ptr [ecx-1], " " ; replace null with space
     invoke   GetTimeFormat, 0, 0, \
            0, ADDR timeformat, ecx, sizeof time_buf
     invoke   StdOut, ADDR pzTitle
     invoke   MessageBox, 0, addr pzTitle, addr pzTitle, MB_OK

     cld    ; Direction Flag Up
     mov    esi, offset StdOutBuf
     INVOKE CurrentTimeZoneName, esi
     inc    eax; -1 is Error?
     jz     err_tz
     mov    esi, offset StdOutBuf
       
@@:     
     lodsb
     and    al, al
     jnz    @B
ALabel:     
     mov    word ptr [esi], 0A0Dh ; This is OD0AH - Trust Me!
     add    esi, 2; length of word in bytes
     mov    byte ptr [ esi ], 0
     mov    esi, offset FirstSpace
     invoke StdOut, esi
     call   PCrLf; New Line i e Cr, Lf   
     inkey  " $$ Wait for KeyBoard - Hit Space Bar to End Process $$ ", 13, 10
     invoke ExitProcess, 0
     ret
     align 8
err_tz:
     print   " Time Zone Not Set ",7,13,10; 7 = Bell Noise i e Alarm
     exit
     ret
     align 8
end_here    equ $   
    end     start



Demostrates what happens with an invalid LCID.
Change the bad LCID to a nice LCID.
Google "LCID Your Country Name"
where Your Country name is CANADA or say USA or UK or France
or What ever?

Please Note in assembler:

; NOTE You need a semi colon before all if (s) even in comments?? This is a semi colon ;

You have been warned?

Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.