Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!microsoft!matts From: matts@microsoft.UUCP (Matt SAETTLER) Newsgroups: comp.windows.ms Subject: Re: File date and time displayed in dialog box Message-ID: <53658@microsoft.UUCP> Date: 21 Mar 90 00:43:41 GMT References: <5135@helios.ee.lbl.gov> Reply-To: matts@microsoft.UUCP (Matt SAETTLER) Organization: Microsoft Corp., Redmond WA Lines: 57 In article <5135@helios.ee.lbl.gov> gimpel@bevsun.bev.lbl.gov (Tom Gimpel) writes: > > Mike Morris sez: >>I want the About item to bring up a window which has ... "" >>Version NN.NN, dated MM/DD/YY, at HH:MM" > >Here's what I did: In AboutDlgProc, which is the proc for the About... box put > >BOOL FAR PASCAL AboutDlgProc (hDlg, message, wParam, lParam) [Some code deleted] > stat ("vers.exe", &stFileInfo); > npstFileTime = localtime (&stFileInfo.st_atime); > if (npstFileTime->tm_hour < 12) > szAmPm = "am"; > else > szAmPm = "pm"; > if (npstFileTime->tm_hour > 12) > npstFileTime->tm_hour -= 12; > if (npstFileTime->tm_hour < 1) > npstFileTime->tm_hour = 12; > sprintf (szTemp, "%2d/%02d/%02d", npstFileTime->tm_mon + 1, > npstFileTime->tm_mday, npstFileTime->tm_year); > SetDlgItemText (hDlg, ID_FILEDATE, (LPSTR)szTemp); > sprintf (szTemp, "%2d:%02d%2s", npstFileTime->tm_hour, > npstFileTime->tm_min, > szAmPm); > SetDlgItemText (hDlg, ID_FILEDATE, (LPSTR)szTemp); ^^^^^^^^ Should be FILETIME Under Microsoft C (5.1), just do: SetDlgItemText (hDlg, ID_FILEDATE, (LPSTR)__DATE__); SetDlgItemText (hDlg, ID_FILETIME, (LPSTR)__TIME__); This will give the time of the compile. This much more useful (and more reliable) than the date of the EXE. This is also not dependent on the finding location of the program. (as Tom said, the code depends on the EXE being in the current directory; not really a good limitation) The __xxx__ are defined by the C compiler. Other useful items are __LINE__ and __FILE__ which give the current source line and file. (useful in doing Asserts ). These are documented somewhere. (I know that they are mentioned on page 31 of the Quick Ref Guide.) [...] >Don't forget to export AboutDlgProc in the .DEF file. (I always do) [...] Ya, me too. A good rule of thumb is if "strange things are happening" then you forgot to export the function. ------------------------------------------------------------------------------ These opinions are my own, or so I'm told....