home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / msdos-programmer-faq / part4 < prev    next >
Encoding:
Internet Message Format  |  2004-05-09  |  43.7 KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <msdos-programmer-faq/part4_1084010824@rtfm.mit.edu>
  3. Supersedes: <msdos-programmer-faq/part4_1081511793@rtfm.mit.edu>
  4. Expires: 11 Jun 2004 10:07:04 GMT
  5. References: <msdos-programmer-faq/part1_1084010824@rtfm.mit.edu>
  6. X-Last-Updated: 2003/08/14
  7. From: jeffrey@carlyle.org (Jeffrey Carlyle)
  8. Sender: jeffrey@carlyle.org (Jeffrey Carlyle)
  9. Reply-To: jeffrey@carlyle.org (Jeffrey Carlyle)
  10. Approved: news-answers-request@MIT.edu
  11. Organization: JeffC.org
  12. Subject: comp.os.msdos.programmer FAQ part 4/5
  13. Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,comp.answers,alt.answers,news.answers
  14. Followup-To: poster
  15. Summary: Frequently asked questions from DOS programmers with tested answers.
  16. Originator: faqserv@penguin-lust.MIT.EDU
  17. Date: 08 May 2004 10:08:03 GMT
  18. Lines: 1000
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1084010883 senator-bedfellow.mit.edu 580 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.os.msdos.programmer:127445 alt.msdos.programmer:54823 comp.answers:57101 alt.answers:72788 news.answers:270992
  22.  
  23. Archive-name: msdos-programmer-faq/part4
  24. Comp-os-msdos-programmer-archive-name: dos-faq-pt4.txt
  25. Posting-frequency: 28 days
  26. Last-modified: 14 Aug 2003
  27.  
  28. comp.os.msdos.programmer FAQ Version 2003.08.14
  29.  
  30. This is the Frequently Asked Questions list for the newsgroup
  31. comp.os.msdos.programmer.
  32.  
  33. COPYRIGHT
  34.  
  35. Copyright 2003 by Jeffrey Carlyle. All rights reserved. This article is
  36. not in the public domain, but it may be redistributed so long as this
  37. notice, the acknowledgments, and the information on obtaining the latest
  38. copy of this list are retained and no fee is charged. The code fragments
  39. may be used freely; credit to the FAQ would be polite. This FAQ is not to
  40. be included in any static: archive (e.g. CD-ROM or book); however, a
  41. pointer to the FAQ may be included. See <Q:01.14> [Where can I get the
  42. latest copy of this FAQ list?] for a link to the latest version of the
  43. FAQ.)
  44.  
  45. This is part 4 of 5 parts.
  46.  
  47. TABLE OF CONTENTS
  48.  
  49. PART 1: 
  50. Section 1.  General FAQ and Newsgroup Information
  51.   <Q:01.01> - Is MS-DOS Dead?
  52.   <Q:01.02> - What is this article for?
  53.   <Q:01.03> - Who has contributed to this article?
  54.   <Q:01.04> - How can I search this article for a particular topic?
  55.   <Q:01.05> - Are the answers guaranteed to be correct and complete?
  56.   <Q:01.06> - What is comp.os.msdos.programmer about?
  57.   <Q:01.07> - Is comp.os.msdos.programmer just for C programmers?
  58.   <Q:01.08> - What is comp.sys.ibm.pc.programmer?
  59.   <Q:01.09> - Is comp.os.msdos.programmer available as a mailing list?
  60.   <Q:01.10> - What's this netiquette?
  61.   <Q:01.11> - How can I learn more about Usenet?
  62.   <Q:01.12> - What other technical newsgroups should I know about?
  63.   <Q:01.13> - Where are FAQ lists archived?
  64.   <Q:01.14> - Where can I get the latest copy of this FAQ list?
  65.  
  66. Section 2.  General Reference
  67.   <Q:02.01> - Are there any good on-line references for PC hardware
  68.               components?
  69.   <Q:02.02> - Are there any good on-line references for PC interrupts?
  70.   <Q:02.03> - What and where is Ralf Brown's interrupt list?
  71.   <Q:02.04> - Where can I find lex, yacc, and language grammars?
  72.   <Q:02.05> - What's the best book to learn programming?
  73.   <Q:02.06> - Why won't my code work?
  74.   <Q:02.07> - Are there any good sources of example code?
  75.   <Q:02.08> - What and where is SNIPPETS?
  76.   <Q:02.09> - Is the source code MS-DOS available?
  77.   <Q:02.10> - What are my alternatives for MS-DOS compatible OSes?
  78.   <Q:02.11> - What and where is FreeDOS?
  79.   <Q:02.12> - Where can I find out about batch files?
  80.  
  81. PART 2: 
  82. Section 3.  Compile and link
  83.   <Q:03.01> - What the heck is DGROUP > 64K?
  84.   <Q:03.02> - How do I fix 'automatic data segment exceeds 64K' or 'stack
  85.               plus data exceed 64K'?
  86.   <Q:03.03> - Will Borland C code and Microsoft C code link together?
  87.   <Q:03.04> - Why did my program bomb at run time with 'floating point
  88.               formats not linked' or 'floating point not loaded'?
  89.   <Q:03.05> - How can I change the stack size in Borland's C compilers?
  90.   <Q:03.06> - What's the format of an .OBJ file?
  91.   <Q:03.07> - What's the format of an .EXE header?
  92.   <Q:03.08> - What's the difference between .COM and .EXE formats?
  93.   <Q:03.09> - How do I create a .COM file?
  94.   <Q:03.10> - Where is EXE2BIN located?
  95.   <Q:03.11> - What does this message mean: 'A20 already enabled so test
  96.               is meaning less?'
  97.  
  98. Section 4.  Keyboard
  99.   <Q:04.01> - How can I read a character without echoing it to the
  100.               screen, and without waiting for the user to press the Enter
  101.               key?
  102.   <Q:04.02> - How can I find out whether a character has been typed,
  103.               without waiting for one?
  104.   <Q:04.03> - How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  105.   <Q:04.04> - How can I disable the print screen function?
  106.   <Q:04.05> - How can my program turn NumLock (CapsLock, ScrollLock) on
  107.               or off?
  108.   <Q:04.06> - How can I speed up the keyboard's auto-repeat?
  109.   <Q:04.07> - What is the SysRq key for?
  110.   <Q:04.08> - How can my program tell what kind of keyboard is on the
  111.               system?
  112.   <Q:04.09> - How can I tell if input, output, or stderr has been
  113.               redirected?
  114.   <Q:04.10> - How can I increase the size of the keyboard buffer?
  115.   <Q:04.11> - How can I stuff characters into the keyboard buffer?
  116.  
  117. PART 3: 
  118. Section 5.  Disks and files
  119.   <Q:05.01> - What drive was the PC booted from?
  120.   <Q:05.02> - How can I boot from drive B:?
  121.   <Q:05.03> - Which real and virtual disk drives are valid?
  122.   <Q:05.04> - How can I make my single floppy drive both a: and b:?
  123.   <Q:05.05> - How can I disable access to a drive?
  124.   <Q:05.06> - How can a batch file test existence of a directory?
  125.   <Q:05.07> - Why won't my C program open a file with a path?
  126.   <Q:05.08> - How can I redirect printer output to a file?
  127.   <Q:05.09> - How can I redirect the output of a batch file?
  128.   <Q:05.10> - How can I redirect stderr?
  129.   <Q:05.11> - How can my program open more files than DOS's limit of 20?
  130.   <Q:05.12> - How can I read, create, change, or delete the volume label?
  131.   <Q:05.13> - How can I get the disk serial number?
  132.   <Q:05.14> - What's the format of .OBJ, .EXE., .COM files?
  133.   <Q:05.15> - How can I flush the software disk cache?
  134.   <Q:05.16> - How can I see if a drive is a RAM drive?
  135.   <Q:05.17> - How can I determine a hard drive's manufacturer?
  136.   <Q:05.18> - Where can I find information about the ATA/ATAPI
  137.               specification?
  138.   <Q:05.19> - How can I copy files to or from filenames containing date
  139.               information?
  140.  
  141. Section 6.  Serial ports (COM ports)
  142.   <Q:06.01> - How do I set my machine up to use COM3 and COM4?
  143.   <Q:06.02> - How do I find the I/O address of a COM port?
  144.   <Q:06.03> - But aren't the COM ports always at I/O addresses 3F8, 2F8,
  145.               3E8, and 2E8?
  146.   <Q:06.04> - How do I configure a COM port and use it to transmit data?
  147.  
  148. PART 4: (this part)
  149. Section 7.  Other hardware questions and problems
  150.   <Q:07.01> - Which 80x86 CPU is running my program?
  151.   <Q:07.02> - How can a C program send control codes to my printer?
  152.   <Q:07.03> - How can I redirect printer output?
  153.   <Q:07.04> - Which video adapter is installed?
  154.   <Q:07.05> - How do I switch to 43- or 50-line mode?
  155.   <Q:07.06> - How can I find the Microsoft mouse position and button
  156.               status?
  157.   <Q:07.07> - How can I access a specific address in the PC's memory?
  158.   <Q:07.08> - How can I read or write my PC's CMOS memory?
  159.   <Q:07.09> - How can I access memory beyond 640K?
  160.   <Q:07.10> - How can I use the protected mode?
  161.   <Q:07.11> - How can I tell if my program is running on a PS/2-style
  162.               machine.
  163.   <Q:07.12> - Is there a 80x87 math unit installed?
  164.   <Q:07.13> - How can I power off the computer from a batch file?
  165.  
  166. Section 8.  Other software questions and problems
  167.   <Q:08.01> - How can a program reboot my PC?
  168.   <Q:08.02> - How can I time events with finer resolution than the system
  169.               clock's 55 ms (about 18 ticks a second)?
  170.   <Q:08.03> - How can I find the error level of the previous program?
  171.   <Q:08.04> - How can a program set DOS environment variables?
  172.   <Q:08.05> - How can I change the switch character to - from /?
  173.   <Q:08.06> - How can I write a TSR (terminate-stay-resident utility)?
  174.   <Q:08.07> - Why does my interrupt function behave strangely?
  175.   <Q:08.08> - How can I write a device driver?
  176.   <Q:08.09> - What can I use to manage versions of software?
  177.   <Q:08.10> - What's this 'null pointer assignment' after my C program
  178.               executes?
  179.   <Q:08.11> - How can a batch file tell whether it's being run in a DOS
  180.               box under Windows?
  181.   <Q:08.12> - How can my program tell if it's running under Windows?
  182.   <Q:08.13> - How can a program tell whether ANSI.SYS is installed?
  183.   <Q:08.14> - How do I copyright software that I write?
  184.   <Q:08.15> - How can I place date and time information into environment
  185.               variables?
  186.  
  187. PART 5: 
  188. Section 9.  Downloading
  189.   <Q:09.01> - What are SimTel and Garbo?
  190.   <Q:09.02> - Can I get archives on CD-ROM?
  191.   <Q:09.03> - Where do I find program <mumble>?
  192.  
  193. Section 10.  Vendors and products
  194.   <Q:10.01> - How can I contact Borland?
  195.   <Q:10.02> - How can I contact Microsoft?
  196.   <Q:10.03> - What is the current version of DJGPP?
  197.   <Q:10.04> - What and where is DJGPP?
  198.   <Q:10.05> - Are there any good shareware/freeware compilers?
  199.   <Q:10.06> - Where is QBASIC?
  200.   <Q:10.07> - What is a vendor's web site address?
  201.  
  202. ------------------------------
  203.  
  204. Subject: Section 7. Other hardware questions and problems
  205. Date: 5 Feb 2002 22:03:03 -0400
  206.  
  207.  The subject says it all. Bv)
  208.  
  209. ------------------------------
  210.  
  211. Subject: <Q:07.01> - Which 80x86 CPU is running my program?
  212. Date: 5 Feb 2002 22:03:03 -0400
  213.  
  214.  SNIPPETS (see <Q:02.08> [What and where is SNIPPETS?]) contains
  215.  C-callable x86 assembly language code for determining the type of CPU in
  216.  CPUCHECK.ASM.
  217.  
  218. ------------------------------
  219.  
  220. Subject: <Q:07.02> - How can a C program send control codes to my
  221.         printer?
  222. Date: 5 Feb 2002 22:03:03 -0400
  223.  
  224.  If you just fprintf(stdprn, ...), C will translate some of your control
  225.  codes. The way around this is to reopen the printer in binary mode: prn
  226.  = fopen("PRN", "wb");
  227.  
  228.  You must use a different file handle because stdprn isn't an lvalue. By
  229.  the way, in DOS 5.0 a colon must not follow PRN or LPT1.
  230.  
  231.  There's one special case, Ctrl-Z (ASCII 26), the DOS end-of- file
  232.  character. If you try to send an ASCII 26 to your printer, DOS simply
  233.  ignores it. To get around this, you need to reset the printer from
  234.  "cooked" to "raw" mode. Microsoft C users must use INT 21 AH=44,
  235.  "get/set device information". Turbo C and Borland C++ users can use
  236.  ioctl to accomplish the same thing: ioctl(fileno(prn), 1,
  237.  ioctl(fileno(prn),0) & 0xFF | 0x20, 0);
  238.  
  239.  An alternative approach is simply to write the printer output into a
  240.  disk file, then copy the file to the printer with the /B switch.
  241.  
  242.  A third approach is to bypass DOS functions entirely and use the BIOS
  243.  printer functions at INT 17. If you also fprintf(stdprn,...) in the same
  244.  program, you'll need to use fflush() to synchronize fprintf()'s buffered
  245.  output with the BIOS's unbuffered.
  246.  
  247.  By the way, if you've opened the printer in binary mode from a C
  248.  program, remember that outgoing \n won't be translated to carriage
  249.  return/line feed. Depending on your printer, you may need to send
  250.  explicit \n\r sequences.
  251.  
  252. ------------------------------
  253.  
  254. Subject: <Q:07.03> - How can I redirect printer output?
  255. Date: 5 Feb 2002 22:03:03 -0400
  256.  
  257.  Please see <Q:05.08> [How can I redirect printer output to a file?]
  258.  
  259. ------------------------------
  260.  
  261. Subject: <Q:07.04> - Which video adapter is installed?
  262. Date: 5 Feb 2002 22:03:03 -0400
  263.  
  264.  The technique below should work if your BIOS is not too old. It uses
  265.  three functions from INT 10, the BIOS video interrupt. (If you're using
  266.  a Borland language, you may not have to do this the hard way. Look for a
  267.  function called DetectGraph or something similar.)
  268.  
  269.  Set AX=1200, BL=32 and call INT 10. If AL returns 12, you have a VGA. If
  270.  not, set AH=12, BL=10 and call INT 10 again. If BL returns 0,1,2,3, you
  271.  have an EGA with 64,128,192,256K memory. If not, set AH=0F and call INT
  272.  10 a third time. If AL is 7, you have an MDA (original monochrome
  273.  adapter) or Hercules; if not, you have a CGA.
  274.  
  275.  This worked when tested with a VGA, but I had no other adapter types to
  276.  test it with.
  277.  
  278. ------------------------------
  279.  
  280. Subject: <Q:07.05> - How do I switch to 43- or 50-line mode?
  281. Date: 8 Feb 2002 20:05:49 -0400
  282.  
  283.  The following file contains .COM utilities and .ASM source code:
  284.  <http://www.simtel.net/pub/pd/49657.html>
  285.  
  286. ------------------------------
  287.  
  288. Subject: <Q:07.06> - How can I find the Microsoft mouse position and
  289.         button status?
  290. Date: 8 Feb 2002 20:07:14 -0400
  291.  
  292.  Use INT 33 AX=3, described in Ralf Brown's interrupt list (<Q:02.03>
  293.  [What and where is Ralf Brown's interrupt list?]).
  294.  
  295.  The Windows manual says that the Logitech mouse is compatible with the
  296.  Microsoft one, so the interrupt will probably work the same.
  297.  
  298.  Also, many files are downloadable from:
  299.  <http://www.simtel.net/pub/msdos/mouse/>
  300.  
  301. ------------------------------
  302.  
  303. Subject: <Q:07.07> - How can I access a specific address in the PC's
  304.         memory?
  305. Date: 7 Feb 2002 14:50:10 -0400
  306.  
  307.  First check the library that came with your compiler. Many vendors have
  308.  some variant of peek and poke functions. For example:
  309.  
  310.  * In Turbo Pascal, use the pseudo-arrays Mem, MemW, and MemL. Be sure
  311.    you use the correct array for the size of data you want to access:
  312.    byte, word, or double word. Alternatively, use pointers.
  313.  
  314.  * In Turbo C/Borland C, and in recent versions of Microsoft C, use
  315.    MK_FP; in older versions of Microsoft C, use FP_OFF and FP_SEG.
  316.    (Caution: Turbo C and Turbo C++ also have FP_OFF and FP_SEG macros,
  317.    but they can't be used to construct a pointer.) Be sure to pick the
  318.    right data type: probably "unsigned char far *" if you're planning to
  319.    access bytes and "unsigned short far *" for words. (The "far" isn't
  320.    needed if your memory model uses 32-bit data pointers, but including
  321.    it does no harm.)
  322.  
  323.  By the way, it's not useful to talk about "portable" ways to do this.
  324.  Any operation that is tied to a specific memory address is not likely to
  325.  work on another kind of machine.
  326.  
  327. ------------------------------
  328.  
  329. Subject: <Q:07.08> - How can I read or write my PC's CMOS memory?
  330. Date: 8 Feb 2002 20:11:37 -0400
  331.  
  332.  There are a great many public-domain utilities that do this. The
  333.  following files can be downloaded from
  334.  <http://www.simtel.net/pub/msdos/sysutl/>:
  335.  
  336.    cmos14.zip    5965  920817  Saves/restores CMOS to/from file
  337.    cmoser11.zip 28323  910721  386/286 enhanced  CMOS setup program
  338.    cmosram.zip  76096  920214  Save AT/386/486 CMOS data to file and restore
  339.    rom2.zip     15692  900131  Save AT and 386 CMOS data to file and restore
  340.    setup21.zip  18172  880613  Setup program which modifies CMOS RAM
  341.    viewcmos.zip 11068  900225  Display contents of AT CMOS RAM, w/C source
  342.  
  343.  A program to check and display CMOS memory (but not write to it) is
  344.  downloadable as part of: <http://www.simtel.net/pub/pd/50522.html>
  345.  <ftp://garbo.uwasa.fi/pc/ts/tsutle23.zip>
  346.  
  347.  Good reports of CMOS299.ZIP have been posted, but it no longer appears
  348.  to be online.
  349.  
  350.  Stan Brown, the former list maintainer, reports that he personally
  351.  tested CMOSRAM and that it worked fine. It contains an excellent (and
  352.  witty) .DOC file that explains the hardware involved and gives specific
  353.  recommendations for preventing disaster or recovering from it. It's $5
  354.  shareware.
  355.  
  356.  Robert Jourdain's {Programmer's Problem Solver for the IBM PC, XT, and
  357.  AT} has code for accessing the CMOS RAM, according to an article posted
  358.  in this newsgroup.
  359.  
  360. ------------------------------
  361.  
  362. Subject: <Q:07.09> - How can I access memory beyond 640K?
  363. Date: 8 Feb 2002 20:50:34 -0400
  364.  
  365.  Part of this involves switching into protected mode.
  366.  
  367.  An article entitled "How DOS Programs Can Use Over 1MB of RAM" appeared
  368.  in PC Magazine 29 June 1993 (xii: 12) pages 302-304.
  369.  
  370.  I also suggest John English's XMS classes for C++:
  371.  <ftp://ftp.brighton.ac.uk/pub/je/xms200je.zip>.
  372.  
  373.  See also <Q:07.10> [How can I use the protected mode?]
  374.  
  375. ------------------------------
  376.  
  377. Subject: <Q:07.10> - How can I use the protected mode?
  378. Date: 8 Feb 2002 20:15:02 -0400
  379.  
  380.  DJ Delorie has produced DJGPP, a protected mode programming environment
  381.  which supports a port of the GNU C/C++/Ada. For more informat see
  382.  <Q:10.04> [What and where is DJGPP?]
  383.  
  384.  Users of Borland C++ Version 4.xx could once purchase the Borland
  385.  PowerPack for DOS Version 1.00; however, it appears that its sell has
  386.  been discontinued. This package includes Borland C++ 4.02 Service
  387.  Update, 16-bit DPMI libraries and extenders, 32-bit DPMI libraries and
  388.  extenders, TurboVision 2.0 (16-bit DOS, 16-bit DPMI, 32-bit DPMI),
  389.  SuperVGA BGI Drivers (16-bit DOS, 16-bit DPMI, 32- bit DPMI).
  390.  
  391.  A reader of comp.os.msdos.programmer has the following updateu about the
  392.  PowerPack and additional information about DPMI programming:
  393.  
  394.  [begin quote]
  395.    About protected-mode programming (Question 7.10), Borland no longer
  396.    supports the PowerPack (from what I've read in this newsgroup), so
  397.    I doubt that it can still be purchased. However, the FAQ could 
  398.    mention that the extender is integrated into Borland C++ version 5.x
  399.    (and probably the Builder product as well).
  400.    
  401.    Borland doesn't fully support that either, since the documentation
  402.    isn't very clear about compiling DPMI programs and a stub for the
  403.    executable has to be extracted from one of Borland's executables. The
  404.    necessary steps were posted a long time ago (by someone else), and I
  405.    can provide the information if necessary. Even if the FAQ didn't
  406.    describe those steps, it could at least indicate that version 5.x can
  407.    compile DPMI programs (as well as clarifying the PowerPack info).
  408.  [end quote]
  409.  
  410.  There are more extenders out there. One notable DOS extender is Adam
  411.  Seychell's DOS32 Version 3.5 beta. It can be found at
  412.  <http://www.programmersheaven.com/zone5/cat19/1363.htm> Also check out
  413.  Adam's page at <http://www.geocities.com/SiliconValley/2151/pmode.html>
  414.  
  415. ------------------------------
  416.  
  417. Subject: <Q:07.11> - How can I tell if my program is running on a
  418.         PS/2-style machine.
  419. Date: 5 Feb 2002 22:03:03 -0400
  420.  
  421.  Use INT 15 AX=C0, described in Ralf Brown's interrupt list (<Q:02.03>
  422.  [What and where is Ralf Brown's interrupt list?]).
  423.  
  424. ------------------------------
  425.  
  426. Subject: <Q:07.12> - Is there a 80x87 math unit installed?
  427. Date: 5 Feb 2002 22:03:03 -0400
  428.  
  429.  SNIPPETS (see <Q:02.08> [What and where is SNIPPETS?]) contains
  430.  C-callable assembly code to determine presence of coprocessor in
  431.  NDPCHECK.ASM.
  432.  
  433. ------------------------------
  434.  
  435. Subject: <Q:07.13> - How can I power off the computer from a batch file?
  436. Date: 6 Feb 2002 20:36:38 -0400
  437.  
  438.  A utility known as ATXOFF.COM is available at
  439.  <http://www.informatik.fh-muenchen.de/~ifw98223/dostools.htm>. It uses
  440.  APM 1.2 to power off the system but doesn't attempt to flush the disk
  441.  cache.
  442.  
  443. ------------------------------
  444.  
  445. Subject: Section 8. Other software questions and problems
  446. Date: 5 Feb 2002 22:03:03 -0400
  447.  
  448.  This section is noteworthy for having the longest code snippets.
  449.  
  450. ------------------------------
  451.  
  452. Subject: <Q:08.01> - How can a program reboot my PC?
  453. Date: 8 Feb 2002 20:16:09 -0400
  454.  
  455.  You can generate a "cold" boot or a "warm" boot. A cold boot is the same
  456.  as turning the power off and on; a warm boot is the same as Ctrl-Alt-Del
  457.  and skips the power-on self 'test.
  458.  
  459.  For a warm boot, store the hex value 1234 in the word at 0040:0072. For
  460.  a cold boot, store 0 in that word. Then, if you want to live
  461.  dangerously, jump to address FFFF:0000. Here's C code to do it:
  462.  
  463.    /* WARNING:  data loss possible */
  464.    void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */
  465.    {
  466.      void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  467.      
  468.      unsigned far* type = (unsigned far*)0x00400072UL;
  469.      *type = (want_warm ? 0x1234 : 0);
  470.      (*boot)( );
  471.    }
  472.  
  473.  What's wrong with that method? It will boot right away, without closing
  474.  files, flushing disk caches, etc. If you boot without flushing a
  475.  write-behind disk cache (if one is running), you could lose data or
  476.  trash the file allocation table in your hard drive.
  477.  
  478.  There are two methods of signaling the cache to flush its buffers:
  479.  
  480.  (1) Simulate a keyboard Ctrl-Alt-Del in the keystroke translation
  481.  function of the BIOS (INT 15 AH=4F; but see notes below)
  482.  
  483.  (2) Issue a disk reset (DOS function 0D). Most disk-cache programs hook
  484.  one or both of those interrupts, so if you use both methods you'll
  485.  probably be safe.
  486.  
  487.  When user code simulates a Ctrl-Alt-Del, one or more of the programs
  488.  that have hooked INT 15 AH=4F can ask that the key be ignored by
  489.  clearing the carry flag. For example, HyperDisk does this when it has
  490.  started but not finished a cache flush. So if the carry flag comes back
  491.  cleared, the boot code has to wait a couple of clock ticks and then try
  492.  again. (None of this matters on older machines whose BIOS can't support
  493.  101- or 102-key keyboards; see the discussion of INT 21 AH=4F in
  494.  <Q:04.07> [What is the SysRq key for?])
  495.  
  496.  C code that tries to signal the disk cache (if any) to flush is given
  497.  below. Turbo Pascal code by Timo Salmi that does more or less the same
  498.  job may be found at question 49 (as of this writing) in the Turbo Pascal
  499.  FAQ in comp.lang.pascal, and is downloadable as file FAQPAS2.TXT, which
  500.  is part of: <ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip>
  501.  
  502.  Here's C code that reboots after trying to signal the disk cache:
  503.  
  504.    #include <dos.h>
  505.    
  506.    void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm  */
  507.    {
  508.      union REGS reg;
  509.  
  510.      void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  511.      unsigned far* boottype = (unsigned far*)0x00400072UL;
  512.      char     far* shiftstate = (char far*)0x00400017UL;
  513.      unsigned      ticks;
  514.      int           time_to_waste;
  515.  
  516.      /* Simulate reception of Ctrl-Alt-Del: */
  517.      for (;;)
  518.      {
  519.        *shiftstate |= 0x0C;    /* turn on Ctrl & Alt */
  520.        reg.h.ah = 0x4F;        /* see notes below */
  521.        reg.h.al = 0x53;        /* 0x53 = Del's scan code */
  522.        reg.x.cflag = 1;        /* sentinel for ignoring key  */
  523.        int86(0x15, ®, ®);
  524.  
  525.        /* If carry flag is still set, we've finished. */
  526.        if(reg.x.cflag)
  527.          break;
  528.  
  529.        /* Else waste some time before trying again: */
  530.        reg.h.ah = 0;
  531.        int86(0x1A, ®, ®); /* system time into CX:DX */
  532.  
  533.        ticks = reg.x.dx;
  534.        for (time_to_waste = 3;  time_to_waste > 0;  )
  535.        {
  536.          reg.h.ah = 0;
  537.          int86(0x1A, ®, ®);
  538.          if (ticks != reg.x.dx)
  539.            ticks = reg.x.dx , --time_to_waste;
  540.        }
  541.      }
  542.  
  543.      /* Issue a DOS disk reset request: */
  544.      reg.h.ah = 0x0D;
  545.      int86(0x21, ®, ®);
  546.  
  547.      /* Set boot type and boot: */
  548.      *boottype = (want_warm ? 0x1234 : 0);
  549.      (*boot)( );
  550.    }
  551.  
  552.  Reader Timo Salmi reported (26 July 1993) that the INT 15 AH=4F call may
  553.  not work on older PCs (below AT, XT2, XT286), according to Ralf Brown's
  554.  interrupt list (<Q:02.03> [What and where is Ralf Brown's interrupt
  555.  list?]).
  556.  
  557.  Reader Roger Fulton reported (1 July 1993) that INT 15 AH=4F hangs even
  558.  a modern PC "ONLY when ANSI.SYS [is] loaded high using EMM386.EXE.
  559.  (Other things loaded high with EMM386.EXE were OK; ANSI.SYS loaded high
  560.  with QEMM386.SYS was OK; ANSI.SYS loaded low with EMM386.EXE installed
  561.  was OK.)" His solution was to use only the disk reset, INT 21 AH=0D,
  562.  which does flush SMARTDRV, then wait five seconds in hopes that any
  563.  other disk-caching software would have time to flush its queue.
  564.  
  565.  Reader Per Bergland reported (10 Sep 1993) that the jump to FFFF:0000
  566.  will not work in Windows or other protected-mode programs. (For example,
  567.  when the above reboot code ran in a DOS session under Windows, a box
  568.  with "waiting for system shutdown" appeared. The PC hung and had to be
  569.  reset by cycling power.) His solution, which does a cold boot not a warm
  570.  boot, is to pulse pin 0 of the 8042 keyboard controller, which is
  571.  connected to the CPU's "reset" line.
  572.  
  573.  He has tested the following code on various Compaqs, and expects it will
  574.  work for any AT-class machine; he cautions that you must first flush the
  575.  disk cache as indicated above.
  576.  
  577.    cli
  578.    @@WaitOutReady:   ;  Busy-wait until  8042 ready for new command
  579.    in al,64h         ; read 8042 status byte
  580.    test al,00000010b ; this bit indicates input buffer full
  581.    jnz @@WaitOutReady
  582.    mov al,0FEh       ; Pulse "reset" = 8042 pin 0
  583.    out 64h,al        ; The PC will reboot now
  584.  
  585. ------------------------------
  586.  
  587. Subject: <Q:08.02> - How can I time events with finer resolution than the
  588.         system clock's 55 ms (about 18 ticks a second)?
  589. Date: 8 Feb 2002 20:19:05 -0400
  590.  
  591.  The PC Timing FAQ / Application Note, maintained by Kris Heidenstrom
  592.  (kheidenstrom@actrix.gen.nz), contains information relating to timing
  593.  with PC hardware and software. It can be found on SimTel:
  594.  <http://www.simtel.net/pub/pd/46935.html>
  595.  
  596.  The following files, among others, are downloadable from SimTel in the
  597.  <http://www.simtel.net/pub/msdos/sysutl/> directory:
  598.  
  599.    atim.zip       4783  881126  Precision program timing for AT
  600.  
  601.  In the <http://www.simtel.net/pub/msdos/c/> directory:
  602.  
  603.    millisec.zip   37734  911205  MSC/asm src for millisecond timing
  604.    mschrt3.zip    53708  910605  High-res timer toolbox for MSC 5.1
  605.    msec_12.zip    8484   920320  High-def timer v1.2 (C,ASM)
  606.    ztimer11.zip  77625  920428  Microsecond timer for C, C++, ASM
  607.  
  608.  For Turbo Pascal users, source and object code are downloadable as:
  609.  <ftp://garbo.uwasa.fi/pc/turbopas/bonus507.zip>
  610.  
  611.  Also see "Q: How is millisecond timing done?" in FAQPAS.TXT,
  612.  downloadable as part of: <ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip>
  613.  
  614. ------------------------------
  615.  
  616. Subject: <Q:08.03> - How can I find the error level of the previous
  617.         program?
  618. Date: 8 Feb 2002 20:21:49 -0400
  619.  
  620.  First, which previous program are you talking about? If your current
  621.  program ran another one, when the child program ends its error level is
  622.  available to the program that spawned it. Most high-level languages
  623.  provide a way to do this; for instance, in Turbo Pascal it's
  624.  Lo(DosExitCode) and the high byte gives the way in which the child
  625.  terminated. In Microsoft C, the exit code of a synchronous child process
  626.  is the return value of the spawn- type function that creates the
  627.  process.
  628.  
  629.  If your language doesn't have a function to return the error code of a
  630.  child process, you can use INT 21 AH=4D (get return code). By the way,
  631.  this will tell you the child's exit code and the manner of its ending
  632.  (normal, Ctrl-C, critical error, or TSR).
  633.  
  634.  It's much trickier if the current program wants to get the error level
  635.  of the program that ran and finished before this one started. G.A.
  636.  Theall has published source and compiled code to do this; the code is
  637.  downloadable as: <http://www.simtel.net/pub/pd/40610.html>
  638.  
  639.  (The code uses undocumented features in DOS 3.3 through 5.0. In the .DOC
  640.  file Theall says that the values returned under 4DOS or other
  641.  replacements won't be right.)
  642.  
  643. ------------------------------
  644.  
  645. Subject: <Q:08.04> - How can a program set DOS environment variables?
  646. Date: 8 Feb 2002 20:22:43 -0400
  647.  
  648.  Program functions that read or write "the environment" typically access
  649.  only the program's copy of it. What this Q really wants to do is to
  650.  modify the active environment, the one that is affected by SET commands
  651.  in batch files or at the DOS prompt. You need to do some programming to
  652.  find the active environment, and that depends on the version of DOS.
  653.  
  654.  A fairly well-written article in PC Magazine 28 Nov 1989 (viii:20),
  655.  pages 309-314, explains how to find the active environment, and includes
  656.  Pascal source code. The article hints at how to change the environment,
  657.  and suggests creating paths longer than 128 characters as one
  658.  application.
  659.  
  660.  Now as for downloadable source code, there are many possibilities.
  661.  
  662.  Stan Brown, the former list maintainer recommends the following:
  663.  <ftp://garbo.uwasa.fi/pc/envutil/rbsetnv1.zip>
  664.  
  665.  It includes some utilities to manipulate the environment, with source
  666.  code in C. A newer program from PC Magazine 22 Dec 1992 (XI: 22) is:
  667.  <ftp://garbo.uwasa.fi/pc/pcmagvol/vol11n22.zip>
  668.  
  669.  You can also use a call to INT 2E, Pass Command to Interpreter for
  670.  Execution; see Ralf Brown's interrupt list (<Q:02.03> [What and where is
  671.  Ralf Brown's interrupt list?]) for details and cautions.
  672.  
  673.  Reader Dr. John Stockton has written a unit for Turbo Pascal known as
  674.  jrs_envu.pas to facilitate writing to the environment. It is for DOS
  675.  (not DPMI) mode programs running under DOS to Win98, but not WinNT. It
  676.  can be downloaded from here:
  677.  <http://www.merlyn.demon.co.uk/programs/jrs_envu.pas>. For more
  678.  information, see <http://www.merlyn.demon.co.uk/batprogs.htm>.
  679.  
  680. ------------------------------
  681.  
  682. Subject: <Q:08.05> - How can I change the switch character to - from /?
  683. Date: 5 Feb 2002 22:03:03 -0400
  684.  
  685.  Under DOS 5.0 and above you can not. INT 21 AX=3700, get switch
  686.  character, always returns a '/' (hex 2F). But the DOS commands don't
  687.  even call that function: they simply hard code '/' as the switch
  688.  character.
  689.  
  690.  Some history: DOS used to let you change the switch character by using
  691.  SWITCHAR= in CONFIG.SYS or by calling DOS function 3701. DOS commands
  692.  and other programs called DOS function 3700 to find out the switch
  693.  character. If you changed the switch character to '-' (the usual
  694.  choice), you could then type "dir c:/c700 -p" rather than "dir c:\c700
  695.  /p". Under DOS 4.0, the DOS commands ignored the switch character but
  696.  functions 3700 and 3701 still worked and could be used by other
  697.  programs. Under DOS 5.0, even those functions no longer work, though all
  698.  DOS functions still accept '/' or '\' in file specs.
  699.  
  700.  You can reactivate the functions to get and set switchar by using
  701.  programs like SLASH.ZIP or the sample TSR called SWITCHAR in
  702.  amisl091.zip (see <Q:08.06> [How can I write a TSR
  703.  (terminate-stay-resident utility)?]). DOS commands will still use the
  704.  slash, but non-DOS programs that call DOS function 3700 will use your
  705.  desired switch character. (DOS replacements like 4DOS may honor the
  706.  switch character for internal commands.)
  707.  
  708.  Some readers may wonder why this is even an issue. Making '-' the switch
  709.  character frees up the front slash to separate names in the path part of
  710.  a file spec. This is easier for the ten-fingered to type, and it's one
  711.  less difference to remember for commuters between DOS and Unix. The
  712.  switch character is the only issue, since all the INT 21 functions
  713.  accept '/' or '\' to separate directory names.
  714.  
  715. ------------------------------
  716.  
  717. Subject: <Q:08.06> - How can I write a TSR (terminate-stay-resident
  718.         utility)?
  719. Date: 8 Feb 2002 20:31:08 -0400
  720.  
  721.  There are books, and there's code to download.
  722.  
  723.  First, the books:
  724.  
  725.  * Ray Duncan's {Advanced MS-DOS}, ISBN 1-55615-157-8, gives a brief
  726.    checklist intended for experienced programmers. The ISBN is for the
  727.    second edition, through DOS 4; but check to see whether the DOS 6
  728.    version is available yet.
  729.  
  730.  * {DOS 5: A Developer's Guide} by Al Williams, ISBN 1-55851-177-6, goes
  731.    into a little more detail, 90 pages worth!
  732.  
  733.  * Pascal programmers might look at {The Ultimate DOS Programmer's
  734.    Manual} by John Mueller and Wallace Wang, ISBN 0-8306-3534-3, for an
  735.    extended example in mixed Pascal and assembler.
  736.  
  737.  * For a pure assembler treatment, check Steven Holzner's {Advanced
  738.    Assembly Language}, ISBN 0-13-663014-6. He has a book with the same
  739.    title out from Brady Press, but it's about half as long as this one.
  740.  
  741.  Next, the code. Some of it is companion code to published articles,
  742.  which are also listed below:
  743.  
  744.  * John English (<http://www.it.bton.ac.uk/staff/je/>) has created a
  745.    wonderful C++ class for creating TSRs which includes several examples.
  746.    This one is my personal favorite. It is downloadable as:
  747.    <ftp://ftp.brighton.ac.uk/pub/je/tsr100je.zip>
  748.    <http://www.simtel.net/pub/pd/42697.html>
  749.  
  750.  * The Alternate Multiplex Interrupt Specification (AMIS),downloadable
  751.    as: <http://www.simtel.net/pub/pd/46788.html>
  752.    <ftp://garbo.uwasa.fi/pc/programming/altmpx35.zip>
  753.  
  754.  * Ralf Brown's assembly-language implementation of the AMIS spec, with
  755.    utilities in C, is downloadable as:
  756.    <ftp://garbo.uwasa.fi/pc/c-lang/amisl092.zip>
  757.  
  758.  * Douglas Boling's MASM template for a TSR is downloadable as:
  759.    <http://www.simtel.net/pub/pd/40314.html>
  760.  
  761.  * Code for Al Stevens's "Writing Terminate-and-Stay-Resident Programs",
  762.    Computer Language, February 1988, pages 37-48 and March 1988, pages
  763.    67-76 is downloadable as: <http://www.simtel.net/pub/pd/41812.html>
  764.  
  765.  Finally, there are (were?) commercial products, of which TesSeRact (for
  766.  C-language TSRs) is one of the best known.
  767.  
  768. ------------------------------
  769.  
  770. Subject: <Q:08.07> - Why does my interrupt function behave strangely?
  771. Date: 8 Feb 2002 20:32:03 -0400
  772.  
  773.  Interrupt service routines can be tricky, because you have to do some
  774.  things differently from "normal" programs. If you make a mistake,
  775.  debugging is a pain because the symptoms may not point at what's wrong.
  776.  Your machine may lock up or behave erratically, or just about anything
  777.  else can happen. Here are some things to look for. (See <Q:08.06> [How
  778.  can I write a TSR (terminate-stay-resident utility)?] for general
  779.  techniques that may prevent a problem.)
  780.  
  781.  First, did you fail to set up the registers at the start of your
  782.  routine? When your routine begins executing, you can count on having CS
  783.  point to your code segment and SS:SP point to some valid stack (of
  784.  unknown length), and that's it. In particular, an interrupt service
  785.  routine must set DS to DGROUP before accessing any data in its data
  786.  segments. (If you're writing in a high-level language, the compiler may
  787.  generate this code for you automatically; check your compiler manual.
  788.  For instance, in Borland and Microsoft C, give your function the
  789.  "interrupt" attribute.)
  790.  
  791.  Did you remember to turn off stack checking when compiling your
  792.  interrupt server and any functions it calls? The stack during the
  793.  interrupt is not where the stack-checking code expects it to be.
  794.  (Caution: Some third-party libraries have stack checking compiled in, so
  795.  you can't call them from your interrupt service routine.)
  796.  
  797.  Next, are you calling any DOS functions (INT 21, 25, or 26) in your
  798.  routine? DOS is not re-entrant. This means that if your interrupt
  799.  happens to be triggered while the CPU is executing a DOS function,
  800.  calling another DOS function will wreak havoc. (Some DOS functions are
  801.  fully re-entrant, as noted in Ralf Brown's interrupt list (<Q:02.03>
  802.  [What and where is Ralf Brown's interrupt list?]). Also, your program
  803.  can test, in a way too complicated to present here, when it's safe to
  804.  call non-re-entrant DOS functions. See INT 28, INT 21 AH=34, and INT 21
  805.  AX=5D06 or 5D0B; and consult {Undocumented DOS} by Andrew Schulman. Your
  806.  program must read both the "InDOS flag" and the "critical error flag".)
  807.  
  808.  Is a function in your language library causing trouble? Does it depend
  809.  on some initializations done at program startup that is no longer
  810.  available when the interrupt executes? Does it call DOS (see preceding
  811.  paragraph)? For example, in both Borland and Microsoft C the memory-
  812.  allocation functions (malloc(), etc..) call DOS functions and also
  813.  depend on setups that they can't get at from inside an interrupt; so do
  814.  the standard I/O functions like scanf() and printf(). Many other library
  815.  functions have the same problem, so you can't use them inside an
  816.  interrupt function without special precautions.
  817.  
  818.  Is your routine simply taking too long? This can be a problem if you're
  819.  hooking on to the timer interrupt, INT 1C or INT 8. That interrupt
  820.  expects to be called about every 55 ms, which is 18.2 times a second.
  821.  Therefore your routine, plus any others hooked to the same interrupts,
  822.  must execute in less than 55 ms. If they use even a substantial fraction
  823.  of that time, you'll see significant slowdowns of your foreground
  824.  program. A good discussion is downloadable as:
  825.  <http://www.simtel.net/pub/pd/46893.html>
  826.  
  827.  Did you forget to restore all registers at the end of your routine?
  828.  
  829.  Reader, Morten Welinder, notes that programmers of interrupt procedures
  830.  in Borland/Turbo Pascal 7.0 should be aware that the high words or the
  831.  32-bit registers are not saved automatically and that the run-time
  832.  library may trash them if, e.g., you use longint operations. The easy
  833.  way around this is to do "Test8086 := 0;" before installing the
  834.  interrupt handler.
  835.  
  836.  Did you chain improperly to the original interrupt? You need to restore
  837.  the stack to the way it was upon entry to your routine, then do a far
  838.  jump (not call) to the original interrupt service routine.
  839.  
  840.  (The process is a little different in high-level languages.)
  841.  
  842. ------------------------------
  843.  
  844. Subject: <Q:08.08> - How can I write a device driver?
  845. Date: 5 Feb 2002 22:03:03 -0400
  846.  
  847.  Many books answer this in detail. Among them are {Advanced MS-DOS} and
  848.  {DOS 5: A Developer's Guide}, cited in the preceding Q. Michael
  849.  Tischer's {PC System Programming}, ISBN 1-55755-036-0, has an extensive
  850.  treatment, as does Dettman and Kyle's {DOS Programmer's Reference: 2d
  851.  Edition}, ISBN 0-88022-458-4. For a really in-depth treatment, look for
  852.  a specialized book like Robert Lai's {Writing MS-DOS Device Drivers},
  853.  ISBN 0-201-13185-4.
  854.  
  855. ------------------------------
  856.  
  857. Subject: <Q:08.09> - What can I use to manage versions of software?
  858. Date: 8 Feb 2002 20:34:22 -0400
  859.  
  860.  A port of the Unix RCS utility is downloadable as:
  861.  <http://www.simtel.net/gnudlpage.php?product=/gnu/gnuish/rcs57pc2.zip&name=rcs57pc2.zip>
  862.  (executable)
  863.  <http://www.simtel.net/gnudlpage.php?product=/gnu/gnuish/rcs57pc1.zip&name=rcs57pc1.zip>
  864.  (source)
  865.  
  866.  This version of RCS is no longer limited to one-character extensions on
  867.  filenames (for example, .CPP and .BAS are now OK).
  868.  
  869.  As for commercial software, I posted a question asking for readers'
  870.  experiences in July 1993 and seven readers responded. PVCS from
  871.  Intersolv (formerly Polymake) got five positive reviews, though several
  872.  readers commented that it's expensive; RCS from MKS got one positive and
  873.  one negative review; Burton TLIB got one negative review; DRTS from ILSI
  874.  got one positive review.
  875.  
  876. ------------------------------
  877.  
  878. Subject: <Q:08.10> - What's this 'null pointer assignment' after my C
  879.         program executes?
  880. Date: 8 Feb 2002 20:35:32 -0400
  881.  
  882.  Somewhere in your program, you assigned a value through a pointer
  883.  without first assigning a value to the pointer. (This might have been
  884.  something like a strcpy() or memcpy() with a pointer as its first
  885.  argument, not necessarily an actual assignment statement.)
  886.  
  887.  Your program may look like it ran correctly, but if you get this message
  888.  you can be certain that there's a bug somewhere.
  889.  
  890.  Microsoft and Borland C, as part of their exit code (after a call to
  891.  exit() or a return from your main function), check whether the location
  892.  0000 in your data segment contains a different value from what you
  893.  started with. If so, they infer that you must have used an uninitialized
  894.  pointer. This implies that the message will appear at the end of
  895.  execution of your program regardless of where the error actually
  896.  occurred.
  897.  
  898.  To track down the problem, you can put exit() calls at various spots in
  899.  the program and narrow down where the uninitialized pointer is being
  900.  used by seeing which added exit() makes the null-pointer message
  901.  disappear. Or, if your program was compiled with small or medium models,
  902.  which use 16-bit data pointers, tell the debugger to set a watch at
  903.  location 0000 in your data segment. (If data pointers are 32 bits, as in
  904.  the compact and large models, a null pointer will overwrite the
  905.  interrupt vectors at 0000:0000 and probably lock up your machine.)
  906.  
  907.  Under MSC/C++ 7.0, you can declare the undocumented library function:
  908.  extern _cdecl _nullcheck(void);
  909.  
  910.  Sprinkle calls to _nullcheck() through your program at regular
  911.  intervals.
  912.  
  913.  Borland's TechFax document TI726 discusses the null pointer assignment
  914.  from a Borland point of view. It's one of many documents downloadable as
  915.  part of: <http://www.simtel.net/pub/pd/50843.html>
  916.  <ftp://garbo.uwasa.fi/pc/turbopas/bchelp10.zip>
  917.  
  918. ------------------------------
  919.  
  920. Subject: <Q:08.11> - How can a batch file tell whether it's being run in
  921.         a DOS box under Windows?
  922. Date: 5 Feb 2002 22:03:03 -0400
  923.  
  924.  When Windows 3.0 or 3.1 is running, the DOS environment will contain a
  925.  definition of the string windir, in lower case. That's not really
  926.  useful, however, because the batch statement
  927.  
  928.   if "%windir%" == "" ...
  929.  
  930.  will test for an environment variable WINDIR in upper case.
  931.  
  932.  Your only real option is to write a program as suggested by the
  933.  following question, and have it return a value which your batch file can
  934.  test via "if errorlevel".
  935.  
  936. ------------------------------
  937.  
  938. Subject: <Q:08.12> - How can my program tell if it's running under
  939.         Windows?
  940. Date: 8 Feb 2002 20:37:06 -0400
  941.  
  942.  Execute INT 2F AX=4680. If AX returns 0, you're in Windows real mode or
  943.  standard mode (or under the DOS shell). Otherwise, call INT 2F AX=1600.
  944.  If AL returns something other than 0 or 80, you're in Windows 386
  945.  enhanced mode. See PC Magazine 24 Nov 1992 (xi:20) pages 492-493.
  946.  
  947.  For more information, see PC Magazine 26 May 1992 (xi:10) pages 345-346.
  948.  A program, WINMODE, is available as part of:
  949.  <http://www.simtel.net/pub/pd/48500.html>
  950.  <ftp://garbo.uwasa.fi/pc/pcmagvol/vol11n10.zip>
  951.  
  952.  PC Magazine 29 March 1994 (xiii: 6) pages 312 and 320 published a new
  953.  program, WINVER. This would be in:
  954.  <http://www.simtel.net/pub/pd/48540.html>
  955.  <ftp://garbo.uwasa.fi/pc/pcmagvol/vol13n06.zip>
  956.  
  957. ------------------------------
  958.  
  959. Subject: <Q:08.13> - How can a program tell whether ANSI.SYS is
  960.         installed?
  961. Date: 5 Feb 2002 22:03:03 -0400
  962.  
  963.  In DOS 4.0 and above, call INT 2F AX=1A00. If the value FF is returned
  964.  in AL, ANSI.SYS is installed. For more information, see Ralf Brown's
  965.  interrupt list (<Q:02.03> [What and where is Ralf Brown's interrupt
  966.  list?]).
  967.  
  968. ------------------------------
  969.  
  970. Subject: <Q:08.14> - How do I copyright software that I write?
  971. Date: 5 Feb 2002 22:03:03 -0400
  972.  
  973.  You can download a very comprehensive answer from the Internet. Terry
  974.  Carroll posts a six-part Copyright FAQ to misc.legal, news.answers and
  975.  other groups. A short answer follows, not based on that article.
  976.  
  977.  Disclaimer: I am not a lawyer, and this is not legal advice. Also, there
  978.  are very likely to be differences in copyright law among nations. No
  979.  matter where you live, if significant money may be involved, get legal
  980.  advice. The following is adapted (and greatly condensed) from chapter 4
  981.  of the Chicago Manual of Style (13th edition, ISBN 0-226- 10390-0).
  982.  
  983.  In the U.S. (at least), when you write something, you own the copyright.
  984.  (The exception that matters most to programmers is "works made for
  985.  hire", i.e., code you write because your employer or client pays you to.
  986.  A contract, agreed in advance, can vest the copyright in the programmer
  987.  even if an employee; otherwise the employer owns the copyright.) You
  988.  don't have to register the work with the Copyright Office unless (until)
  989.  the copyright is infringed and you intend to bring suit; however, it is
  990.  easier to recover damages in court if you did register the work within
  991.  three months of publication.
  992.  
  993.  From paragraph 4.16 of the Chicago Manual: "... the [copyright] notice
  994.  consists of three parts: (1) the symbol [C-in-a-circle] (preferred
  995.  because it also suits the requirements of the Universal Copyright
  996.  Convention), the word 'Copyright', or the abbreviation 'Copr.', (2) the
  997.  year of first publication, and (3) the name of the copyright owner. Most
  998.  publishers also add the phrase 'All rights reserved' because it affords
  999.  some protection in Central and South American countries...."
  1000.  
  1001.  Surprise: "(C)" is legally not the same as the C-in-a- circle, so those
  1002.  of us who are ASCII-bound must use the word or the abbreviation.
  1003.  
  1004. ------------------------------
  1005.  
  1006. Subject: <Q:08.15> - How can I place date and time information into
  1007.         environment variables?
  1008. Date: 6 Feb 2002 10:16:12 -0400
  1009.  
  1010.  You can use a program known as NOWMINUS. More information about NOWMINUS
  1011.  can be found at <http://www.merlyn.demon.co.uk/programs/nowminus.txt>.
  1012.  Pascal source code is included.
  1013.  
  1014. ------------------------------
  1015.  
  1016. Subject: Conclusion
  1017.  
  1018. This is the end of part 4 of 5 parts.
  1019.  
  1020. This text is copyright 2003 by Jeffrey Carlyle. All rights reserved.
  1021. Please see the top of this article for additional copyright information.
  1022.  
  1023.