From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 17-JUN-1992 00:43:06.33
To:	macro32@WKUVX1.BITNET
CC:	
Subj:	RE: Can I get the creation date/time of the image I am running?

From:   BRYDON@PSI%DSNY25@MRGATE@PRSRTR
To:     "macro32@wkuvx1.bitnet"@M_INTERNET@MRGATE@PRSRTR

Euan Troup (etroup@atnf.csiro.au) asks:

>Is it possible to determine the date and time at which a VMS executable image
>was linked from inside the running program? I would like to be able to run a
>program and have it display the link date/time as a version i.d. I don't seem
>to be able to find anything relevant in the manuals, although if someone could
>direct me to the right place I'd be grateful.

Here is a piece of code that I use.  Documentation is as used with Fortran.  I
use it with Pascal code with no problems.  I think I got this copy from the
BULLETIN distribution.

____________________________________________________________________________
Harvey Brydon         | Internet:   brydon@dsn.SINet.slb.com
Dowell Schlumberger   | FAX:        (918)250-9323
P.O. Box 2710         | Telex:      1565030001 SINET ASL SLB
5051 S. 129E Ave      | P.O.T.S.:   (918)250-4312
Tulsa OK 74101        |
I bought my VAXstation from my uncle on his deathbead - I wrote him a check.
------- READ_HEADER.MAR  -------------------------------------------------
        .TITLE  READ_HEADER - Read Image Header
        .IDENT  /1-001/

; This subroutine returns the image identification and link time.
;
; Format:
;
;   status.wlc.v = READ_HEADER( ident.wt.ds [,time.wt.ds] )
;
; Parameters:
;
;   ident       The image identification text,
;                 character string passed by descriptor, write only
;
;   time        The image link time (text format),
;                 character string passed by descriptor, write only
;
; Written: John Miano, 24-June-1986 -
;       (obtained from April 87 DECUS L&T Sig Newsletter, used in Bulletin 1.72)
;
        .link           "sys$system:sys.stb"/selective_search
        .LIBRARY        "SYS$LIBRARY:LIB"

        $DSCDEF
        $IHDDEF
        $IHIDEF
        $SSDEF

; Argument pointer offsets

        $OFFSET 4,POSITIVE,<IDENT,TIME>

        .PSECT READ_HEADER, RD, NOWRT, EXE, LONG
        .ENTRY READ_HEADER, ^M< R2, R3, R4, R5, R6, R7, R8, R11 >

        CMPL    (AP),#1                 ; Make sure that there is at least
        BGEQ    ENOUGH_ARGUMENTS        ;  one argument to this routine
        MOVL    #SS$_INSFARG, R0
        RET

ENOUGH_ARGUMENTS:

; Get the identification of the image.

        MOVL    @#CTL$GL_IMGHDRBF, R11  ; R11 - Address of image buffer
        MOVL    (R11), R6               ; R6  - Address of image header

        CVTWL   IHD$W_IMGIDOFF(R6), R7
        MOVAB   (R6)[R7], R7            ; R7 - Address of ID Block

        CVTBL   IHI$T_IMGID(R7),R0      ; Length of the ID string
        MOVL    IDENT(AP), R8
        MOVC5   R0, <IHI$T_IMGID+1>(R7), #32, -
                DSC$W_LENGTH(R8), @DSC$A_POINTER(R8)

        CMPL    (AP), #2
        BGEQ    RETURN_TIME
        MOVZBL  #1, R0
        RET

RETURN_TIME:

; Get the time the image was linked and convert it to ASCII

        $ASCTIM_S -
                TIMBUF=@TIME(AP), -
                TIMADR=IHI$Q_LINKTIME(R7)

        RET

        .END
