16-bit process; Windows date, but DOS time

16-bit process; Windows date, but DOS time

Post by Markus Bet » Tue, 05 Aug 2003 01:38:53



Hello,

I have got to support a more than 10 years old 16-bit Borland Pascal
programme, and I have some trouble with date and time under Windows
NT / 2000.

I found out the following:

- Both GetDate and GetTime of Borland Pascal are based on the DOS
  interrupt 21h, functions 2Ah and 2Ch.
- DOS function 2Ah retrieves the Windows system date.
- DOS function 2Ch retrieves the time from an interrupt controlled count
  in memory that is synchronized with the Windows system time only
  on programme startup.

The problem is that for long-running processes the DOS time gets
asynchrone with the Windows system time, so it is possible to that e. g.
<Monday 23:59:59> is followed by <Monday 00:00:00>, <Monday 00:00:01>,
<Tuesday 00:00:02>.

If the Windows system date and time are changed by a user, in the DOS
programme only the date changes, not the time.

I made a hack that retrieves date and time by touching a file and
reading its modification date. But file dates have a precision of
2 seconds only, and I don't know how the consequences to the hard disk
are (regarding physical accesses).

Does anyone know another way to read the Windows system date and time
from a 16-bit DOS process?

TIA, Markus

Followup-To: comp.os.msdos.programmer

 
 
 

16-bit process; Windows date, but DOS time

Post by Wojciech Galazk » Tue, 05 Aug 2003 05:37:18


Markus,

If your application is important then consider running it on Windows 98 alone while porting it to a more reliable operating system, eg. FreeBSD, Solaris or Linux (not SCO !)
If the application isn't as important to make a port to a new system consider sticking with Windows 98.  If you do not need networking you probably may try FreeDOS as well. While this may not work at the first time there is a community of people who would be interested to make FreeDOS compatible with your application (or Borland Pascal) I believe. Do not rely on Microsoft, their software is sold 'as is', only customers' money is real while reliability has never been.

 
 
 

16-bit process; Windows date, but DOS time

Post by Dr John Stockto » Tue, 05 Aug 2003 20:21:33




at Sun, 3 Aug 2003 18:38:53 :-

Quote:>I have got to support a more than 10 years old 16-bit Borland Pascal
>programme, and I have some trouble with date and time under Windows
>NT / 2000.

>I found out the following:

>- Both GetDate and GetTime of Borland Pascal are based on the DOS
>  interrupt 21h, functions 2Ah and 2Ch.
>- DOS function 2Ah retrieves the Windows system date.
>- DOS function 2Ch retrieves the time from an interrupt controlled count
>  in memory that is synchronized with the Windows system time only
>  on programme startup.

>The problem is that for long-running processes the DOS time gets
>asynchrone with the Windows system time, so it is possible to that e. g.
><Monday 23:59:59> is followed by <Monday 00:00:00>, <Monday 00:00:01>,
><Tuesday 00:00:02>.

>If the Windows system date and time are changed by a user, in the DOS
>programme only the date changes, not the time.

>I made a hack that retrieves date and time by touching a file and
>reading its modification date. But file dates have a precision of
>2 seconds only, and I don't know how the consequences to the hard disk
>are (regarding physical accesses).

>Does anyone know another way to read the Windows system date and time
>from a 16-bit DOS process?

You might, perhaps, find my
<URL:http://www.merlyn.demon.co.uk/pas-time.htm>, etc., of some help,
though it does not cover the exact case.  I'd be pleased to add to that
page as appropriate.

It appears that, in your system, each DOS process has its own clock, but
not its own calendar - an OS design fault.

If you can be satisfied that your process will not be started near
midnight, and that you can make it read the time at intervals reliably
less than 24 hours, you can keep track of the date by your own code, on
the basis of "if the time is less than it was, it must now be tomorrow".

The getTickCount call might be useful; it gives milliseconds since
start.

News:comp.lang.pascal.borland might know; added to newsgroups.

--

  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt>   RAH Prins : c.l.p.b mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

 
 
 

16-bit process; Windows date, but DOS time

Post by Markus Bet » Wed, 06 Aug 2003 04:51:25



>Markus,

>If your application is important then consider running it on Windows 98 alone ...

No, it must be Windows NT or newer.

Markus

 
 
 

16-bit process; Windows date, but DOS time

Post by Markus Bet » Wed, 06 Aug 2003 04:51:26



Quote:>If you can be satisfied that your process will not be started near
>midnight, and that you can make it read the time at intervals reliably
>less than 24 hours, you can keep track of the date by your own code, on
>the basis of "if the time is less than it was, it must now be tomorrow".

>The getTickCount call might be useful; it gives milliseconds since
>start.

Yes, thank you. The more I think about it, the more ideas I get. This is
one of them.

But I hoped for an OS patch or so ...

Markus

 
 
 

16-bit process; Windows date, but DOS time

Post by Wojciech Galazk » Thu, 07 Aug 2003 04:28:18



Quote:>No, it must be Windows NT or newer.

You can write a Virtual Dos Device that would allow you to accessl Win32 Date or Time functions from your DOS program ....
 
 
 

16-bit process; Windows date, but DOS time

Post by Gisle Vane » Thu, 07 Aug 2003 05:17:49



>>No, it must be Windows NT or newer.

>You can write a Virtual Dos Device that would allow you to accessl Win32 Date
> or Time functions from your >DOS program ....

Do you know any VDD that operates under NT/XP?
AFAIK it doesn't have the VDD/VXD loader service as Win9x
had. Ref. int 2F/1684.

It should be equally "simple" to make a NTP-client in DOS
that gets the time from any machine (local or remote).
The ntp protocol is rather simple.

--gv

 
 
 

16-bit process; Windows date, but DOS time

Post by Ross Rid » Thu, 07 Aug 2003 16:12:47



>You can write a Virtual Dos Device that would allow you to accessl Win32 Date
> or Time functions from your >DOS program ....

>Do you know any VDD that operates under NT/XP?
>AFAIK it doesn't have the VDD/VXD loader service as Win9x
>had. Ref. int 2F/1684.

Virtual Dos Device drivers aren't VxDs.  They're DLLs that get loaded
by NTVDM, the MS-DOS emulator under Windows NT/2K/XP.

                                        Ross Ridge

--
 l/  //   Ross Ridge -- The Great HTMU

-()-/()/  http://www.csclub.uwaterloo.ca/u/rridge/
 db  //  

 
 
 

16-bit process; Windows date, but DOS time

Post by Wojciech Galazk » Fri, 08 Aug 2003 05:34:08




>>>No, it must be Windows NT or newer.

>>You can write a Virtual Dos Device that would allow you to accessl Win32 Date
>> or Time functions from your >DOS program ....

>Do you know any VDD that operates under NT/XP?

Yes, Microsoft provides some basic examples in DDK

Quote:>AFAIK it doesn't have the VDD/VXD loader service as Win9x
>had. Ref. int 2F/1684.

VDD is not a VxD, it's much simpler. It does not use int 2fh

Quote:>It should be equally "simple" to make a NTP-client in DOS
>that gets the time from any machine (local or remote).
>The ntp protocol is rather simple.

Yes you can call Winsock functions from a VDD.
 
 
 

1. DOS 16-bit programs in Windows 95/98 window

Hello,

Could someone point me to any resources which explain the Microsoft
Windows 95/98 limitations for DOS 16-bit programs running in a window.
I need to modify a few DOS programs (in Pascal) to be able to display
640x480x16 and 640x480x256 mode graphics. However they will not
run in a window, but only in full screen mode. Text modes work fine
however.

Thanks for your help.

Mike McWhinney
Chief Engineer
elja, Inc.

2. GEnie Account availability

3. Cross compiling DOS 6.22 16-bit EXE from Windows NT 4

4. Correct id to link to MAPI

5. int64 or something like in a 16 bits program (16 bits compiler or algo)

6. Mortgage workaround

7. 16-bit Apps under Windows NT

8. What is IBMLVL.INI for?

9. How to change DOS date/time to readeable date/time?

10. 16-bit or 32-bit use?

11. Transparent 32-bit math in a 16-bit world?

12. Any difference in accessing data in 32-bit & 16-bit mode?

13. 16-Bit -> 32-Bit Programming