home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / internet / faq / englisch / comp.os.msdos.programmer < prev    next >
Encoding:
Text File  |  1995-04-11  |  139.2 KB  |  3,253 lines

  1. Archive-name: msdos-programmer-faq/faq
  2. Comp-os-msdos-programmer-archive-name: dos-faq
  3. Garbo-archive-name: pc/doc-net/dosfv203.zip
  4. Posting-frequency: monthly
  5. Last-modified: 13 Jan 1994
  6.  
  7. ------------------------------
  8.  
  9. Subject: Title Page
  10.  
  11. comp.os.msdos.programmer FAQ Version 2.03
  12.  
  13. Copyright (C) 1995 by Jeffrey Carlyle, Perplexic Software.  All rights
  14. reserved.  This article is not  in the public  domain,  but it  may be 
  15. redistributed  so long as  this notice,  the acknowledgments,  and the 
  16. information on obtaining the latest copy of this list are retained and
  17. no fee is charged. The code fragments may be used freely; credit would 
  18. be polite.
  19.  
  20. ------------------------------
  21.  
  22. Subject: TABLE OF CONTENTS
  23.  
  24. Section 1.  General FAQ and Newsgroup Information
  25.   1.01 - What is this article for? *revised*
  26.   1.02 - Who has contributed to this article? *revised*
  27.   1.03 - How can I search this article for a particular topic?
  28.   1.05 - Are the answers guaranteed to be correct and complete?
  29.   1.06 - What is comp.os.msdos.programmer about? 
  30.   1.07 - Is comp.os.msdos.programmer just for C programmers?
  31.   1.08 - What is comp.sys.ibm.pc.programmer?
  32.   1.09 - Is comp.os.msdos.programmer available as a mailing list?
  33.   1.10 - What's this "netiquette"?
  34.   1.11 - How can I learn more about Usenet?
  35.   1.12 - What other technical newsgroups should I know about?
  36.   1.13 - Where are FAQ lists archived?
  37.   1.14 - Where can I get the latest copy of this FAQ list? 
  38.   1.15 - Are there any good on-line references for PC hardware components?
  39.   1.16 - Are there any good on-line references for PC interrupts?
  40.   1.17 - What and where is "Ralf Brown's interrupt list"?
  41.   1.18 - Where can I find lex, yacc, and language grammars?
  42.   1.19 - What's the best book to learn programming?
  43.   1.20 - How do I use ftp? 
  44.   1.21 - Why won't my code work?
  45.     
  46. Section 2.  Compile and Link
  47.   2.01 - What the heck is "DGROUP > 64K"? 
  48.   2.02 - How do I fix "automatic data segment exceeds 64K" or "stack
  49.          plus data exceed 64K"?
  50.   2.03 - Will Borland C code and Microsoft C code link together? 
  51.   2.04 - Why did my program bomb at run time with "floating point
  52.          formats not linked" or "floating point not loaded"?
  53.   2.05 - How can I change the stack size in Borland's C compilers? 
  54.   2.06 - What's the format of an .OBJ file? 
  55.   2.07 - What's the format of an .EXE header?
  56.   2.08 - What's the difference between .COM and .EXE formats?
  57.   2.09 - How do I create a .COM file? *new*
  58.   2.10 - Where is EXE2BIN located? *new*  
  59.  
  60. Section 3.  Keyboard
  61.   3.01 - How can I read a character without echoing it to the screen,
  62.          and without waiting for the user to press the Enter key?
  63.   3.02 - How can I find out whether a character has been typed, without
  64.          waiting for one?
  65.   3.03 - How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  66.   3.04 - How can I disable the print screen function?
  67.   3.05 - How can my program turn NumLock (CapsLock, ScrollLock) on or
  68.          off?
  69.   3.06 - How can I speed up the keyboard's auto-repeat?
  70.   3.07 - What is the SysRq key for?
  71.   3.08 - How can my program tell what kind of keyboard is on the system?
  72.   3.09 - How can I tell if input, output, or stderr has been redirected?
  73.   3.10 - How can I increase the size of the keyboard buffer? *revised*
  74.   3.11 - How can I stuff characters into the keyboard buffer?
  75.  
  76. Section 4.  Disks and files
  77.   4.01 - What drive was the PC booted from?
  78.   4.02 - How can I boot from drive b:?
  79.   4.03 - Which real and virtual disk drives are valid? *revised*
  80.   4.04 - How can I make my single floppy drive both a: and b:?
  81.   4.05 - How can I disable access to a drive?
  82.   4.06 - How can a batch file test existence of a directory?
  83.   4.07 - Why won't my C program open a file with a path?
  84.   4.08 - How can I redirect printer output to a file? 
  85.   4.09 - How can I redirect the output of a batch file? 
  86.   4.10 - How can I redirect stderr? 
  87.   4.11 - How can my program open more files than DOS's limit of 20?
  88.   4.12 - How can I read, create, change, or delete the volume label?
  89.   4.13 - How can I get the disk serial number? 
  90.   4.14 - What's the format of .OBJ, .EXE., .COM files?
  91.   4.15 - How can I flush the software disk cache?
  92.  
  93. Section 5.  Serial ports (COM ports)
  94.   5.01 - How do I set my machine up to use COM3 and COM4?
  95.   5.02 - How do I find the I/O address of a COM port? 
  96.   5.03 - But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
  97.          and 2E8?
  98.   5.04 - How do I configure a COM port and use it to transmit data?
  99.  
  100. Section 6.  Other hardware questions and problems
  101.   6.01 - Which 80x86 CPU is running my program?
  102.   6.02 - How can a C program send control codes to my printer?
  103.   6.03 - How can I redirect printer output to a file?
  104.   6.04 - Which video adapter is installed?
  105.   6.05 - How do I switch to 43- or 50-line mode?
  106.   6.06 - How can I find the Microsoft mouse position and button status?
  107.   6.07 - How can I access a specific address in the PC's memory?
  108.   6.08 - How can I read or write my PC's CMOS memory?
  109.   6.09 - How can I access memory beyond 640K?
  110.   6.10 - How can I use the protected mode? 
  111.  
  112. Section 7.  Other software questions and problems
  113.   7.01 - How can a program reboot my PC?
  114.   7.02 - How can I time events with finer resolution than the system
  115.          clock's 55 ms (about 18 ticks a second)?
  116.   7.03 - How can I find the error level of the previous program?
  117.   7.04 - How can a program set DOS environment variables?
  118.   7.05 - How can I change the switch character to - from /?
  119.   7.06 - How can I write a TSR (terminate-stay-resident utility)?
  120.   7.07 - Why does my interrupt function behave strangely? *revised*
  121.   7.08 - How can I write a device driver?
  122.   7.09 - What can I use to manage versions of software?
  123.   7.10 - What's this "null pointer assignment" after my C program
  124.          executes?
  125.   7.11 - How can a batch file tell whether it's being run in a DOS box
  126.          under Windows?
  127.   7.12 - How can my program tell if it's running under Windows?
  128.   7.13 - How can a program tell whether ANSI.SYS is installed?
  129.   7.14 - How do I copyright software that I write?
  130.  
  131. Section 8.  Downloading
  132.   8.01 - What are SimTel, Garbo, and Wustl?
  133.   8.02 - I have no ftp access.  How can I get files from the archives?
  134.   8.03 - Can I get archives on CD-ROM?
  135.   8.04 - Where do I find program <mumble>?
  136.   8.05 - How can I check SimTel or Garbo before I post a request for a
  137.          program?
  138.   8.06 - How do I download and decode a program I found?
  139.   8.07 - Where is UUDECODE?
  140.   8.08 - Why do I get errors when extracting from a ZIP file I downloaded?
  141.  
  142. Section 9.  Vendors and products
  143.   9.01 - How can I contact Borland? *revised*
  144.   9.02 - How can I contact Microsoft? 
  145.   9.03 - What's the current version of UNZIP? 
  146.   9.04 - What is the phone number for a vendor's BBS?
  147.  
  148. ------------------------------
  149.  
  150. Subject: THE ANSWERS
  151.  
  152. ------------------------------
  153.  
  154. Subject: Section 1.  General FAQ and Newsgroup Information
  155.  
  156. ------------------------------
  157.  
  158. Subject: 1.01 - What is this article for? *revised*
  159. Date: Fri, 13 Jan 95 15:34:00 CDT
  160.  
  161.     This is the FAQ (Frequently Asked Questions) list for the newsgroup
  162.     comp.os.msdos.programmer. This list is maintained in versions; new
  163.     questions and revised questions in this version are marked in with
  164.     "*new*" or "*revised*" in the subject. This list is posted monthly.
  165.  
  166.     FAQ lists are intended to reduce the noise level in their newsgroups
  167.     that results from the repetition of the same questions, correct
  168.     answers, wrong answers, corrections to the wrong answers,
  169.     corrections to the corrections, debate, etc.
  170.     
  171.     This list should serve as a repository of the canonical "best"
  172.     answers to the questions in it.  The names of folks who have helped
  173.     to improve this FAQ list are listed in "1.02 - Who has contributed to
  174.     this article?"
  175.     
  176. ------------------------------
  177.  
  178. Subject: 1.02 - Who has contributed to this article? *revised*
  179. Date: Wed, 11 Jan 95 15:34:00 CDT
  180.  
  181.     This list is maintained and edited by Jeffrey Carlyle, Perplexic
  182.     Software, Bowling Green, Kentucky, USA. (jeffrey.carlyle@bgamug.com)
  183.  
  184.     The major contributor to this list is Stan Brown, the former list 
  185.     maintainer. Most of this list was written by Stan. He can be contacted
  186.     at brown@NCoast.ORG.
  187.  
  188.     Many articles posted in comp.os.msdos.programmer sparked ideas or
  189.     provided information for the first version of this list.  Though
  190.     they are not responsible for any errors, thanks are due to the
  191.     following persons for posted articles or private email that led to
  192.     improvements in this FAQ list:
  193.  
  194.     Jamshid Afshar, Mark Aitchison, Sanjay Aiyagari, George Almasi,
  195.     Aaron Auseth, Robert Baker, Preston Bannister, Scott Barman, Denis
  196.     Beauregard, Per Bergland, Mike Black, Chris Blum, Ron Bodkin, Mark
  197.     Brader, Jon Brinkmann, Andrew James Bromage, Glynn Brooks, Paul
  198.     Brooks, Ralf Brown, Shaun Burnett, D'Arcy J.M. Cain, Raymond Chen,
  199.     Denny de Jonge, Eric DeVolder, Alan Drew, Paul Ducklin, Gary Dueck,
  200.     Roland Eriksson, Mark Evans, Markus Fischer, George Forsman, Roger
  201.     Fulton, Vincent Giovannone, Robert Grunloh, B.Haible, Janos Haide,
  202.     Klaus Hartnegg, Kris Heidenstrom, Tom Haapanen, Joel Hoffman, Ari
  203.     Hovila, Chin Huang, Joe Huffman, Michael Holin, Mike Iarrobino,
  204.     Byrial Jensen, Rune Jorgensen, Ajay Kamdar, Everett Kaser, Jeff
  205.     Kellam, Jen Kilmer, Reinhard Kirchner, Dave Kirsch, Chad Knudsen,
  206.     Samuel Ko, Jan Kotas, Janne Kukonlehto, Benjamin Lee, Stephen Lee,
  207.     Jim Lynch, Greg Malknecht, Sidney Markowitz, Jim Marks, Dimitri
  208.     Matzarakis, Fred McCall, Ken McKee, Doug Merrett, Tom Milner, Bill
  209.     Moore, Duncan Murdoch, Steve Murphy, Daniel Neri, Mert Nickerson,
  210.     David Nugent, John Oldenburg, David Pape, Keith Petersen, Karl
  211.     Riedling, Arthur Rubin, Gerald Ruderman, Timo Salmi, Tapio Sand,
  212.     John Schmid, Russell Schulz, Huseyin Sevay, Ajay Shah, Bob Smith,
  213.     Sean Sullivan, Steve Summit, Tom Swingle, Anders Thulin, Curt
  214.     Tilmes, Rick Watkins, Ya-Gui Wei, Morten Welinder, Joe Wells, Scott
  215.     Winder, Gregory Youngblood, Eli Zaretski, khill@vax1.umkc.edu
  216.  
  217.     Contributors for this version were:
  218.       Morten Welinder, Jan Kotas
  219.  
  220.  
  221. ------------------------------
  222.  
  223. Subject: 1.03 - How can I search this article for a particular topic?
  224.  
  225.     To search for a particular topic, save this article to a text file
  226.     and use your favorite editor's find function to search for a word.
  227.  
  228.     You can use the MS-DOS Editor to search for a topic. Run the editor
  229.     and load the FAQ. Press ALT+S to activate the search menu then press
  230.     F. In the box that says find what enter the word you want to look for.
  231.     When you are completed, press enter. If a match is found EDIT will 
  232.     highlight it. If that is not what you were looking for press F3 and
  233.     EDIT will show you the next match.
  234.  
  235. ------------------------------
  236.  
  237. Subject: 1.05 - Are the answerers guaranteed to be correct and complete?
  238. Date: Wed, 05 Sep 94 15:34:00 CDT
  239.  
  240.     I have tried to test all of the facts, but THERE IS NO WARRANTY ON
  241.     THE CODE OR ON THE TECHNIQUES DESCRIBED HEREIN. Please send corrections
  242.     to jeffrey.carlyle@bgamug.com. All the code has been tested; but the
  243.     testing may not have been perfect, and machines and configurations vary.
  244.     (Except where otherwise noted, C code was tested with MSC 5, BC++ 2.0,
  245.     or BC++ 4.0.)
  246.  
  247.     The mention of particular books or programs must not be construed to
  248.     reflect unfavorably on any that are not mentioned.
  249.  
  250. ------------------------------
  251.  
  252. Subject: 1.06 - What is comp.os.msdos.programmer about?
  253. Date: Wed, 05 Sep 94 15:34:00 CDT
  254.  
  255.     comp.os.msdos.programmer (comp.sys.ibm.pc.programmer until September
  256.     1990) concerns programming for MS-DOS systems.  The article "USENET
  257.     Readership report for Jul 94" in news.lists shows 120,000 readers of
  258.     this newsgroup worldwide.  Traffic (exclusive of crossposts) was 1981
  259.     articles aggregating 3.1 Megabytes. It ranked as the 79th most popular
  260.     newsgroup.
  261.  
  262.     Much of our traffic is about language products (chiefly from Borland
  263.     and Microsoft).  More programming topics focus on C than on any one
  264.     other language, but we are not just for C programmers (see "1.07 - Is
  265.     comp.os.msdos.programmer just for C programmers?").
  266.  
  267.     Since most MS-DOS systems run on hardware that is roughly compatible
  268.     with the IBM PC, on Intel 8088, 80188, or 80x86 chips, we tend to
  269.     get a lot of questions and answers about programming other parts of
  270.     the hardware.
  271.  
  272. ------------------------------
  273.  
  274. Subject: 1.07 - Is comp.os.msdos.programmer just for C programmers?
  275.     
  276.     No, it is for all programmers who want to share information about
  277.     programming in MS-DOS and DOS replacements like 4DOS.  Programs and
  278.     questions are also posted in Pascal, assembly, and other languages
  279.     (including MS-DOS batch programming.)
  280.  
  281.     Why does the newsgroup seem to be so C-oriented sometimes?  There
  282.     are two reasons.  First, comp.lang.c and comp.lang.pascal have
  283.     evolved in different directions.  comp.lang.pascal welcomes vendor-
  284.     specific discussion, such as Turbo Pascal.  Since so many of TP's
  285.     features are tailored to programming on PCs and in MS-DOS, Turbo
  286.     Pascal programmers tend to find DOS questions welcomed there, so
  287.     that comp.os.msdos.programmer gets less of the "DOS in Turbo Pascal"
  288.     traffic.  On the other hand, comp.lang.c has stayed closer to
  289.     talking only about the C language, and vendor-specific or operating-
  290.     system-specific questions are not welcome.  This tends to push
  291.     questions about disks, DOS file structure, video, the keyboard,
  292.     TSRs, etc. to comp.os.msdos.programmer even when those programs are
  293.     written in C.
  294.  
  295.     This FAQ is definitely C-oriented, not because that's necessarily
  296.     best but because I tried to stick to what I could verify personally.
  297.     As a C programmer (with some assembler), I could most carefully
  298.     verify solutions in C or assembler.  I felt that short, clear
  299.     programs could be published in just one language and programmers
  300.     could translate them into their languages of choice.  But the FAQ
  301.     list also contains several long programs written only in C; this is
  302.     a defect with no obvious remedy.  Most answers that point to source
  303.     code at archive sites include both C- and Pascal-language source
  304.     when available.
  305.   
  306. ------------------------------
  307.  
  308. Subject: 1.08 - What is comp.sys.ibm.pc.programmer?
  309.  
  310.     comp.sys.ibm.pc.programmer is the old name of comp.os.msdos.programmer, 
  311.     and has been obsolete since September 1990.  However, many systems have
  312.     not removed the old group, or have removed it but aliased it to the
  313.     new name.  This means that some people still think they're posting
  314.     to comp.sys.ibm.pc.programmer even though they're actually posting to
  315.     comp.os.msdos.programmer.
  316.  
  317.     You can easily verify the non-existence of comp.sys.ibm.pc.programmer by
  318.     reference to the "List of Active Newsgroups" posted to news.groups.
  319.     It's available at:
  320.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/active-newsgroups/part1>
  321.  
  322.     (For more info see "1.13 - Where are FAQ lists archived?")
  323.   
  324. ------------------------------
  325.  
  326. Subject: 1.09 - Is comp.os.msdos.programmer available as a mailing list?
  327.  
  328.     Sorry, no.
  329.  
  330. ------------------------------
  331.  
  332. Subject: 1.10 - What's this "netiquette"?
  333.  
  334.     Netiquette is good Usenet etiquette.  It includes basic rules like
  335.     the ones below.  (See also "1.11 - How can I learn more about
  336.     Usenet?")
  337.  
  338.     - Always read a newsgroup for a reasonable time before you post an
  339.       article to it.
  340.  
  341.     - Pick the one right group for your article; don't crosspost unless
  342.       absolutely necessary.  If you absolutely must post an article to
  343.       more than one group, do crosspost it and don't post the same
  344.       article separately to each group.  See "1.12 - What other technical
  345.       newsgroups should I know about?" when considering where to post an
  346.       article.
  347.  
  348.     - Before you post a question, make sure you're posting to the right
  349.       newsgroup; the best way to do that is to observe the preceding
  350.       rule.  Check the group's FAQ list (if it has one) to make sure
  351.       that your question isn't already answered there; see "1.13 - Where
  352.       are FAQ lists archived?".
  353.  
  354.     - When you post a question, if you ask for email responses then
  355.       promise to post a summary.  Keep your promise.  And make it a real
  356.       summary: don't just append all the email you got.  Instead, write
  357.       your own (brief) description of the solution:  this is the best
  358.       way to make sure you really understand it.
  359.  
  360.     - Before you post a follow-up, read the other follow-ups.  Very
  361.       often you'll find that someone else has already made the point you
  362.       had in mind.
  363.  
  364.     - When someone posts a question, if you want to know the answer
  365.       don't post a "me, too".  Instead send email to the poster asking
  366.       him or her to share responses with you.
  367.  
  368.     - When posting a follow-up to another posted article, remove all
  369.       headers and signature lines from the old article; just keep the
  370.       line "In <article>, so-and-so writes:".  Also cut the original
  371.       article down as much as possible; just keep enough of it to remind
  372.       readers of the context.
  373.  
  374.     - Keep lines in posted articles to 72-75 characters.  Many
  375.       newsreaders chop off column 81 or arbitrarily insert a newline
  376.       there, which makes longer lines difficult or impossible to read.
  377.       But you need to keep well below 80 characters per line to allow
  378.       for the > characters that get inserted when other people post
  379.       follow-ups to your article.
  380.  
  381.     - Keep your signature to 4 lines or less (including any graphics),
  382.       and for heaven's sake make sure it doesn't get posted twice in
  383.       your article.
  384.  
  385.     - Don't post email without first obtaining the permission of the
  386.       sender.
  387.     
  388. ------------------------------
  389.  
  390. Subject: 1.11 - How can I learn more about Usenet?
  391.     
  392.     There are two important newsgroups for learning about how Usenet and
  393.     newsreader software works:
  394.  
  395.     - news.announce.newusers contains periodic postings that everybody
  396.       is asked to read before posting anything to Usenet.  (In theory,
  397.       all new users are subscribed to news.announce.newusers
  398.       automatically.  But in practice not all newsreader software does
  399.       that, so that many people violate the guidelines given there
  400.       simply because they don't know about them.)
  401.  
  402.     - news.newusers.questions is described as "Q & A for users new to
  403.       the Usenet".  But new and long-time users can ask or answer
  404.       questions about Usenet and newsreader software there.  There's an
  405.       important article, "Welcome to news.newusers.questions! (weekly
  406.       posting)", that everyone is asked to read before posting to
  407.       news.newusers.questions.  (See below for ways to get a copy of
  408.       that article.)
  409.  
  410.     The following postings in news.announce.newusers might be considered
  411.     the "mandatory course" for new users:
  412.  
  413.         Introduction to news.announce.newusers
  414.         What is Usenet?
  415.         Answers to Frequently Asked Questions
  416.         Rules for posting to Usenet
  417.         A Primer on How to Work With the Usenet Community
  418.         Hints on writing style for Usenet
  419.         Emily Postnews Answers Your Questions on Netiquette
  420.  
  421.     The articles mentioned above are downloadable via ftp from
  422.     rtfm.mit.edu in the following files:
  423.  
  424.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/news-newusers-intro>
  425.             Welcome to news.newusers.questions! (weekly posting)
  426.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/news-announce-intro/part1>
  427.             Introduction to news.announce.newusers
  428.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/what-is-usenet/part1>
  429.             What is Usenet?
  430.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/usenet-faq/part1>
  431.             Answers to Frequently Asked Questions
  432.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/posting-rules/part1>
  433.             Rules for posting to Usenet
  434.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/usenet-primer/part1>
  435.             A Primer on How to Work With the Usenet Community
  436.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/usenet-writing-style/part1>
  437.             Hints on writing style for Usenet
  438.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/emily-postnews/part1>
  439.             Emily Postnews Answers Your Questions on Netiquette
  440.  
  441.     For rtfm.mit.edu instructions, see "1.13 - Where are FAQ lists
  442.     archived?"
  443.     
  444. ------------------------------
  445.  
  446. Subject: 1.12 - What other technical newsgroups should I know about?
  447. Date: Wed, 02 Oct 94 15:34:00 CDT
  448.  
  449.     Caution:  Some of these newsgroups have specialized charters; you'll
  450.     probably get flamed (and deserve it) if you post to an inappropriate
  451.     group.  Most groups have FAQ lists that will tell you what's
  452.     appropriate.  Don't post a request for the FAQ list; instead,
  453.     retrieve it yourself: see "1.13 - Where are FAQ lists archived?"
  454.  
  455.     - misc.forsale.computers.d and misc.forsale.computers.pc-clone are
  456.       where you post notices of equipment, software, or computer books
  457.       that you want to sell.  Please don't post or crosspost those
  458.       notices to comp.os.msdos.programmer.
  459.  
  460.     - comp.os.ms-windows.programmer.* groups (formerly part of
  461.       comp.windows.ms.programmer):  Similar to comp.os.msdos.programmer,
  462.       but focus on programming for the MS-Windows platform.
  463.  
  464.     - comp.sys.ibm.pc.hardware is for more hardware-oriented discussions
  465.       of the machines that run DOS.
  466.  
  467.     - the various comp.lang.* groups for articles and questions on the
  468.       programming languages.  Caution:  some groups welcome discussions
  469.       that are operating-system dependent or vendor specific; others do
  470.       not.  For example, comp.lang.c is definitely _not_ for questions
  471.       about programming DOS or PC system features, even if the programs
  472.       are written in C.  On the other hand, comp.lang.pascal contains
  473.       much discussion that is specific to Turbo Pascal.
  474.  
  475.     - comp.binaries.ibm.pc.wanted: AFTER you have looked in the other
  476.       groups, this is the place to post a request for a particular
  477.       binary program.
  478.  
  479.     - comp.archives.msdos.announce (moderated) explains how to use the
  480.       archive sites, especially Garbo and SimTel, and lists files
  481.       uploaded to them.  Discussions belong in comp.archives.msdos.d,
  482.       which replaced comp.binaries.ibm.pc.archives in December 1992.
  483.  
  484.     - comp.binaries.ibm.pc.d is for discussions about programs posted in
  485.       comp.binaries.ibm.pc, and only those programs.  This is a good
  486.       place to report bugs in the programs, but not to ask where to find
  487.       them (see cbip.wanted, above).  comp.binaries.ibm.pc.d is NOT supposed
  488.       to be a general PC discussion group.
  489.  
  490.     - comp.sources.misc: a moderated group for source code for many
  491.       computer systems.  It tends to get lots of Unix stuff, but you may
  492.       also pick up some DOS-compatible code here.
  493.  
  494.     - alt.sources: an unmoderated group for source code.  Guidelines are
  495.       posted periodically.
  496.  
  497.     - comp.os.msdos.programmer.turbovision is specifically for
  498.       programming in Turbo Vision.
  499.     
  500.     - rec.games.programmer discusses many graphics programming topics.
  501.     
  502.     - Garbo-Ann is a moderated one-way mailing list which is used
  503.       by Garbo MsDos and Windows archive managers to announce new
  504.       additions to Garbo collections. This is for those who cannot
  505.       subscribe to the comp.archives.msdos.announce newsgroup.
  506.  
  507.       To subscribe to Garbo-Ann send a message to
  508.       Majordomo@Garbo.uwasa.fi using the format below.
  509.  
  510.         To: Majordomo@Garbo.uwasa.fi
  511.         Subject: insert any subject here
  512.  
  513.         subscribe garbo-ann youremail@somewhere.net.land
  514.  
  515.     - MSDOS-Ann is a moderated one-way mailing list which is used by
  516.       SimTel, the Coast to Coast Software Repository (tm), to announce
  517.       new additions to the msdos collection. This is for those who cannot
  518.       subscribe to the comp.archives.msdos.announce newsgroup.
  519.  
  520.       To subscribe to Msdos-Ann send a message to
  521.       listserv@SimTel.Coast.NET using the format below.
  522.  
  523.         To: listserv@SimTel.Coast.NET
  524.         Subject: insert any subject here
  525.  
  526.         subscribe msdos-ann
  527.  
  528. ------------------------------
  529.  
  530. Subject: 1.13 - Where are FAQ lists archived?
  531.     
  532.     Very possibly the FAQ list you want is already at your site.  Check
  533.     the newsgroup news.answers; if your site doesn't carry news.answers,
  534.     check comp.answers, rec.answers, etc., according to the top-level
  535.     name in the FAQ list's "home" newsgroup.  Articles are posted to the
  536.     *.answers groups in a way that should make them last until the next
  537.     versions are posted.  If they expire sooner at your site, you might
  538.     want to lobby your sysadmin to treat the moderated *.answers groups
  539.     as a special case and grant them longer expiration times than other
  540.     groups.
  541.  
  542.     To ftp most FAQ lists, connect to rtfm.mit.edu, and change to
  543.     directory /pub/usenet/news.answers.  The name of the file that you
  544.     want is the Archive-name from the top of the article.  For instance,
  545.     if the Archive-name is software-eng/part1 you would retrieve
  546.     /pub/usenet/news.answers/software-eng/part1.
  547.  
  548.     By email (only if you have no ftp access, please), the server is
  549.     mail-server@rtfm.mit.edu .  It accepts "send" commands that omit the
  550.     leading "/pub/" from file names; for example:
  551.  
  552.         send usenet/news.answers/software-eng/part1
  553.  
  554.     For full instructions about the mail server, send it a message
  555.     consisting of these two lines:
  556.  
  557.         help
  558.         index
  559.  
  560.     Not just FAQ lists, but every article listed in the "List of
  561.     Periodic Informational Postings" (LoPIP) can be obtained by ftp or
  562.     email from rtfm.mit.edu.  If you have an old copy of an
  563.     informational article, look for an "Archive-name" at the beginning;
  564.     rtfm.mit.edu stores it under that name in /pub/usenet/news.answers.
  565.     If the article has no Archive-name, check the first name on the
  566.     Newsgroups line and change to that directory under /pub/usenet.
  567.  
  568.     Or send email >>> with valid reply-to address << to brown@ncoast.org
  569.     and you'll receive my canned instructions (about 8K) for retrieving
  570.     FAQ lists for most newsgroups, including a few that aren't archived
  571.     at rtfm.mit.edu.  (This offer may be withdrawn without notice
  572.     depending on system constraints.)
  573.     
  574. ------------------------------
  575.  
  576. Subject: 1.14 - Where can I get the latest copy of this FAQ list? 
  577.  
  578.     You can retrieve the latest version of this list as
  579.  
  580.     <ftp://garbo.uwas.fi/pc/doc-net/dosfv203.zip>
  581.  
  582.     Check the date before downloading, to make sure that the archived
  583.     version is actually newer than what you have.
  584.  
  585.     Like most FAQ lists, this one is archived at rtfm.mit.edu and a
  586.     number of mirror sites.  If you have ftp access, retrieve either of
  587.     these identical files:
  588.  
  589.     <ftp://rtfm.mit.edu/pub/usenet/news.answers/msdos-programmer-faq/faq>
  590.     <ftp://rtfm.mit.edu/pub/usenet/comp.os.msdos.programmer/dos-faq>
  591.  
  592.     If you have no ftp access, see "1.13 - Where are FAQ lists archived?"
  593.     for instructions on retrieving it by email.
  594.  
  595. ------------------------------
  596.  
  597. Subject: 1.15 - Are there any good on-line references for PC
  598.         hardware components?
  599.     
  600.     Good reports of HELPPC21 have been posted.  It is downloadable as
  601.  
  602.     <ftp://oak.oakland.edu/pub/msdos/info/helppc21.zip>
  603.     <ftp://garbo.uwasa.fi/pc/programming/helppc21.zip>
  604.  
  605.     This hypertext system contains much information on ports and other
  606.     hardware, as well as some overlap with Ralf Brown's interrupt list
  607.     (1.17).  It is shareware ($25).
  608.     
  609. ------------------------------
  610.  
  611. Subject: 1.16 - Are there any good on-line references for PC interrupts?
  612.     
  613.     The definitive work is Ralf Brown's interrupt list; see 1.17.
  614.     
  615. ------------------------------
  616.  
  617. Subject: 1.17 - What and where is "Ralf Brown's interrupt list"?
  618. Date: Wed, 05 Sep 94 15:34:00 CDT
  619.  
  620.     This is megabytes of information on documented and (officially)
  621.     undocumented BIOS and DOS interrupts, DOS tables, and interrupts
  622.     hooked by many software packages.
  623.  
  624.     inter42a.zip, inter42b.zip, and inter42c.zip is the actual
  625.     list. inter42d.zip is a collection of utilities and conversion
  626.     programs for the list. The list is downloadable from:
  627.  
  628.         <ftp://oak.oakland.edu/pub/msdos/info>
  629.         <ftp://garbo.uwasa.fi/pc/programming>
  630.  
  631.     These versions were uploaded in early August 1994; updates are
  632.     announced every few months in comp.archives.msdos.announce.
  633.     
  634. ------------------------------
  635.  
  636. Subject: 1.18 - Where can I find lex, yacc, and language grammars?
  637.     
  638.     The FAQ list of the comp.compilers newsgroup answers this for Basic,
  639.     C, Pascal, and other languages.  See "1.13 - Where are FAQ lists
  640.     archived?"
  641.     
  642. ------------------------------
  643.  
  644. Subject: 1.19 - What's the best book to learn programming?
  645.     
  646.     Sorry, this FAQ list cannot settle religious arguments.
  647.  
  648.     Much of the heat over this topic arises because each person believes
  649.     that the book that he or she learned from is the best book.  But
  650.     different people have very different experiences of the same book.
  651.     The only person who can tell you which is the best book for learning
  652.     a given topic is you.
  653.  
  654.     Your best bet is to go to a fairly well-stocked bookstore when you
  655.     have a couple of hours to spare.  Start at one end of the shelf and
  656.     work your way methodically through every book that looks like it
  657.     might cover what you want to learn.  Look at the tables of contents;
  658.     read a page or two from each book.  Then make your decision.  If
  659.     money is a problem, or if you're not sure of your choice, check out
  660.     your top two or three from your library.
  661.  
  662. ------------------------------
  663.  
  664. Subject: 1.20 - How do I use ftp?
  665. Date: Wed, 10 Oct 94 15:34:00 CDT
  666.  
  667.     I was much impressed with {The Whole Internet User's Guide and
  668.     Catalog} by Ed Krol (O'Reilly & Associates, second edition ISBN
  669.     1-56592-063-5).  It gives lots of information on using ftp, email,
  670.     Telnet, Archie, etc.  As a new user of ftp (January 1993), I found
  671.     the information made me productive quickly.  (Disclosure:  Though I
  672.     don't believe it has biased my judgment, you should know that
  673.     O'Reilly sent me a free evaluation copy.)
  674.  
  675.     You may also want to look at the "Anonymous FTP FAQ List". You can
  676.     get it from:
  677.  
  678.         <ftp://rtfm.mit.edu/pub/usenet/news.answers/ftp-list/faq>
  679.         <ftp://garbo.uwasa.fi/pc/doc-net/ftp-list.zip>
  680.         <ftp://oak.oakland.edu/SimTel/msdos/info/ftp-list.zip>
  681.  
  682.     When downloading a file by ftp, make sure you have write access to
  683.     your working directory on your local machine, and that your disk has
  684.     enough space to hold the files.  Also make sure that if it's a ZIP
  685.     file or other binary file type, you set the protocol to binary
  686.     before downloading the file.
  687.  
  688. ------------------------------
  689.  
  690. Subject: 1.21 - Why won't my code work?
  691.     
  692.     First you need to try to determine whether the problem is in your
  693.     use of the programming language or in your use of MS-DOS and your PC
  694.     hardware.  (Your manual should tell you which features are standard
  695.     and which are vendor- or MS-DOS- or PC-specific.  You _have_ read
  696.     your manual carefully, haven't you?)
  697.  
  698.     If the feature that seems to be working wrong is something related
  699.     to your PC hardware or to the internals of MS-DOS, this group is the
  700.     right place to ask.  (Please check this FAQ list first, to make sure
  701.     your question isn't already answered here.)
  702.  
  703.     On the other hand, if your problem is with the programming language,
  704.     the comp.lang hierarchy (including comp.lang.pascal and comp.lang.c)
  705.     is probably a better resource.  Please read the other group's FAQ
  706.     list thoroughly before posting.  (These exist in comp.lang.c,
  707.     comp.lang.c++, comp.lang.modula3, comp.lang.lisp, comp.lang.perl;
  708.     they may exist in other groups as well.)  It's almost never a good
  709.     idea to crosspost between comp.os.msdos.programmer and a language
  710.     group.
  711.  
  712.     Before posting in either place, try to make your program as small as
  713.     possible while still exhibiting the bad behavior.  Sometimes this
  714.     alone is enough to show you where the trouble is.  Also edit your
  715.     description of the problem to be as short as possible.  This makes
  716.     it look more like you tried to solve the problem on your own, and
  717.     makes people more inclined to try to help you.  See also "1.10 -
  718.     What's this "netiquette"?"
  719.  
  720. ------------------------------
  721.  
  722. Subject: Section 2.  Compile and link
  723.  
  724. ------------------------------
  725.  
  726. Subject: 2.01 - What the heck is "DGROUP > 64K"?
  727.  
  728.     This Q explains the problem; the next Q gives some remedies.
  729.  
  730.     DGROUP is a link-time group of data segments, and the compiler
  731.     typically generates code that expects DS to be pointing to DGROUP.
  732.     (Exception:  Borland's huge model has no DGROUP.)
  733.  
  734.     Here's what goes into DGROUP:
  735.  
  736.     - tiny model (all pointers near):  DGROUP holds the entire program.
  737.  
  738.     - small and medium models (data pointers near):  DGROUP holds all
  739.       globals and static variables including string literals, plus the
  740.       stack and the heap.
  741.  
  742.     - large, compact, and huge models in Microsoft (data pointers far):
  743.       DGROUP holds only initialized globals and static variables
  744.       including string literals, plus the stack and the near heap.
  745.  
  746.     - large and compact models in Borland (data pointers far): DGROUP
  747.       holds initialized and uninitialized globals and static variables
  748.       including string literals, but not the stack or heap.
  749.  
  750.     - huge model in Borland (data pointers far): there is no DGROUP, so
  751.       the 64K limit doesn't apply.
  752.  
  753.     In all of the above, which is to say all six models in Microsoft C
  754.     and all but huge in Borland C, DGROUP is limited to 64K including
  755.     string literals (which are treated as static data).  This limitation
  756.     is due to the Intel CPU's segmented architecture.
  757.  
  758.     For more information, see topics like "memory models" and "memory
  759.     management" in the index of your compiler manual.  Also see
  760.     TI738.asc, downloadable as part of
  761.  
  762.         <ftp://oak.oakland.edu/pub/msdos/turbo-c/bchelp10.zip>
  763.         <ftp://garbo.uwasa.fi/pc/turbopas/bchelp10.zip>
  764.  
  765.     for an extended general discussion of memory usage in Borland C
  766.     programs, of which much applies to any C compiler in DOS.
  767.  
  768. ------------------------------
  769.  
  770. Subject: 2.02 - How do I fix "automatic data segment exceeds 64K" or
  771.                "stack plus data exceed 64K"?
  772.  
  773.     These messages are a variation of "DGROUP > 64K".  For causes,
  774.     please see the preceding Q.
  775.  
  776.     If you get this error in tiny model, your program is simply too big
  777.     and you must use a different memory model.  If you get this link
  778.     error in models S, C, M, L, or Microsoft's H, there are some things
  779.     you can do.  (This error can't occur in Borland's huge model.)
  780.  
  781.     If you have one or two big global arrays, simply declare them far.
  782.     The compiler takes this to mean that any references to them will use
  783.     32-bit pointers, so they'll be in separate segments and no longer
  784.     part of DGROUP.
  785.  
  786.     Or you can use the /Gt[number] option with Microsoft or -Ff[=size]
  787.     with Borland C++ 2.0 and up.  This will automatically put variables
  788.     above a certain size into their own segments outside of DGROUP.
  789.  
  790.     Yet another option is to change global arrays to far pointers.  Then
  791.     at the beginning of your program, allocate them from the far heap
  792.     (_fmalloc() in Microsoft, farmalloc() in Borland).
  793.  
  794.     Finally, you can change to huge model (with Borland compilers, not
  795.     Microsoft).  Borland's H model still uses far pointers by default,
  796.     but "sets aside the [64K] limit" and has no DGROUP group, according
  797.     to the BC++ 2.0 Programmer's Guide.  Microsoft's H model does use
  798.     huge data pointers by default but retains DGROUP and its 64K limit,
  799.     so switching to the H model doesn't buy you anything if you have
  800.     DGROUP problems.
  801.  
  802. ------------------------------
  803.  
  804. Subject: 2.03 - Will Borland C code and Microsoft C code link together?
  805.  
  806.     Typically this question is asked by someone who owns compiler A and
  807.     is trying to write code to link with a third-party library that was
  808.     compiled under compiler B.
  809.  
  810.     The answer to the question is, Not in general.  Here are some of the
  811.     reasons:
  812.  
  813.     - "Helper" functions (undocumented functions for stack checking,
  814.       floating-point arithmetic, and operations on longs) differ between
  815.       the two compilers.
  816.  
  817.     - The compilers may embed instructions in the object code that tell
  818.       the linker to look for their own run-time libraries.  You can use
  819.       the linker option that says to ignore such instructions: /n in
  820.       TLINK, /NOD in the Microsoft linker (the one that comes with the C
  821.       compiler, not the one that used to come with DOS).  But getting
  822.       around this problem will very likely just reveal other problems,
  823.       like different helper functions, that have no easy solution.
  824.  
  825.     Those problems will generate link-time errors.  Others may not show
  826.     up until run time:
  827.  
  828.     - Borland's compact, large, and huge models don't assume DS=SS, but
  829.       Microsoft's do.  The -Fs option on the Borland compiler, or one of
  830.       the /A options on Microsoft, should take care of this problem--
  831.       once you know that's what's going on.
  832.  
  833.     - Check conventions for ordering and packing structure members, and
  834.       for alignment of various types on byte, word, paragraph, or other
  835.       boundaries.  Again, you can generally adjust your code to match if
  836.       you know what conventions were used in compiling the "foreign"
  837.       libraries.
  838.  
  839.     - Check the obvious and make sure that your code was compiled under
  840.       the same memory model as the code you're trying to link with.
  841.       (That's necessary, but no guarantee.  Microsoft and Borland don't
  842.       use exactly the same conventions for segments and groups,
  843.       particularly in the larger memory models.)
  844.  
  845.     That said, there are some circumstances where you can link hybrids.
  846.     Your best chance of success comes if you compile in large model with
  847.     the compiler switch that says to reload DS on entry to each
  848.     function, avoid longs and floating point, use only 16-bit pointers,
  849.     suppress stack checking, and specify all libraries used in the link.
  850.  
  851. ------------------------------
  852.  
  853. Subject: 2.04 - Why did my program bomb at run time with "floating point
  854.                formats not linked" or "floating point not loaded"?
  855.  
  856.     These messages look similar but have very different causes.
  857.  
  858.     "floating point not loaded" is Microsoft C's run-time message when
  859.     the code requires a numeric coprocessor but your computer doesn't
  860.     have one installed.  If the program is yours, relink it using the
  861.     xLIBCE or xLIBCA library (where x is the memory model).
  862.  
  863.     "floating point formats not linked" is a Borland run-time error
  864.     (Borland C or C++, Turbo C or C++).  Borland's compilers try to be
  865.     smart and not link in the floating-point (f-p) library unless you
  866.     need it.  Alas, they all get the decision wrong.  One common case is
  867.     where you don't call any f-p functions, but you have %f or other f-p
  868.     formats in scanf() or printf() calls.  The cure is to call an f-p
  869.     function, or at least force one to be present in the link.
  870.  
  871.     To do that, define this function somewhere in a source file but
  872.     don't call it:
  873.  
  874.         static void forcefloat(float *p) {
  875.             float f = *p;
  876.             forcefloat(&f);
  877.         }
  878.  
  879.     It doesn't have to be in the module with the main program, as long
  880.     as it's in a module that will be included in the link.
  881.  
  882.     If you have Borland C++ 3.0, the README file documents a slightly
  883.     less ugly work-around.  Insert these statements in your program:
  884.  
  885.         extern unsigned _floatconvert;
  886.         #pragma extref _floatconvert
  887.  
  888. ------------------------------
  889.  
  890. Subject: 2.05 - How can I change the stack size in Borland's C
  891.                compilers?
  892.  
  893.     In Turbo C, Turbo C++, and Borland C++, you may not find "stack
  894.     size" in the index but the global variable _stklen should be there.
  895.     The manual will instruct you to put a statement like
  896.  
  897.         extern unsigned _stklen = 54321U;
  898.  
  899.     in your code, outside of any function.  You must assign the value
  900.     right in the extern statement; it won't work to assign a value at
  901.     run time.  The linker may give you a duplicate symbol warning, which
  902.     you can ignore.
  903.  
  904. ------------------------------
  905.  
  906. Subject: 2.06 - What's the format of an .OBJ file? *revised*
  907. Date: Wed, 11 Jan 95 15:34:00 CDT
  908.  
  909.     - base .OBJ format:  Intel's document number #121748-001, {8086
  910.       Relocatable Object Module Formats}.  (not verified)
  911.  
  912.     Both Microsoft and Borland have extended the .OBJ format, as has IBM
  913.     for OS/2; and according to the MS-DOS encyclopedia, Microsoft
  914.     doesn't actually use all the listed formats.
  915.  
  916.     - Microsoft-specific .OBJ formats:
  917.  
  918.       * The .OBJ format document in a text file format, is downloadable
  919.       as <ftp://ftp.microsoft.com\softlib\mslfiles\ss0288.exe>
  920.  
  921.       * A 45-page article can be found in the {MS-DOS Encyclopedia},
  922.         ISBN 1-55615-049-0, now out of print.
  923.  
  924.       * "Microsoft Object Module Format (OMF)" Specification, 22 Nov
  925.         1991, was published by the Microsoft Languages Group.  (not
  926.         verified)
  927.  
  928.     - Borland-specific .OBJ formats:  Open Architecture Handbook.  The
  929.       Borland Developer's Technical Guide, 1991, no ISBN.  Chapter 2,
  930.       "Object file contents", (pages 27-50) covers the comment records
  931.       sent to the object file by Borland C++ version 3.0 and other
  932.       Borland compilers.  The comment records mostly contain information
  933.       for the Borland debugger. (not verified)
  934.  
  935.     - A "tutorial on the .OBJ format" comes with the VAL experimental
  936.       linker, downloadable as
  937.  
  938.         <ftp://oak.oakland.edu/pub/msdos/pgmutil/val-link.zip>
  939.         <ftp://garbo.uwasa.fi/pc/assembler/linker.zoo>
  940.  
  941.       Despite such different names, those files have the same contents,
  942.       but their contents are dated 18 Feb 1989.  You'd be better off
  943.       with one of the more recent references listed above.
  944.  
  945. ------------------------------
  946.  
  947. Subject: 2.07 - What's the format of an .EXE header?
  948.  
  949.     See PC Magazine 30 June 1992 (xi:12) pages 349-350 for the old and
  950.     new formats.  For a more detailed layout, look under INT 21 AH=4B in
  951.     Ralf Brown's interrupt list (Q 1.17).  That list includes extensions
  952.     for Borland's TLINK and Borland debugger info.
  953.  
  954.     Among the books that detail formats of executable files are {DOS
  955.     Programmer's Reference: 2d Edition} by Terry Dettman and Jim Kyle,
  956.     ISBN 0-88022-458-4; and {Microsoft MS-DOS Programmer's Reference},
  957.     ISBN 1-55615-329-5.
  958.  
  959. ------------------------------
  960.  
  961. Subject: 2.08 - What's the difference between .COM and .EXE formats?
  962.  
  963.     To oversimplify:  a .COM file is a direct image of core, and an .EXE
  964.     file will undergo some further relocation when it is run (and so it
  965.     begins with a relocation header).  A .COM file is limited to 64K for
  966.     all segments combined, but an .EXE file can have as many segments as
  967.     your linker will handle and be as large as RAM can take.
  968.  
  969.     The actual file extension doesn't matter.  DOS knows that a file
  970.     being loaded is in .EXE format if its first two bytes are MZ or ZM;
  971.     otherwise it is assumed to be in .COM format.  For instance, DR-DOS
  972.     6.0's COMMAND.COM is in .EXE format.
  973.  
  974. ------------------------------
  975.  
  976. Subject: 2.09 - How do I create a .COM file? *new*
  977. Date: Fri, 13 Jan 95 15:34:00 CDT
  978.  
  979.    There are two steps to creating a .COM file. First, your program must
  980.    not have a stack. In C, you must compile your program with the TINY
  981.    memory model. Second, use EXE2BIN or a similiar program to convert
  982.    the .EXE file to a .COM file. To find EXE2BIN see subject: "2.10 -
  983.    Where is EXE2BIN located?"
  984.  
  985. ------------------------------
  986.  
  987. Subject: 2.10 - Where is EXE2BIN located? *new*
  988. Date: Fri, 13 Jan 95 15:34:00 CDT
  989.  
  990.    EXE2BIN was formerly shipped with MS-DOS. If you are still using DOS
  991.    5.0 or earlier you can find EXE2BIN in your DOS directory. Users of
  992.    DOS 6.0 and later you need to get the MS-DOS Supplemental Disks.
  993.    These disks are available via FTP at ftp.microsoft.com.
  994.  
  995.    For MS-DOS 6.0:
  996.    <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\dos6supp.exe>
  997.    For MS-DOS 6.2:
  998.    <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\dos62sp.exe>
  999.    For MS-DOS 6.21:
  1000.    <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\supp621.exe>
  1001.    For MS-DOS 6.22:
  1002.    <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\supp622.exe>
  1003.  
  1004.  
  1005. ------------------------------
  1006.  
  1007. Subject: Section 3.  Keyboard
  1008.  
  1009. ------------------------------
  1010.  
  1011. Subject: 3.01 - How can I read a character without echoing it to the
  1012.            screen, and without waiting for the user to press the
  1013.            Enter key?
  1014.  
  1015.     The C compilers from Microsoft and Borland offer getch() (or
  1016.     getche() to echo the character); Turbo Pascal has ReadKey.
  1017.  
  1018.     In other programming languages, execute INT 21 AH=8; AL is returned
  1019.     with the character from standard input (possibly redirected).  If
  1020.     you don't want to allow redirection, or you want to capture Ctrl-C
  1021.     and other special keys, use INT 16 AH=10; this will return the scan
  1022.     code in AH and ASCII code (if possible) in AL, but  AL=E0 with AH
  1023.     nonzero indicates that one of the grey "extended" keys was pressed.
  1024.     (If your BIOS doesn't support the extended keyboard, use INT 16 AH=0
  1025.     not 10.)
  1026.  
  1027. ------------------------------
  1028.  
  1029. Subject: 3.02 - How can I find out whether a character has been typed,
  1030.            without waiting for one?
  1031.  
  1032.     In Turbo Pascal, use KeyPressed.  Both Microsoft C and Turbo C offer
  1033.     the kbhit() function.  All of these tell you whether a key has been
  1034.     pressed.  If no key has been pressed, they return that information
  1035.     to your program.  If a keystroke is waiting, they tell your program
  1036.     that but leave the key in the input buffer.
  1037.  
  1038.     You can use the BIOS call, INT 16 AH=01 or 11, to check whether an
  1039.     actual keystroke is waiting; or the DOS call, INT 21 AH=0B, to check
  1040.     for a keystroke from stdin (subject to redirection).  See Ralf
  1041.     Brown's interrupt list (Q 1.17).
  1042.  
  1043. ------------------------------
  1044.  
  1045. Subject: 3.03 - How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  1046.  
  1047.     Several utilities are downloadable from /pub/msdos/keyboard at
  1048.     SimTel.  In that directory, cadel.zip contains a TSR (with source
  1049.     code) to disable those keys.  Also, keykill.arc contains two
  1050.     utilities:  keykill.com lets you disable up to three keys of your
  1051.     choice, and deboot.com changes the boot key to leftShift-Alt-Del.
  1052.  
  1053.     C programmers who simply want to make sure that the user can't Ctrl-
  1054.     Break out of their program can use the ANSI-standard signal()
  1055.     function; the Borland compilers also offer ctrlbrk() for handling
  1056.     Ctrl-Break.  However, if your program uses normal DOS input such as
  1057.     getch(), ^C will appear on the screen when the user presses Ctrl-C
  1058.     or Ctrl-Break.  You can avoid the ^C echo for Ctrl-C by using
  1059.     _bios_keybrd() in MSC or bioskey() in BC++; however, Ctrl-Break will
  1060.     still terminate the program.
  1061.  
  1062.     An alternative approach involves programming input at a lower level.
  1063.     You can use INT 21 AH=7, which allows redirection but doesn't echo
  1064.     the ^C (or any other character, for that matter); or use INT 16 AH=0
  1065.     or 10; or hook INT 9 to discard Ctrl-C and Ctrl-Break before the
  1066.     regular BIOS keyboard handler sees them; etc., etc.
  1067.  
  1068.     You should be aware that Ctrl-C and Ctrl-Break are processed quite
  1069.     differently internally.  Ctrl-Break, like all keystrokes, is
  1070.     processed by the BIOS code at INT 9 as soon as the user presses the
  1071.     keys, even if earlier keys are still in the keyboard buffer:  by
  1072.     default the handler at INT 1B is called.  Ctrl-C is not special to
  1073.     the BIOS, nor is it special to DOS functions 6 and 7; it _is_
  1074.     special to DOS functions 1 and 8 when at the head of the keyboard
  1075.     buffer.  You will need to make sure BREAK is OFF to prevent DOS
  1076.     polling the keyboard for Ctrl-C during non-keyboard operations.
  1077.  
  1078.     Some good general references are {Advanced MS-DOS} by Ray Duncan,
  1079.     ISBN 1-55615-157-8; {8088 Assembler Language Programming:  The IBM
  1080.     PC}, ISBN 0-672-22024-5, by Willen & Krantz; and {COMPUTE!'s Mapping
  1081.     the IBM PC}, ISBN 0-942386-92-2.
  1082.  
  1083. ------------------------------
  1084.  
  1085. Subject: 3.04 - How can I disable the print screen function?
  1086.  
  1087.     There are really two print screen functions:  1) print current
  1088.     screen snapshot, triggered by PrintScreen or Shift-PrtSc or Shift-
  1089.     grey*, and 2) turn on continuous screen echo, started and stopped by
  1090.     Ctrl-P or Ctrl-PrtSc.
  1091.  
  1092.     1) Screen snapshot to printer
  1093.  
  1094.     The BIOS uses INT 5 for this.  Fortunately, you don't need to mess
  1095.     with that interrupt handler.  The standard handler, in BIOS versions
  1096.     dated December 1982 or later, uses a byte at 0040:0100 (= 0000:0500)
  1097.     to determine whether a print screen is currently in progress.  If it
  1098.     is, pressing PrintScreen again is ignored.  So to disable the screen
  1099.     snapshot, all you have to do is write a 1 to that byte.  When the
  1100.     user presses PrintScreen, the BIOS will think that a print screen is
  1101.     already in progress and will ignore the user's keypress.  You can re-
  1102.     enable PrintScreen by zeroing the same byte.
  1103.  
  1104.     Here's some simple code:
  1105.  
  1106.         void prtsc_allow(int allow) /* 0=disable, nonzero=enable */ {
  1107.             unsigned char far* flag = (unsigned char far*)0x00400100UL;
  1108.             *flag = (unsigned char)!allow;
  1109.         }
  1110.  
  1111.     2) Continuous echo of screen to printer
  1112.  
  1113.     If ANSI.SYS is loaded, you can easily disable the continuous echo of
  1114.     screen to printer (Ctrl-P or Ctrl-PrtSc).  Just redefine the keys by
  1115.     "printing" strings like these to the screen (BASIC print, C
  1116.     printf(), Pascal Write statements, or ECHO command in batch files),
  1117.     where <27> stands for the Escape character, ASCII 27:
  1118.  
  1119.         <27>[0;114;"Ctrl-PrtSc disabled"p
  1120.         <27>[16;"^P"p
  1121.  
  1122.     If you haven't installed ANSI.SYS, I can't offer an easy way to
  1123.     disable the echo-screen-to-printer function.
  1124.  
  1125.     Actually, you might not need to disable Ctrl-P and Ctrl-PrtSc.  If
  1126.     your only concern is not locking up your machine, when you see the
  1127.     "Abort, Retry, Ignore, Fail" prompt just press Ctrl-P again and then
  1128.     press I.  As an alternative, install one of the many print spoolers
  1129.     that intercept printer-status queries and always return "Printer
  1130.     ready".
  1131.  
  1132. ------------------------------
  1133.  
  1134. Subject: 3.05 - How can my program turn NumLock (CapsLock, ScrollLock) on
  1135.            or off?
  1136.  
  1137.     First, if you just don't want NumLock turned on when you reboot,
  1138.     check your system's setups.  (Use Ctrl-Alt-Enter any time, or press
  1139.     a special key like Del at boot time, or run the setup program
  1140.     supplied with your system.)  Many systems now have an option in
  1141.     setup to turn NumLock off at boot time.
  1142.  
  1143.     You need to twiddle bit 5, 6, or 4 of location 0040:0017.  Here's
  1144.     some code:  lck() turns on a lock state, and unlck() turns it off.
  1145.     (The status lights on some keyboards may not reflect the change.  If
  1146.     yours is one, call INT 16 AH=2, "get shift status", and that may
  1147.     update them.  It will certainly do no harm.)
  1148.  
  1149.         #define NUM_LOCK  (1 << 5)
  1150.         #define CAPS_LOCK (1 << 6)
  1151.         #define SCRL_LOCK (1 << 4)
  1152.         void lck(int shiftype) {
  1153.             char far* kbdstatus = (char far*)0x00400017UL;
  1154.             *kbdstatus |= (char)shiftype;
  1155.         }
  1156.         void unlck(int shiftype) {
  1157.             char far* kbdstatus = (char far*)0x00400017UL;
  1158.             *kbdstatus &= ~(char)shiftype;
  1159.         }
  1160.  
  1161. ------------------------------
  1162.  
  1163. Subject: 3.06 - How can I speed up the keyboard's auto-repeat?
  1164.  
  1165.     The keyboard speed has two components: delay (before a key that you
  1166.     hold down starts repeating) and typematic rate (the speed once the
  1167.     key starts repeating).  Most BIOS versions since 1986 let software
  1168.     change the delay and typematic rate by calling INT 16 AH=3, "set
  1169.     typematic rate and delay"; see Ralf Brown's interrupt list (Q 1.17).
  1170.     If you have DOS 4.0 or later, you can use the MODE CON command that
  1171.     you'll find in your DOS manual.
  1172.  
  1173.     On 83-key keyboards (mostly XTs), the delay and typematic rate can't
  1174.     easily be changed.  According to PC Magazine 15 Jan 1991 (x:1) page
  1175.     409, to adjust the typematic rate you need "a memory-resident
  1176.     program which simply '[watches]' the keyboard to see if you're
  1177.     holding down a key ... and after a certain time [starts] stuffing
  1178.     extra copies of the held-down key into the buffer."  No source code
  1179.     is given in that issue; but the QUICKEYS utility that PC Magazine
  1180.     published in 1986 does this sort of watching (not verified); source
  1181.     and object code are downloadable in
  1182.  
  1183.     <ftp://oak.oakland.edu/pub/msdos/pcmag/vol5n05.zip>
  1184.  
  1185. ------------------------------
  1186.  
  1187. Subject: 3.07 - What is the SysRq key for?
  1188.  
  1189.     There is no standard use for the key.  The BIOS keyboard routines in
  1190.     INT 16 simply ignore it; therefore so do the DOS input routines in
  1191.     INT 21 as well as the keyboard routines in libraries supplied with
  1192.     high-level languages.
  1193.  
  1194.     When you press or release a key, the keyboard triggers hardware line
  1195.     IRQ1, and the CPU calls INT 9.  INT 9 reads the scan code from the
  1196.     keyboard and the shift states from the BIOS data area.
  1197.  
  1198.     What happens next depends on whether your PC's BIOS supports an
  1199.     enhanced keyboard (101 or 102 keys).  If so, INT 9 calls INT 15
  1200.     AH=4F to translate the scan code.  If the translated scan code is 54
  1201.     hex (for the SysRq key) then INT 9 calls INT 15 AH=85 and doesn't
  1202.     put the keystroke into the keyboard buffer.  The default handler of
  1203.     that function does nothing and simply returns.  (If your PC has an
  1204.     older BIOS that doesn't support the extended keyboards, INT 15 AH=4F
  1205.     is not called.  Early ATs have 84-key keyboards, so their BIOS calls
  1206.     INT 15 AH=85 but not 4F.)
  1207.  
  1208.     Thus your program is free to use SysRq for its own purposes, but at
  1209.     the cost of some programming.  You could hook INT 9, but it's
  1210.     probably easier to hook INT 15 AH=85, which is called when SysRq is
  1211.     pressed or released.
  1212.  
  1213. ------------------------------
  1214.  
  1215. Subject: 3.08. How can my program tell what kind of keyboard is on the
  1216.                system?
  1217.  
  1218.     Ralf Brown's Interrupt List (Q 1.17) includes MEMORY.LST, a detailed
  1219.     breakdown by Robin Walker of the contents of the BIOS system block
  1220.     that starts at 0040:0000.  Bit 4 of byte 0040:0096 is "1=enhanced
  1221.     keyboard installed".  C code to test the keyboard type:
  1222.  
  1223.         char far *kbd_stat_byte3 = (char far *)0x00400096UL;
  1224.         if (0x10 & *kbd_stat_byte3)
  1225.             /* 101- or 102-key keyboard is installed */
  1226.  
  1227.     PC Magazine 15 Jan 1991 (x:1) suggests on page 412 that "for some
  1228.     clones [the above test] is not foolproof".  If you use this method
  1229.     in your program you should provide the user some way to override
  1230.     this test, or at least some way to tell your program to assume a non-
  1231.     enhanced keyboard.  The article suggests a different approach to
  1232.     determining the type of keyboard.
  1233.  
  1234. ------------------------------
  1235.  
  1236. Subject: 3.09 - How can I tell if input, output, or stderr has been redirected? 
  1237.  
  1238.     Normally, input and output are associated with the console (i.e.,
  1239.     with the keyboard and the screen, respectively).  If either is not,
  1240.     you know that it has been redirected.  Some source code to check
  1241.     this is available at the usual archive sites.
  1242.  
  1243.     If you program in Turbo Pascal, you'll want this downloadable
  1244.     collection of Turbo Pascal units:
  1245.  
  1246.     <ftp://garbo.uwasa.fi/pc/ts/tspa33*.zip>
  1247.     <ftp://oak.oakland.edu/pub/msdos/turbopas/tspa33*.zip>
  1248.  
  1249.     (where the * is 70, 60, 55, 50, or 40 for Turbo Pascal 7.0, 6.0,
  1250.     5.5, 5.0, or 4.0 respectively.)  Source code is not included.  Also
  1251.     see the downloadable Frequently Asked Questions files by Timo Salmi:
  1252.  
  1253.     <ftp://garbo.uwasa.fi/pc/ts/tsfaqp18.zip>
  1254.     <ftp://oak.oakland.edu/pub/msdos/info/tsfaqp18.zip>
  1255.  
  1256.     If you program in C, use isatty() if your implementation has it.
  1257.     Otherwise,
  1258.  
  1259.     <ftp://oak.oakland.edu/pub/msdos/sysutil/is_con10.zip>
  1260.  
  1261.     is downloadable from SimTel; it includes source code.
  1262.  
  1263.     Good references for the principles are PC Magazine 16 Apr 1991 (x:7)
  1264.     page 374; Ray Duncan's {Advanced MS-DOS}, ISBN 1-55615-157-8, or
  1265.     Ralf Brown's interrupt list (Q 1.17) for INT 21 AX=4400; and Terry
  1266.     Dettman and Jim Kyle's {DOS Programmer's Reference: 2d edition},
  1267.     ISBN 0-88022-458-4, pages 602-603.
  1268.  
  1269. ------------------------------
  1270.  
  1271. Subject: 3.10 - How can I increase the size of the keyboard buffer?
  1272.                *revised*
  1273. Date: Fri, 13 Jan 95 15:34:00 CDT
  1274.  
  1275.  
  1276.     Microsoft has its own keyboard extender availible on the MS-DOS
  1277.     supplmental disks for MS-DOS 6.xx. 
  1278.  
  1279.     For MS-DOS 6.0:
  1280.   <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\dos6supp.exe>
  1281.     For MS-DOS 6.2:
  1282.   <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\dos62sp.exe>
  1283.     For MS-DOS 6.21:
  1284.   <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\supp621.exe>
  1285.     For MS-DOS 6.22:
  1286.   <ftp://ftp.microsoft.com\peropsys\msdos\public\supplmnt\supp622.exe>
  1287.  
  1288.     I tested only one of the many available device drivers that do this,
  1289.     namely BUF160, which extends the keyboard buffer to 160 characters.
  1290.     It performed flawlessly for two years with MS-DOS 5 and Windows 3.1.
  1291.     It's downloadable as
  1292.  
  1293.     <ftp://oak.oakland.edu/pub/msdos/keyboard/buf160_6.zip>
  1294.     <ftp://garbo.uwasa.fi/pc/keyboard/buf160_6.zip>
  1295.  
  1296. ------------------------------
  1297.  
  1298. Subject: 3.11 - How can I stuff characters into the keyboard buffer?
  1299.  
  1300.     If your computer has an enhanced keyboard (see "3.08 - How can my
  1301.     program tell what kind of keyboard is on the system?"), put the scan
  1302.     code in CH and the ASCII character in CL, then execute INT 16 AH=5.
  1303.     The return in AL is 0 for success or 1 for buffer full.
  1304.  
  1305.  
  1306. ------------------------------
  1307.  
  1308. Subject: Section 4.  Disks and files
  1309.  
  1310. ------------------------------
  1311.  
  1312. Subject: 4.01 - What drive was the PC booted from?
  1313.     
  1314.     Under DOS 4.0 or later, use INT 21 AX=3305.  DL is returned with an
  1315.     integer indicating the boot drive (1=A:, etc.).
  1316.  
  1317. ------------------------------
  1318.  
  1319. Subject: 4.02 - How can I boot from drive b:?
  1320.  
  1321.     Downloadable shareware:
  1322.  
  1323.     <ftp://oak.oakland.edu/pub/msdos/diskutil/boot_b.zip>
  1324.     <ftp://garbo.uwasa.fi/pc/bootutil/boot_b.zip>
  1325.  
  1326.     The included documentation says it works by writing a new boot
  1327.     sector on a disk in your a: drive that redirects the boot to your b:
  1328.     drive.  (A similar utility is bboot.zip in the same directory at
  1329.     Garbo only.)
  1330.  
  1331.     If that doesn't work, you can always interchange your a: and b:
  1332.     drives by switching ribbon cables and changing the setup in your
  1333.     BIOS.  From an article posted 27 Jan 1993 on another newsgroup:
  1334.  
  1335.     Take the "ribbon" connector, as you call it, and switch them.  To
  1336.     double check, start at the end of the cable that connects to the
  1337.     motherboard or floppy controller.  Follow the cable until you get to
  1338.     the first connector.  Connect this to the drive you want to be b:.
  1339.     After this, there should be a few lines on the cable that get
  1340.     flipped left to right.  (On most cables, they just cut the lines and
  1341.     physically reverse them.  It should be quite obvious from looking at
  1342.     the cable.)  Anyway, the connector after the pins get flipped right
  1343.     to left is the connector for your a: drive.
  1344.  
  1345. ------------------------------
  1346.  
  1347. Subject: 4.03 - Which real and virtual disk drives are valid? *revised*
  1348. Date: Wed, 11 Jan 95 15:34:00 CDT
  1349.  
  1350.     Use INT 21 AH=29 (parse filename).  Point DS:SI at a null-terminated
  1351.     ASCII string that contains the drive letter and a colon, point ES:DI
  1352.     at a 37-byte dummy FCB buffer, and call INT 21 AX=2900.  On return,
  1353.     AL is FF if the drive is invalid, something else if the drive is
  1354.     valid.  RAM disks and SUBSTed drives are considered valid.
  1355.  
  1356.     You can detect whether the drive is ASSIGNed by using INT 2F
  1357.     AX=0601.  To check whether the drive is SUBSTed, use INT 21 AX=4409;
  1358.     or use INT 21 AH=52 to test for both JOIN and SUBST.  See Ralf
  1359.     Brown's interrupt list (Q 1.17).
  1360.  
  1361.     Unfortunately, the b: drive is considered valid even on a single-
  1362.     diskette system.  You can check that special case by interrogating
  1363.     the BIOS equipment byte at 0040:0010.  Bits 7-6 contain the one less
  1364.     than the number of diskette drives, so if those bits are zero you
  1365.     know that b: is an invalid drive even though function 29 says it's
  1366.     valid.
  1367.  
  1368.     Following is some code originally posted by Doug Dougherty to test
  1369.     valid drives (treating SUBSTed and JOINed drives as valid), with my
  1370.     fix for the b: special case, tested in Borland C++ 4.5 (in the large
  1371.     model):
  1372.  
  1373.         #include <dos.h>
  1374.         #include <stdio.h>
  1375.         void drvlist(void) {
  1376.             char s[3] = "A:", fcb_buff[37];
  1377.             int valid;
  1378.             for (   ;  *s<='Z';  (*s)++) {
  1379.                 _SI = (unsigned) s;
  1380.                 _DI = (unsigned) fcb_buff;
  1381.                 _ES = _DS;
  1382.                 _AX = 0x2900;
  1383.                 geninterrupt(0x21);
  1384.                 valid = _AL != 0xFF;
  1385.                 if (*s == 'B'  &&  valid) {
  1386.                     char far *equipbyte = (char far *)0x00400010UL;
  1387.                     valid = (*equipbyte & (3 << 6)) != 0;
  1388.                 }
  1389.                 printf("Drive '%s' is %sa valid drive.\n",
  1390.                         s, valid ? "" : "not ");
  1391.             }
  1392.         }
  1393.  
  1394.     This code was translated to MSC 7.0 and tested it in small model:
  1395.  
  1396.         #include <dos.h>
  1397.         #include <stdio.h>
  1398.         void drvlist(void) {
  1399.             char s[3] = "A:", fcb_buff[37], *buff=fcb_buff;
  1400.             int valid;
  1401.             for (   ;  *s<='Z';  (*s)++) {
  1402.                 __asm mov si,s      __asm mov di,buff
  1403.                 __asm mov ax,ds     __asm mov es,ax
  1404.                 __asm mov ax,0x2900 __asm int 21h
  1405.                 __asm xor ah,ah     __asm mov valid,ax
  1406.                 valid = (valid != 0xFF);
  1407.                 if (*s == 'B'  &&  valid) {
  1408.                     char far *equipbyte = (char far *)0x00400010UL;
  1409.                     valid = (*equipbyte & (3 << 6)) != 0;
  1410.                 }
  1411.                 printf("Drive '%s' is %sa valid drive.\n",
  1412.                         s, valid ? "" : "not ");
  1413.             }
  1414.         }
  1415.  
  1416. ------------------------------
  1417.  
  1418. Subject: 4.04 - How can I make my single floppy drive both a: and b:?
  1419.  
  1420.     Under any DOS since DOS 2.0, you can put the command
  1421.  
  1422.         assign b=a
  1423.  
  1424.     into your AUTOEXEC.BAT file.  Then, when you type "dir b:" you'll no
  1425.     longer get the annoying prompt to insert diskette B (and the even
  1426.     more annoying prompt to insert A the next time you type "dir a:").
  1427.  
  1428.     You may be wondering why anybody would want to do this.  Suppose you
  1429.     use two different machines, maybe one at home and one at work.  One
  1430.     of them has only a 3.5" diskette drive; the other machine has two
  1431.     drives, and b: is the 3.5" one.  You're bound to type "dir b:" on
  1432.     the first one, and get the nuisance message
  1433.  
  1434.         Insert diskette for drive B: and press any key when ready.
  1435.  
  1436.     But if you assign drive b: to point to a:, you avoid this problem.
  1437.  
  1438.     Caution:  there are a few commands, such as DISKCOPY, that will not
  1439.     work right on ASSIGNed or SUBSTed drives.  See the DOS manual for
  1440.     the full list.  Before typing one of those commands, be sure to turn
  1441.     off the mapping by typing "assign" without arguments.
  1442.  
  1443.     The DOS 5.0 manual says that ASSIGN is obsolete, and recommends the
  1444.     equivalent form of SUBST: "subst b: a:\".  Unfortunately, if this
  1445.     command is executed when a: doesn't hold a diskette, the command
  1446.     fails.  ASSIGN doesn't have this problem, so under DOS 5.0 you
  1447.     should disregard that particular bit of advice in the manual.
  1448.  
  1449. ------------------------------
  1450.  
  1451. Subject: 4.05 - How can I disable access to a drive?
  1452.  
  1453.     Reader Eric DeVolder writes that he has made available a program to
  1454.     do this.  I haven't tried it, but it's downloadable as
  1455.  
  1456.     <ftp://oak.oakland.edu/pub/msdos/diskutil/rmdriv20.zip>
  1457.     <ftp://garbo.uwasa.fi/pc/sysutil/rmdriv20.zip>
  1458.  
  1459. ------------------------------
  1460.  
  1461. Subject: 4.06 - How can a batch file test existence of a directory?
  1462.                *revised*
  1463. Date: Wed, 11 Jan 95 15:34:00 CDT
  1464.  
  1465.     The standard way, which in fact is documented in the DOS manual, is
  1466.  
  1467.         if exist d:\path\nul goto found
  1468.  
  1469.     Unfortunately, this is not entirely reliable.  I found it failed in
  1470.     Pathworks (a/k/a PCSA, DEC's network that connects PCs and VAXes),
  1471.     or on a MARS box that uses an OEM version of MS-DOS 5.0.  Readers
  1472.     have reported that it gave the wrong answer on Novell networks, on
  1473.     DR-DOS, and in a DOS window under OS/2.  By "failed" I mean that it
  1474.     "found" a directory that didn't exist, or failed to find one that
  1475.     did exist, or both.  (I'm told that IBM fixed the OS/2 bug in
  1476.     version 2.11 of OS/2.) As a legacy from earlier versions of DOS it
  1477.     always succeedes if the path is DEV.
  1478.  
  1479.     There appears to be no foolproof way to use pure batch commands to
  1480.     test for existence of a directory.  The real solution is to write a
  1481.     program, which returns a value that your batch program can then test
  1482.     with an "if errorlevel".  Reader Duncan Murdoch kindly posted the
  1483.     following Turbo Pascal version:
  1484.  
  1485.         program existdir;
  1486.             { Confirms the existence of a directory given on the command
  1487.             line.  Returns errorlevel 2 on error, 1 if not found, 0 if
  1488.             found. }
  1489.  
  1490.         uses
  1491.             dos;
  1492.  
  1493.         var
  1494.             s : searchrec;
  1495.  
  1496.         begin
  1497.             if paramcount <> 1 then
  1498.             begin
  1499.                 writeln('Syntax:  EXISTDIR directory');
  1500.                 halt(2);
  1501.             end
  1502.             else
  1503.             begin
  1504.                 findfirst(paramstr(1),Directory,S);
  1505.                 while (Doserror = 0) and ((Directory and S.Attr) = 0) do
  1506.                     findnext(S);
  1507.                 if Doserror <> 0 then
  1508.                 begin
  1509.                     Writeln('Directory not found.');
  1510.                     halt(1);
  1511.                 end
  1512.                 else
  1513.                 begin
  1514.                     Writeln('Directory found.');
  1515.                     halt(0);
  1516.                 end;
  1517.             end;
  1518.         end.
  1519.  
  1520.     Timo Salmi also has a Turbo Pascal version in his Turbo Pascal FAQ,
  1521.     which is downloadable as
  1522.  
  1523.     <ftp://garbo.uwasa.fi/pc/ts/tsfaqp18.zip>
  1524.  
  1525. ------------------------------
  1526.  
  1527. Subject: 4.07 - Why won't my C program open a file with a path?
  1528.  
  1529.     You've probably got something like the following code:
  1530.  
  1531.         char *filename = "c:\foo\bar\mumble.dat";
  1532.         FILE *fptr;
  1533.         . . .
  1534.         fptr = fopen(filename, "r");
  1535.  
  1536.     The problem is that \f is a form feed, \b is a backspace, and \m is
  1537.     m.  Whenever you want a backslash in a string constant in C, you
  1538.     must use two backslashes:
  1539.  
  1540.         char *filename = "c:\\foo\\bar\\mumble.dat";
  1541.  
  1542.     This is a feature of every C compiler, because Dennis Ritchie
  1543.     designed C this way.  It's a problem only on MS-DOS systems, because
  1544.     only DOS (and Atari ST/TT running TOS) uses the backslash in
  1545.     directory paths.  But even in DOS this backslash convention applies
  1546.     _only_ to string constants in your source code.  For file and
  1547.     keyboard input at run time, \ is just a normal character, so users
  1548.     running your program would type in file specs the same way as in DOS
  1549.     commands, with single \ characters.
  1550.  
  1551.     Another possibility is to code all paths in source programs with /
  1552.     rather than \ characters:
  1553.  
  1554.         char *filename = "c:/foo/bar/mumble.dat";
  1555.  
  1556.     Ralf Brown writes, "All versions of the DOS kernel accept either
  1557.     forward or backslashes as directory separators.  I tend to use this
  1558.     form more frequently than backslashes since it is easier to type and
  1559.     read."  This applies to DOS function calls (and therefore to calls
  1560.     to the file library of every programming language), but not to DOS
  1561.     commands.
  1562.  
  1563. ------------------------------
  1564.  
  1565. Subject: 4.08 - How can I redirect printer output to a file?
  1566.  
  1567.     Recommended: PRN2FILE from PC Magazine, downloadable as:
  1568.  
  1569.     <ftp://oak.oakland.edu/pub/msdos/printer/prn2file.zip>
  1570.     <ftp://garbo.uwasa.fi/pc/printer/prn2file.zip>
  1571.  
  1572.     PC Magazine has given copies away as part of its utilities disks, so
  1573.     you may already have a copy.
  1574.  
  1575.     The directories mentioned above have lots of other utilities to
  1576.     redirect printer output.
  1577.  
  1578. ------------------------------
  1579.  
  1580. Subject: 4.09 - How can I redirect the output of a batch file?
  1581.  
  1582.     Assuming the batch file is called batch.bat, to send its output
  1583.     (stdout) to another file, just invoke COMMAND.COM as a secondary
  1584.     command processor:
  1585.  
  1586.         command /c batch parameters_if_any >outfile
  1587.  
  1588.     Timo Salmi's notes on this and other batch tricks are downloadable:
  1589.  
  1590.     <ftp://oak.oakland.edu/pub/msdos/batutil/tsbat44.zip>
  1591.     <ftp://garbo.uwasa.fi/pc/ts/tsbat44.zip>
  1592.  
  1593. ------------------------------
  1594.  
  1595. Subject: 4.10 - How can I redirect stderr?
  1596.  
  1597.     Use freopen(..., stderr) and then execute the desired command via
  1598.     system().  There are downloadable versions of programs to do this.
  1599.     I recommend this file, which includes TP4 source and executable:
  1600.  
  1601.     <ftp://oak.oakland.edu/pub/msdos/sysutil/rdstderr.zip>
  1602.  
  1603.     A C example is downloadable as
  1604.  
  1605.     <ftp://oak.oakland.edu/pub/msdos/c/redirect.c>
  1606.  
  1607.     I compiled it with MSC 7.0, and it works fine with one exception:
  1608.     Contrary to the included comments, redirected output starts writing
  1609.     at the beginning of the output file rather than appending.  That is
  1610.     easily solved by adding "fseek(stderr, 0L, SEEK_END);" after the
  1611.     freopen() call for stderr.
  1612.  
  1613. ------------------------------
  1614.  
  1615. Subject: 4.11 - How can my program open more files than DOS's limit of 20?
  1616.  
  1617.     This is a summary of an article Ralf Brown posted on 8 August 1992,
  1618.     with some additions from a Microsoft tech note and information from
  1619.     Chin Huang.)
  1620.  
  1621.     DOS imposes some limits.  Once you overcome those, which is pretty
  1622.     easy, you may have to take additional measures to overcome the
  1623.     limitations built into your compiler's run-time library.
  1624.  
  1625.     1) Limitations imposed by DOS
  1626.  
  1627.     There are separate limits on files and file handles.  For example,
  1628.     DOS opens three files but five file handles:  CON (stdin, stdout,
  1629.     and stderr), AUX (stdaux), and PRN (stdprn).
  1630.  
  1631.     The limit in FILES= in CONFIG.SYS is a system-wide limit on files
  1632.     opened by all programs (including the three that DOS opens and any
  1633.     opened by TSRs); each process has a limit of 20 handles (including
  1634.     the five that DOS opens).  Example:  CONFIG.SYS has FILES=40.  Then
  1635.     program #1 will be able to open 15 file handles.  Assuming that the
  1636.     program actually does open 15 handles pointing to 15 different
  1637.     files, other programs could still open a total of 22 files (40-3-15
  1638.     = 22), though no one program could open more than 15 file handles.
  1639.  
  1640.     If you're running DOS 3.3 or later, you can increase the per-process
  1641.     limit of 20 file handles by a call to INT 21 AH=67, Set Handle
  1642.     Count.  Your program is still limited by the system-wide limit on
  1643.     open files, so you may also need to increase the FILES= value in
  1644.     your CONFIG.SYS file (and reboot).  The run-time library that you're
  1645.     using may have a fixed-size table of file handles, so you may also
  1646.     need to get source code for the module that contains the table,
  1647.     increase the table size, and recompile it.
  1648.  
  1649.     2) Limitations in Microsoft C run-time library
  1650.  
  1651.     In Microsoft C the run-time library limits you to 20 file handles.
  1652.     To change this, you must be aware of two limits:
  1653.  
  1654.     - file handles used with _open(), _read(), etc.: Edit _NFILE_ in
  1655.       CRT0DAT.ASM.
  1656.  
  1657.     - stream files used with fopen(), fread(), etc.: Edit _NFILE_ in
  1658.       _FILE.C for DOS or FILE.ASM for Windows/QuickWin.  This must not
  1659.       exceed the value of _NFILE_ in CRT0DAT.ASM.
  1660.  
  1661.     (QuickWin uses the constant _WFILE_ in CRT0DAT.ASM and WFILE.ASM for
  1662.     the maximum number of child text windows.)
  1663.  
  1664.     After changing the limits, recompile using CSTARTUP.BAT.  Microsoft
  1665.     recommends that you first read README.TXT in the same directory.
  1666.  
  1667.     3) Limitations in Borland C++ run-time library
  1668.  
  1669.     (Reader Chin Huang provided this information on 12 Sep 1993.)
  1670.  
  1671.     To increase the open file limit for a program you compile with
  1672.     Borland C++ 3.1, edit the file _NFILE.H in the include directory and
  1673.     change the _NFILE_ value.  Compile and link the modules FILES.C and
  1674.     FILES2.C from the lib directory into your program.
  1675.  
  1676. ------------------------------
  1677.  
  1678. Subject: 4.12 - How can I read, create, change, or delete the volume label?
  1679.  
  1680.     In DOS 5.0 (and possibly in 4.0 as well), there are actually two
  1681.     volume labels: the LABEL command reports only the first but changes
  1682.     both of them.
  1683.  
  1684.     - The traditional volume label is an entry with "volume label"
  1685.       attribute in the root directory of the disk.  The DIR, VOL, and
  1686.       LABEL commands report this volume label, and LABEL sets it.
  1687.  
  1688.     - There is a second volume label, which may be different, in the
  1689.       boot record along with the serial number. In DOS 4.0 and later,
  1690.       INT 21 AH=69 gets or sets the boot record's serial number and
  1691.       volume label together; see "4.13 - How can I get the disk serial
  1692.       number?"  DIR and VOL ignore this volume label; the LABEL command
  1693.       doesn't report it but does set it.
  1694.  
  1695.     The rest of this answer assumes that by "volume label" you mean the
  1696.     traditional one, the one that DIR and VOL display.  Though it's a
  1697.     directory entry in the root directory, you can't change it using the
  1698.     newer DOS file-access functions (INT 21 AH=3C, 41, 43); instead, use
  1699.     the old FCB-oriented directory functions.  Specifically, you need to
  1700.     allocate a 64-byte buffer and a 41- byte extended FCB (file control
  1701.     block).  Call INT 21 AH=1A to find out whether there is a volume
  1702.     label.  If there is, AL returns 0 and you can change the label using
  1703.     DOS function 17 or delete it using DOS function 13.  If there's no
  1704.     volume label, function 1A will return FF and you can create a label
  1705.     via function 16.  Important points to notice are that ? wildcards
  1706.     are allowed but * are not; the volume label must be space filled not
  1707.     null terminated.
  1708.  
  1709.     The following MSC 7.0 code worked for me in DOS 5.0; the functions
  1710.     it uses have been around since DOS 2.0.  The function parameter is 0
  1711.     for the current disk, 1 for a:, 2 for b:, etc.  It doesn't matter
  1712.     what your current directory is; these functions always search the
  1713.     root directory for volume labels.  (I didn't try to change the
  1714.     volume label of any networked drives.)
  1715.  
  1716.         // Requires DOS.H, STDIO.H, STRING.H
  1717.         void vollabel(unsigned char drivenum) {
  1718.             static unsigned char extfcb[41], dta[64], status, *newlabel;
  1719.             int chars_got = 0;
  1720.             #define DOS(buff,func) __asm { __asm mov dx,offset buff   \
  1721.                 __asm mov ax,seg buff  __asm push ds  __asm mov ds,ax \
  1722.                 __asm mov ah,func  __asm int 21h  __asm pop ds        \
  1723.                 __asm mov status,al }
  1724.             #define getlabel(buff,prompt) newlabel = buff;  \
  1725.                 memset(newlabel,' ',11);  printf(prompt);   \
  1726.                 scanf("%11[^\n]%n", newlabel, &chars_got);  \
  1727.                 if (chars_got < 11) newlabel[chars_got] = ' ';
  1728.  
  1729.             // Set up the 64-byte transfer area used by function 1A.
  1730.             DOS(dta, 1Ah)
  1731.             // Set up an extended FCB and search for the volume label.
  1732.             memset(extfcb, 0, sizeof extfcb);
  1733.             extfcb[0] = 0xFF;           // denotes extended FCB
  1734.             extfcb[6] = 8;              // volume-label attribute bit
  1735.             extfcb[7] = drivenum;       // 1=A,2=B,...; 0=current drive
  1736.             memset(&extfcb[8], '?', 11);// wildcard *.*
  1737.             DOS(extfcb,11h)
  1738.             if (status == 0) {          // DTA has volume label's FCB
  1739.                 printf("volume label is %11.11s\n", &dta[8]);
  1740.                 getlabel(&dta[0x18],
  1741.                     "new label (\"delete\" to delete): ");
  1742.                 if (chars_got == 0)
  1743.                     printf("label not changed\n");
  1744.                 else if (strncmp(newlabel,"delete  ",11) == 0) {
  1745.                     DOS(dta,13h)
  1746.                     printf(status ? "label failed\n" :
  1747.                                     "label deleted\n");
  1748.                 }
  1749.                 else {                  // user wants to change label
  1750.                     DOS(dta,17h)
  1751.                     printf(status ? "label failed\n" :
  1752.                                     "label changed\n");
  1753.                 }
  1754.             }
  1755.             else {                      // no volume label was found
  1756.                 printf("disk has no volume label.\n");
  1757.                 getlabel(&extfcb[8], "new label (<Enter> for none): ");
  1758.                 if (chars_got > 0) {
  1759.                     DOS(extfcb,16h)
  1760.                     printf(status ? "label failed\n" :
  1761.                                     "label created\n");
  1762.                 }
  1763.             }
  1764.         }        // end function vollabel
  1765.  
  1766. ------------------------------
  1767.  
  1768. Subject: 4.13 - How can I get the disk serial number?
  1769.  
  1770.     If the disk was formattted by DOS 4.0 or later, use INT 21: AX=6900
  1771.     gets the serial number; AX=6901 sets it.  (The disk serial number
  1772.     doesn't exist if the disk was formatted with an earlier version of
  1773.     DOS, or with some third-party formatters.)  See Ralf Brown's
  1774.     interrupt list (Q 1.17), or PC Magazine July 1992 (xi:13) page 496,
  1775.     for details.
  1776.  
  1777.     INT 21 AH=69 also gets and sets the volume label in the boot record,
  1778.     which is not necessarily the same as "the" volume label displayed by
  1779.     the DIR, VOL, and LABEL commands.  For that volume label, see "4.12 -
  1780.     How can I read, create, change, or delete the volume label?"
  1781.  
  1782. ------------------------------
  1783.  
  1784. Subject: 4.14 - What's the format of .OBJ, .EXE., .COM files?
  1785.  
  1786.     Please see "2.06 - What's the format of an .OBJ file?"; "2.07 - What's
  1787.     the format of an .EXE header?"; and "2.08 - What's the difference
  1788.     between .COM and .EXE formats?"
  1789.  
  1790. ------------------------------
  1791.  
  1792. Subject: 4.15 - How can I flush the software disk cache?
  1793.  
  1794.     Please see "7.01 - How can a program reboot my PC?"
  1795.  
  1796.  
  1797. ------------------------------
  1798.  
  1799. Subject: Section 5.  Serial ports (COM ports)
  1800.  
  1801. ------------------------------
  1802.  
  1803. Subject: 5.01 - How do I set my machine up to use COM3 and COM4?
  1804.  
  1805.     Unless your machine is fairly old, it's probably already set up.
  1806.     After installing the board that contains the extra COM port(s),
  1807.     check the I/O addresses in word 0040:0004 or 0040:0006.  (In DEBUG,
  1808.     type "D 40:4 L4" and remember that every word is displayed low byte
  1809.     first, so if you see "03 56" the word is 5603.)  If those addresses
  1810.     are nonzero, your PC is ready to use the ports and you don't need
  1811.     the rest of this answer.
  1812.  
  1813.     If the I/O address words in the 0040 segment are zero after you've
  1814.     installed the I/O board, you need some code to store these values
  1815.     into the BIOS data segment:
  1816.  
  1817.         0040:0004  word  I/O address of COM3
  1818.         0040:0006  word  I/O address of COM4
  1819.         0040:0011  byte (bits 3-1): number of serial ports installed
  1820.  
  1821.     The documentation with your I/O board should tell you the port
  1822.     addresses.  When you know the proper port addresses, you can add
  1823.     code to your program to store them and the number of serial ports
  1824.     into the BIOS data area before you open communications.  Or you can
  1825.     use DEBUG to create a little program to include in your AUTOEXEC.BAT
  1826.     file, using this script:
  1827.  
  1828.         n SET_ADDR.COM      <--- or a different name ending in .COM
  1829.         a 100
  1830.         mov  AX,0040
  1831.         mov  DS,AX
  1832.         mov  wo [0004],aaaa <--- replace aaaa with COM3 address or 0
  1833.         mov  wo [0006],ffff <--- replace ffff with COM4 address or 0
  1834.         and  by [0011],f1
  1835.         or   by [0011],8    <--- use number of serial ports times 2
  1836.         mov  AH,0
  1837.         int  21
  1838.                             <--- this line must be blank
  1839.         rCX
  1840.         1f
  1841.         rBX
  1842.         0
  1843.         w
  1844.         q
  1845.  
  1846. ------------------------------
  1847.  
  1848. Subject: 5.02 - How do I find the I/O address of a COM port?
  1849.  
  1850.     Look in the four words beginning at 0040:0000 for COM1 through COM4.
  1851.     (The DEBUG command "D 40:0 L8" will do this.  Remember that words
  1852.     are stored and displayed low byte first, so a word value of 03F8
  1853.     will be displayed as F8 03.)  If the value is zero, that COM port is
  1854.     not installed (or you've got an old BIOS; see "5.01 - How do I set my
  1855.     machine up to use COM3 and COM4?").  If the value is nonzero, it is
  1856.     the I/O address of the transmit/receive register for the COM port.
  1857.     Each COM port occupies eight consecutive I/O addresses (though many
  1858.     chips use only the first seven).
  1859.  
  1860.     Here's some C code to find the I/O address:
  1861.  
  1862.         unsigned ptSel(unsigned comport) {
  1863.             unsigned io_addr;
  1864.             if (comport >= 1  &&  comport <= 4) {
  1865.                 unsigned far *com_addr = (unsigned far *)0x00400000UL;
  1866.                 io_addr = com_addr[comport-1];
  1867.             }
  1868.             else
  1869.                 io_addr = 0;
  1870.             return io_addr;
  1871.         }
  1872.  
  1873.     You might also want to explore Port Finder, downloadable as
  1874.  
  1875.     <ftp://oak.oakland.edu/pub/msdos/io_util/pf271.zip>
  1876.     <ftp://nic.funet.fi/pub/msdos/utilities/sysutl/pf271.zip>
  1877.  
  1878.     I haven't tried it myself, but a posted article reviewed it very
  1879.     favorably and said it also lets you swap ports around.
  1880.  
  1881. ------------------------------
  1882.  
  1883. Subject: 5.03 - But aren't the COM ports always at I/O addresses 3F8,
  1884.                2F8, 3E8, and 2E8?
  1885.  
  1886.     The first two are usually right (though not always); the last two
  1887.     are different on many machines.
  1888.  
  1889. ------------------------------
  1890.  
  1891. Subject: 5.04. How do I configure a COM port and use it to transmit data?
  1892.  
  1893.     (Revised: 10/09/1994)
  1894.  
  1895.     Do you want actual code, or do you want books that explain what's
  1896.     going on?
  1897.  
  1898.     1) Source code
  1899.  
  1900.     First, check your compiler's run-time library.  Many compilers offer
  1901.     functions similar to Microsoft C's _bios_serialcom() or Borland's
  1902.     bioscom(), which may meet your needs.
  1903.  
  1904.     Second, check for downloadable resources at SimTel and Garbo.  At
  1905.     SimTel, <ftp://oak.oakland.edu/pub/msdos/c/pcl4c34.zip> (March 1993)
  1906.     is described as "Asynchronous communications library for C"; Garbo
  1907.     has a whole <ftp://garbo.uwasa.fi/pc/comm> directory.  Also, an
  1908.     extended example is in Borland's TechFax TI445, downloadable as
  1909.     part of
  1910.  
  1911.     <ftp://oak.oakland.edu/pub/msdos/turbo-c/bchelp10.zip>
  1912.     <ftp://garbo.uwasa.fi/pc/turbopas/bchelp10.zip>
  1913.  
  1914.     Though written by Borland, much of it is applicable to other forms
  1915.     of C, and it should give you ideas for other programming languages.
  1916.  
  1917.     2) Reference books
  1918.  
  1919.     Highly recommended: Joe Campbell's {C Programmer's Guide to Serial
  1920.     Communications}, ISBN 0-672-22584-0.  He gives complete details on
  1921.     how serial ports work, along with complete programs for doing polled
  1922.     or interrupt-driver I/O.  The book is quite thick, and none of it
  1923.     looks like filler.
  1924.  
  1925.     If Campbell's book is overkill for you, you'll find a good short
  1926.     description of serial I/O in {DOS 5: A Developer's Guide}, ISBN
  1927.     1-55851-177-6, by Al Williams.
  1928.  
  1929.     Finally, a reader has recommended {Serial Communications Programming
  1930.     in C/C++} by Mark Goodwin (ISBN 1558281983), with source code in the
  1931.     book and on disk.  Topics include the basics, various methods of
  1932.     serial communications on the PC (with consideration of high-speed
  1933.     modems), ANSI screen interface, file transfer protocols (Xmodem and
  1934.     Ymodem), etc.  There is code in C, and that code is extended into a
  1935.     C++ class for those who use C++.  There are also subroutines in
  1936.     Assembly.
  1937.  
  1938.     3) Downloadable information files
  1939.  
  1940.     A "Serial Port FAQ" is occasionally posted to this newsgroup, and is
  1941.     downloadable as multiple files:
  1942.  
  1943.     <ftp://pfsparc02.phil15.uni-sb.de/pub/E-Technik/afd/*Serial*>
  1944.     <ftp://rtfm.mit.edu/pub/usenet/comp.os.msdos.programmer/
  1945.            The_Serial_Port,_rel._15,_part*>
  1946.  
  1947.     For rtfm.mit.edu instructions, see "1.13 - Where are FAQ lists
  1948.     archived?"
  1949.  
  1950.     (The uni-sb.de archive administrator warns that the ftp address may
  1951.     change, sometime in the future, to etcip1.ee.uni-sb.de.)
  1952.  
  1953.  
  1954. ------------------------------
  1955.  
  1956. Subject: Section 6. Other hardware questions and problems
  1957.  
  1958. ------------------------------
  1959.  
  1960. Subject: 6.01 - Which 80x86 CPU is running my program? *revised*
  1961. Date: Wed, 11 Jan 95 15:34:00 CDT
  1962.  
  1963.     The official Intel CPU identification code in assembly language
  1964.     is available in:
  1965.  
  1966.       <ftp://oak.oakland.edu/SimTel/msdos/sysinfo/icpuid3a.zip>
  1967.  
  1968. ------------------------------
  1969.  
  1970. Subject: 6.02 - How can a C program send control codes to my printer?
  1971.  
  1972.     If you just fprintf(stdprn, ...), C will translate some of your
  1973.     control codes.  The way around this is to reopen the printer in
  1974.     binary mode:
  1975.  
  1976.         prn = fopen("PRN", "wb");
  1977.  
  1978.     You must use a different file handle because stdprn isn't an lvalue.
  1979.     By the way, PRN or LPT1 must not be followed by a colon in DOS 5.0.
  1980.  
  1981.     There's one special case, Ctrl-Z (ASCII 26), the DOS end-of-file
  1982.     character.  If you try to send an ASCII 26 to your printer, DOS
  1983.     simply ignores it.  To get around this, you need to reset the
  1984.     printer from "cooked" to "raw" mode.  Microsoft C users must use INT
  1985.     21 AH=44, "get/set device information".  Turbo C and Borland C++
  1986.     users can use ioctl to accomplish the same thing:
  1987.  
  1988.         ioctl(fileno(prn), 1, ioctl(fileno(prn),0) & 0xFF | 0x20, 0);
  1989.  
  1990.     An alternative approach is simply to write the printer output into a
  1991.     disk file, then copy the file to the printer with the /B switch.
  1992.  
  1993.     A third approach is to bypass DOS functions entirely and use the
  1994.     BIOS printer functions at INT 17.  If you also fprintf(stdprn,...)
  1995.     in the same program, you'll need to use fflush() to synchronize
  1996.     fprintf()'s buffered output with the BIOS's unbuffered.
  1997.  
  1998.     By the way, if you've opened the printer in binary mode from a C
  1999.     program, remember that outgoing \n won't be translated to carriage
  2000.     return/line feed.  Depending on your printer, you may need to send
  2001.     explicit \n\r sequences.
  2002.  
  2003. ------------------------------
  2004.  
  2005. Subject: 6.03 - How can I redirect printer output to a file?
  2006.  
  2007.     Please see "4.08 - How can I redirect printer output to a file?"
  2008.  
  2009. ------------------------------
  2010.  
  2011. Subject: 6.04 - Which video adapter is installed?
  2012.  
  2013.     The technique below should work if your BIOS is not too old.  It
  2014.     uses three functions from INT 10, the BIOS video interrupt.  (If
  2015.     you're using a Borland language, you may not have to do this the
  2016.     hard way.  Look for a function called DetectGraph or something
  2017.     similar.)
  2018.  
  2019.     Set AX=1200, BL=32 and call INT 10.  If AL returns 12, you have a
  2020.     VGA.  If not, set AH=12, BL=10 and call INT 10 again.  If BL returns
  2021.     0,1,2,3, you have an EGA with 64,128,192,256K memory.  If not, set
  2022.     AH=0F and call INT 10 a third time.  If AL is 7, you have an MDA
  2023.     (original monochrome adapter) or Hercules; if not, you have a CGA.
  2024.  
  2025.     This worked when tested with a VGA, but I had no other adapter types
  2026.     to test it with.
  2027.  
  2028. ------------------------------
  2029.  
  2030. Sunject: 6.05 - How do I switch to 43- or 50-line mode?
  2031.  
  2032.     <ftp://oak.oakland.edu/pub/msdos/screen/vidmode.zip>, downloadable
  2033.     from SimTel, contains .COM utilities and .ASM source code.
  2034.  
  2035. ------------------------------
  2036.  
  2037. Sunject: 6.06 - How can I find the Microsoft mouse position and
  2038.                 button status?
  2039.  
  2040.     Use INT 33 AH=3, described in Ralf Brown's interrupt list (Q 1.17).
  2041.  
  2042.     The Windows manual says that the Logitech mouse is compatible with
  2043.     the Microsoft one, so the interrupt will probably work the same.
  2044.  
  2045.     Also, many files are downloadable from
  2046.  
  2047.     <ftp://oak.oakland.edu/pub/msdos/mouse>
  2048.  
  2049. ------------------------------
  2050.  
  2051. Subject: 6.07 - How can I access a specific address in the PC's memory?
  2052.  
  2053.     First check the library that came with your compiler.  Many vendors
  2054.     have some variant of peek and poke functions. For example:
  2055.  
  2056.     - In Turbo Pascal, use the pseudo-arrays Mem, MemW, and MemL.  Be
  2057.       sure you use the correct array for the size of data you want to
  2058.       access: byte, word, or double word.
  2059.  
  2060.     - In Turbo C/Borland C, and in recent versions of Microsoft C, use
  2061.       MK_FP; in older versions of Microsoft C, use FP_OFF and FP_SEG.
  2062.       (Caution:  Turbo C and Turbo C++ also have FP_OFF and FP_SEG
  2063.       macros, but they can't be used to construct a pointer.)  Be sure
  2064.       to pick the right data type: probably "unsigned char far *" if
  2065.       you're planning to access bytes and "unsigned short far *" for
  2066.       words.  (The "far" isn't needed if your memory model uses 32-bit
  2067.       data pointers, but including it does no harm.)
  2068.  
  2069.     By the way, it's not useful to talk about "portable" ways to do
  2070.     this.  Any operation that is tied to a specific memory address is
  2071.     not likely to work on another kind of machine.
  2072.  
  2073. ------------------------------
  2074.  
  2075. Subject: 6.08 - How can I read or write my PC's CMOS memory? 
  2076.  
  2077.     There are a great many public-domain utilities that do this.  These
  2078.     are downloadable from SimTel in directory /pub/msdos/at:
  2079.  
  2080.         cmos14.zip     5965  920817  Saves/restores CMOS to/from file
  2081.         cmoser11.zip  28323  910721  386/286 enhanced CMOS setup program
  2082.         cmosram.zip   76096  920214  Save AT/386/486 CMOS data to file
  2083.             and restore
  2084.         rom2.zip      15692  900131  Save AT and 386 CMOS data to file
  2085.             and restore
  2086.         setup21.zip   18172  880613  Setup program which modifies CMOS
  2087.             RAM
  2088.         viewcmos.zip  11068  900225  Display contents of AT CMOS RAM,
  2089.             w/C source
  2090.  
  2091.     A program to check and display CMOS memory (but not write to it) is
  2092.     downloadable as part of
  2093.  
  2094.     <ftp://garbo.uwasa.fi/pc/ts/tsutle22.zip>
  2095.     <ftp://oak.oakland.edu/pub/msdos/sysutil/tsutle22.zip>
  2096.  
  2097.     Good reports of CMOS299.ZIP, available in the pc.dir directory of
  2098.     cantva.canterbury.ac.nz [132.181.30.3], have been posted.
  2099.  
  2100.     Of the above, my only experience is with CMOSRAM, which seems to
  2101.     work fine.  It contains an excellent (and witty) .DOC file that
  2102.     explains the hardware involved and gives specific recommendations
  2103.     for preventing disaster or recovering from it.  It's $5 shareware.
  2104.  
  2105.     Robert Jourdain's {Programmer's Problem Solver for the IBM PC, XT,
  2106.     and AT} has code for accessing the CMOS RAM, according to an article
  2107.     posted in this newsgroup.
  2108.  
  2109. ------------------------------
  2110.  
  2111. Subject: 6.09 - How can I access memory beyond 640K?
  2112.  
  2113.     PC Magazine 29 June 1993 (xii:12) pages 302-304 carry an article,
  2114.     "How DOS Programs Can Use Over 1MB of RAM".
  2115.  
  2116. ------------------------------
  2117.  
  2118. Subject: 6.10 - How can I use the protected mode?
  2119. Date: Wed, 05 Sep 95 15:34:00 CDT
  2120.  
  2121.     If you are using Borland C++ Version 4.0, you can purchase the
  2122.     Borland PowerPack for DOS Version 1.00. This package includes:
  2123.     Borland C++ 4.02 Service Update, 16-bit DPMI libraries and
  2124.     extenders, 32-bit DPMI libraries and extenders, TurboVision 2.0
  2125.     (16-bit DOS, 16-bit DPMI, 32-bit DPMI), SuperVGA BGI Drivers
  2126.     (16-bit DOS, 16-bit DPMI, 32-bit DPMI).
  2127.  
  2128.     Thomas Pytel has written his own DOS extender for Borland C++
  2129.     4.0.
  2130.  
  2131.     Here is a exert from Pytel's documentation about PMC Version 1.01:
  2132.  
  2133.        "PMC contains a small library of the most commonly used and needed
  2134.     system functions. Some ANSI C compliant functions are provided, but
  2135.     overall, PMC is not ANSI compatible. Malloc functions are available.
  2136.     As are many low level string and memory block functions. PMC also
  2137.     provides some DPMI functions, some non-ANSI file functions, and low
  2138.     level IRQ functions. There are low level functions for fast mode
  2139.     switching using the raw mode switching services of whatever DPMI host
  2140.     it is running under.
  2141.  
  2142.        "I designed the PMC interface and library to serve as a small,
  2143.     tight, kernel for other C code to be built around. My primary use
  2144.     for it will be games, demos, and many other things which do not really
  2145.     use standard C functions. But the low level functions provided in
  2146.     PMC.LIB will find much use in almost any type of program that is done.
  2147.  
  2148.        "PMC allows flat access to low and extended memory. You need not
  2149.     deal with segments or near and far pointers. In fact, BCC32 does
  2150.     not recognize the near or far keywords. Memory is split into two pools,
  2151.     a low memory pool and an extended memory pool. This is transparent to
  2152.     your code though, as the malloc routines check both pools for any
  2153.     memory requests. You can deal explicitly with the low or high memory
  2154.     heaps if you wish. You may need a low memory DMA buffer for example.
  2155.  
  2156.        "The extender used is PMODE 3.0. It is about 9k of code and it
  2157.     is internal to the EXE file which is created. For more information
  2158.     on it, you should read the PMODE documentation. The programs created
  2159.     with PMC will run on any 386+ system which is running as a clean system,
  2160.     under XMS, VCPI, or DPMI. This covers all memory managers and Windows
  2161.     and OS/2. In addition, the PMODE extender is very fast. I should know,
  2162.     I wrote for that purpose."
  2163.  
  2164.     PMC is freeware and includes the source code which is in C
  2165.     and assembly language. PMC Version 1.01 can be found in
  2166.  
  2167.     <ftp://ftp.eng.ufl.edu/pub/msdos/demos/programming/source/pmc101.zip>
  2168.  
  2169.     Adam Seychell has written a DOS extender for ASM programmers. His
  2170.     shareware library DOS32 Version 2.4 can be found in
  2171.  
  2172.     <ftp://ftp.eng.ufl.edu/pub/msdos/demos/programming/source/dos32v24.zip>
  2173.  
  2174. ------------------------------
  2175.  
  2176. Subject: Section 7. Other software questions and problems
  2177.  
  2178. ------------------------------
  2179.  
  2180. Subject: 7.01 - How can a program reboot my PC?
  2181.  
  2182.     You can generate a "cold" boot or a "warm" boot.  A cold boot is the
  2183.     same as turning the power off and on; a warm boot is the same as
  2184.     Ctrl-Alt-Del and skips the power-on self 'test.
  2185.  
  2186.     For a warm boot, store the hex value 1234 in the word at 0040:0072.
  2187.     For a cold boot, store 0 in that word.  Then, if you want to live
  2188.     dangerously, jump to address FFFF:0000.  Here's C code to do it:
  2189.  
  2190.         /* WARNING:  data loss possible */
  2191.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  2192.             void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  2193.             unsigned far* type = (unsigned far*)0x00400072UL;
  2194.             *type = (want_warm ? 0x1234 : 0);
  2195.             (*boot)( );
  2196.         }
  2197.  
  2198.     What's wrong with that method?  It will boot right away, without
  2199.     closing files, flushing disk caches, etc.  If you boot without
  2200.     flushing a write-behind disk cache (if one is running), you could
  2201.     lose data or trash the file allocation table in your hard drive.
  2202.  
  2203.     There are two methods of signaling the cache to flush its buffers:
  2204.     (1) simulate a keyboard Ctrl-Alt-Del in the keystroke translation
  2205.     function of the BIOS (INT 15 AH=4F; but see notes below), and (2)
  2206.     issue a disk reset (DOS function 0D).  Most disk-cache programs hook
  2207.     one or both of those interrupts, so if you use both methods you'll
  2208.     probably be safe.
  2209.  
  2210.     When user code simulates a Ctrl-Alt-Del, one or more of the programs
  2211.     that have hooked INT 15 AH=4F can ask that the key be ignored by
  2212.     clearing the carry flag.  For example, HyperDisk does this when it
  2213.     has started but not finished a cache flush.  So if the carry flag
  2214.     comes back cleared, the boot code has to wait a couple of clock
  2215.     ticks and then try again.  (None of this matters on older machines
  2216.     whose BIOS can't support 101- or 102-key keyboards; see the
  2217.     discussion of INT 21 AH=4F in "307. What is the SysRq key for?")
  2218.  
  2219.     C code that tries to signal the disk cache (if any) to flush is
  2220.     given below.  Turbo Pascal code by Timo Salmi that does more or less
  2221.     the same job may be found at question 49 (as of this writing) in the
  2222.     Turbo Pascal FAQ in comp.lang.pascal, and is downloadable as file
  2223.     FAQPAS2.TXT, which is part of
  2224.  
  2225.     <ftp://garbo.uwasa.fi/pc/ts/tsfaqp18.zip>
  2226.     <ftp://oak.oakland.edu/pub/msdos/info/tsfaqp18.zip>
  2227.  
  2228.     Here's C code that reboots after trying to signal the disk cache:
  2229.  
  2230.         #include <dos.h>
  2231.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  2232.             union REGS reg;
  2233.             void    (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  2234.             unsigned far* boottype    =     (unsigned far*)0x00400072UL;
  2235.             char     far* shiftstate  =         (char far*)0x00400017UL;
  2236.             unsigned      ticks;
  2237.             int           time_to_waste;
  2238.             /* Simulate reception of Ctrl-Alt-Del: */
  2239.             for (;;) {
  2240.                 *shiftstate |= 0x0C;    /* turn on Ctrl & Alt */
  2241.                 reg.h.ah = 0x4F;        /* see notes below */
  2242.                 reg.h.al = 0x53;        /* 0x53 = Del's scan code */
  2243.                 reg.x.cflag = 1;        /* sentinel for ignoring key */
  2244.                 int86(0x15, ®, ®);
  2245.                 /* If carry flag is still set, we've finished. */
  2246.                 if (reg.x.cflag)
  2247.                     break;
  2248.                 /* Else waste some time before trying again: */
  2249.                 reg.h.ah = 0;
  2250.                 int86(0x1A, ®, ®);/* system time into CX:DX */
  2251.                 ticks = reg.x.dx;
  2252.                 for (time_to_waste = 3;  time_to_waste > 0;  ) {
  2253.                     reg.h.ah = 0;
  2254.                     int86(0x1A, ®, ®);
  2255.                     if (ticks != reg.x.dx)
  2256.                         ticks = reg.x.dx , --time_to_waste;
  2257.                 }
  2258.             }
  2259.             /* Issue a DOS disk reset request: */
  2260.             reg.h.ah = 0x0D;
  2261.             int86(0x21, ®, ®);
  2262.             /* Set boot type and boot: */
  2263.             *boottype = (want_warm ? 0x1234 : 0);
  2264.             (*boot)( );
  2265.         }
  2266.  
  2267.     Reader Timo Salmi reported (26 July 1993) that the INT 15 AH=4F call
  2268.     may not work on older PCs (below AT, XT2, XT286), according to Ralf
  2269.     Brown's interrupt list (Q 1.17).
  2270.  
  2271.     Reader Roger Fulton reported (1 July 1993) that INT 15 AH=4F hangs
  2272.     even a modern PC "ONLY when ANSI.SYS [is] loaded high using
  2273.     EMM386.EXE.  (Other things loaded high with EMM386.EXE were OK;
  2274.     ANSI.SYS loaded high with QEMM386.SYS was OK; ANSI.SYS loaded low
  2275.     with EMM386.EXE installed was OK.)"  His solution was to use only
  2276.     the disk reset, INT 21 AH=0D, which does flush SMARTDRV, then wait
  2277.     five seconds in hopes that any other disk-caching software would
  2278.     have time to flush its queue.
  2279.  
  2280.     Reader Per Bergland reported (10 Sep 1993) that the jump to
  2281.     FFFF:0000 will not work in Windows or other protected-mode programs.
  2282.     (For example, when the above reboot code ran in a DOS session under
  2283.     Windows, a box with "waiting for system shutdown" appeared.  The PC
  2284.     hung and had to be reset by cycling power.)  His solution, which
  2285.     does a cold boot not a warm boot, is to pulse pin 0 of the 8042
  2286.     keyboard controller, which is connected to the CPU's "reset" line.
  2287.     He has tested the following code on various Compaqs, and expects it
  2288.     will work for any AT-class machine; he cautions that you must first
  2289.     flush the disk cache as indicated above.
  2290.  
  2291.             cli
  2292.         @@WaitOutReady:   ; Busy-wait until 8042 ready for new command
  2293.             in al,64h         ; read 8042 status byte
  2294.             test al,00000010b ; this bit indicates input buffer full
  2295.             jnz @@WaitOutReady
  2296.             mov al,0FEh       ; Pulse "reset" = 8042 pin 0
  2297.             out 64h,al
  2298.             ; The PC will reboot now
  2299.  
  2300. ------------------------------
  2301.  
  2302. Subject: 7.02 - How can I time events with finer resolution than the
  2303.            system clock's 55 ms (about 18 ticks a second)? 
  2304.  
  2305.     The following files, among others, are downloadable from SimTel:
  2306.  
  2307.         /pub/msdos/at :
  2308.         atim.zip       4783  881126  Precision program timing for AT
  2309.  
  2310.         /pub/msdos/c :
  2311.         millisec.zip  37734  911205  MSC/asm src for millisecond timing
  2312.         mschrt3.zip   53708  910605  High-res timer toolbox for MSC 5.1
  2313.         msec_12.zip    8484  920320  High-def timer v1.2 (C,ASM)
  2314.         ztimer11.zip  77625  920428  Microsecond timer for C, C++, ASM
  2315.             (also at Garbo as /pc/c/ztimer11.zip)
  2316.  
  2317.         /pub/msdos/turbo_c :
  2318.         tchrt3.zip    53436  910606  High-res timer for Turbo C 2.0
  2319.         tctimer.zip   15609  891030  High-res timing for Turbo C
  2320.             (same as /pc/c/tctimer.zoo at Garbo; both are version 1.0)
  2321.  
  2322.     For Turbo Pascal users, source and object code are downloadable in
  2323.  
  2324.     <ftp://oak.oakland.edu/pub/msdos/turbopas/bonus507.zip>
  2325.     <ftp://garbo.uwasa.fi/pc/turbopas/bonus507.zip>
  2326.  
  2327.     Also see "Q: How is millisecond timing done?" in FAQPAS.TXT,
  2328.     downloadable as part of
  2329.  
  2330.     <ftp://garbo.uwasa.fi/pc/ts/tsfaqp18.zip>
  2331.     <ftp://oak.oakland.edu/pub/msdos/info/tsfaqp18.zip>
  2332.  
  2333. ------------------------------
  2334.  
  2335. Subject: 7.03 - How can I find the error level of the previous program?
  2336.  
  2337.     First, which previous program are you talking about?  If your
  2338.     current program ran another one, when the child program ends its
  2339.     error level is available to the program that spawned it.  Most high-
  2340.     level languages provide a way to do this; for instance, in Turbo
  2341.     Pascal it's Lo(DosExitCode) and the high byte gives the way in which
  2342.     the child terminated.  In Microsoft C, the exit code of a
  2343.     synchronous child process is the return value of the spawn-type
  2344.     function that creates the process.
  2345.  
  2346.     If your language doesn't have a function to return the error code of
  2347.     a child process, you can use INT 21 AH=4D (get return code).  By the
  2348.     way, this will tell you the child's exit code and the manner of its
  2349.     ending (normal, Ctrl-C, critical error, or TSR).
  2350.  
  2351.     It's much trickier if the current program wants to get the error
  2352.     level of the program that ran and finished before this one started.
  2353.     G.A.Theall has published source and compiled code to do this; the
  2354.     code is downloadable as
  2355.  
  2356.     <ftp://oak.oakland.edu/pub/msdos/batutil/errlvl13.zip>
  2357.  
  2358.     (The code uses undocumented features in DOS 3.3 through 5.0.  Theall
  2359.     says in the .DOC file that the values returned under 4DOS or other
  2360.     replacements won't be right.)
  2361.  
  2362. ------------------------------
  2363.  
  2364. Subject: 7.04 - How can a program set DOS environment variables?
  2365.  
  2366.     Program functions that read or write "the environment" typically
  2367.     access only the program's copy of it.  What this Q really wants to
  2368.     do is to modify the active environment, the one that is affected by
  2369.     SET commands in batch files or at the DOS prompt.  You need to do
  2370.     some programming to find the active environment, and that depends on
  2371.     the version of DOS.
  2372.  
  2373.     A fairly well-written article in PC Magazine 28 Nov 1989 (viii:20),
  2374.     pages 309-314, explains how to find the active environment, and
  2375.     includes Pascal source code.  The article hints at how to change the
  2376.     environment, and suggests creating paths longer than 128 characters
  2377.     as one application.
  2378.  
  2379.     Now as for downloadable source code, there are many possibilities.
  2380.     I looked at some of these, and liked
  2381.  
  2382.     <ftp://oak.oakland.edu/pub/msdos/envutil/rbsetnv1.zip>
  2383.     <ftp://garbo.uwasa.fi/pc/envutil/rbsetnv1.zip>
  2384.  
  2385.     the best.  It includes some utilities to manipulate the environment,
  2386.     with source code in C.  A newer program is
  2387.  
  2388.     <ftp://oak.oakland.edu/pub/msdos/batutil/strings2.zip>
  2389.     <ftp://garbo.uwasa.fi/pc/pcmag/vol11n22.zip>
  2390.  
  2391.     which is the code from PC Magazine 22 Dec 1992 (xi:22).
  2392.  
  2393.     You can also use a call to INT 2E, Pass Command to Interpreter for
  2394.     Execution; see Ralf Brown's interrupt list (Q 1.17) for details and
  2395.     cautions.
  2396.  
  2397. ------------------------------
  2398.  
  2399. Subject: 7.05 - How can I change the switch character to - from /?
  2400.  
  2401.     Under DOS 5.0 and above, you can't--not completely, anyway.  INT 21
  2402.     AX=3700, get switch character, always returns a '/' (hex 2F).  But
  2403.     the DOS commands don't even call that function: they simply hard
  2404.     code '/' as the switch character.
  2405.  
  2406.     Some history:  DOS used to let you change the switch character by
  2407.     using SWITCHAR= in CONFIG.SYS or by calling DOS function 3701.  DOS
  2408.     commands and other programs called DOS function 3700 to find out the
  2409.     switch character.  If you changed the switch character to '-' (the
  2410.     usual choice), you could then type "dir c:/c700 -p" rather than "dir
  2411.     c:\c700 /p".  Under DOS 4.0, the DOS commands ignored the switch
  2412.     character but functions 3700 and 3701 still worked and could be used
  2413.     by other programs.  Under DOS 5.0, even those functions no longer
  2414.     work, though all DOS functions still accept '/' or '\' in file
  2415.     specs.
  2416.  
  2417.     You can reactivate the functions to get and set switchar by using
  2418.     programs like SLASH.ZIP or the sample TSR called SWITCHAR in
  2419.     amisl091.zip (see "7.06 - How can I write a TSR (terminate-stay-
  2420.     resident utility)?").  DOS commands will still use the slash, but
  2421.     non-DOS programs that call DOS function 3700 will use your desired
  2422.     switch character.  (DOS replacements like 4DOS may honor the switch
  2423.     character for internal commands.)
  2424.  
  2425.     Some readers may wonder why this is even an issue.  Making '-' the
  2426.     switch character frees up the front slash to separate names in the
  2427.     path part of a file spec.  This is easier for the ten-fingered to
  2428.     type, and it's one less difference to remember for commuters between
  2429.     DOS and Unix.  The switch character is the only issue, since all the
  2430.     INT 21 functions accept '/' or '\' to separate directory names.
  2431.  
  2432. ------------------------------
  2433.  
  2434. Subject: 7.06 - How can I write a TSR (terminate-stay-resident utility)?
  2435.  
  2436.     There are books, and there's code to download.
  2437.  
  2438.     First, the books:
  2439.  
  2440.     - Ray Duncan's {Advanced MS-DOS}, ISBN 1-55615-157-8, gives a brief
  2441.       checklist intended for experienced programmers.  The ISBN is for
  2442.       the second edition, through DOS 4; but check to see whether the
  2443.       DOS 6 version is available yet.
  2444.  
  2445.     - {DOS 5:  A Developer's Guide} by Al Williams, ISBN 1-55851-177-6,
  2446.       goes into a little more detail, 90 pages worth!
  2447.  
  2448.     - Pascal programmers might look at {The Ultimate DOS Programmer's
  2449.       Manual} by John Mueller and Wallace Wang, ISBN 0-8306-3534-3, for
  2450.       an extended example in mixed Pascal and assembler.
  2451.  
  2452.     - For a pure assembler treatment, check Steven Holzner's {Advanced
  2453.       Assembly Language}, ISBN 0-13-663014-6.  He has a book with the
  2454.       same title out from Brady Press, but it's about half as long as
  2455.       this one.
  2456.  
  2457.     Next, the code.  Some of it is companion code to published articles,
  2458.     which are also listed below:
  2459.  
  2460.     - The Alternate Multiplex Interrupt Specification, downloadable as
  2461.  
  2462.     <ftp://oak.oakland.edu/pub/msdos/info/altmpx35.zip>
  2463.     <ftp://garbo.uwasa.fi/pc/programming/altmpx35.zip>
  2464.  
  2465.     - Ralf Brown's assembly-language implementation of the spec, with
  2466.       utilities in C, is downloadable as
  2467.  
  2468.     <ftp://oak.oakland.edu/pub/msdos/asmutil/amisl091.zip>
  2469.     <ftp://garbo.uwasa.fi/pc/c/amisl091.zip>
  2470.  
  2471.     - Douglas Boling's MASM template for a TSR is downloadable as
  2472.  
  2473.     <ftp://oak.oakland.edu/pub/msdos/asmutl/template.zip>
  2474.  
  2475.     - A posted article mentions Boling's "Strategies and Techniques for
  2476.       Writing State-of-the-Art TSRs that Exploit MS-DOS 5", Microsoft
  2477.       Systems Journal, Jan-Feb 1992, Volume 7, Number 1, pages 41-59,
  2478.       with examples downloadable in
  2479.  
  2480.     <ftp://oak.oakland.edu/pub/msdos/msjournal/msjv7-1.zip>
  2481.  
  2482.     - code for Al Stevens's "Writing Terminate-and-Stay-Resident
  2483.       Programs", Computer Language, February 1988, pages 37-48 and March
  2484.       1988, pages 67-76 is downloadable as
  2485.  
  2486.     <ftp://oak.oakland.edu/pub/msdos/c/tsrc.zip>
  2487.  
  2488.     - software examples to accompany Kaare Christian's "Using Microsoft
  2489.       C Version 5.1 to Write Terminate-and-Stay-Resident Programs",
  2490.       Microsoft Systems Journal, September 1988, Volume 3, Number 5,
  2491.       pages 47-57 are downloadable as
  2492.  
  2493.     <ftp://oak.oakland.edu/pub/msdos/msjournal/msjv3-5.zip>
  2494.  
  2495.     Finally, there are commercial products, of which TesSeRact (for C-
  2496.     language TSRs) is one of the best known.
  2497.  
  2498. ------------------------------
  2499.  
  2500. Subject: 7.07 - Why does my interrupt function behave strangely?
  2501.                *revised*
  2502. Date: Wed, 11 Jan 95 15:34:00 CDT
  2503.  
  2504.     Interrupt service routines can be tricky, because you have to do
  2505.     some things differently from "normal" programs.  If you make a
  2506.     mistake, debugging is a pain because the symptoms may not point at
  2507.     what's wrong.  Your machine may lock up or behave erratically, or
  2508.     just about anything else can happen.  Here are some things to look
  2509.     for.  (See "7.06 - How can I write a TSR (terminate-stay-resident
  2510.     utility)?" for general techniques that may prevent a problem.)
  2511.  
  2512.     First, did you fail to set up the registers at the start of your
  2513.     routine?  When your routine begins executing, you can count on
  2514.     having CS point to your code segment and SS:SP point to some valid
  2515.     stack (of unknown length), and that's it.  In particular, an
  2516.     interrupt service routine must set DS to DGROUP before accessing any
  2517.     data in its data segments.  (If you're writing in a high-level
  2518.     language, the compiler may generate this code for you automatically;
  2519.     check your compiler manual.  For instance, in Borland and Microsoft
  2520.     C, give your function the "interrupt" attribute.)
  2521.  
  2522.     Did you remember to turn off stack checking when compiling your
  2523.     interrupt server and any functions it calls?  The stack during the
  2524.     interrupt is not where the stack-checking code expects it to be.
  2525.     (Caution:  Some third-party libraries have stack checking compiled
  2526.     in, so you can't call them from your interrupt service routine.)
  2527.  
  2528.     Next, are you calling any DOS functions (INT 21, 25, or 26) in your
  2529.     routine?  DOS is not re-entrant.  This means that if your interrupt
  2530.     happens to be triggered while the CPU is executing a DOS function,
  2531.     calling another DOS function will wreak havoc.  (Some DOS functions
  2532.     are fully re-entrant, as noted in Ralf Brown's interrupt list (Q
  2533.     1.17).  Also, your program can test, in a way too complicated to
  2534.     present here, when it's safe to call non-re-entrant DOS functions.
  2535.     See INT 28, INT 21 AH=34, and INT 21 AX=5D06 or 5D0B; and consult
  2536.     {Undocumented DOS} by Andrew Schulman.  Your program must read both
  2537.     the "InDOS flag" and the "critical error flag".)
  2538.  
  2539.     Is a function in your language library causing trouble?  Does it
  2540.     depend on some initializations done at program startup that is no
  2541.     longer available when the interrupt executes?  Does it call DOS (see
  2542.     preceding paragraph)?  For example, in both Borland and Microsoft C
  2543.     the memory-allocation functions (malloc(), etc..) call DOS functions
  2544.     and also depend on setups that they can't get at from inside an
  2545.     interrupt; so do the standard I/O functions like scanf() and
  2546.     printf().  Many other library functions have the same problem, so
  2547.     you can't use them inside an interrupt function without special
  2548.     precautions.
  2549.  
  2550.     Is your routine simply taking too long?  This can be a problem if
  2551.     you're hooking on to the timer interrupt, INT 1C or INT 8.  That
  2552.     interrupt expects to be called about every 55 ms, which is 18.2
  2553.     times a second.  Therefore your routine, plus any others hooked to
  2554.     the same interrupts, must execute in less than 55 ms.  If they use
  2555.     even a substantial fraction of that time, you'll see significant
  2556.     slowdowns of your foreground program.  A good discussion is
  2557.     downloadable as
  2558.  
  2559.     <ftp://oak.oakland.edu/pub/msdos/info/intshare.zip>
  2560.  
  2561.     Did you forget to restore all registers at the end of your routine?
  2562.     Reader, Morten Welinder, notes that programmers of interrupt
  2563.     procedures in Borland/Turbo Pascal 7.0 should be aware that the
  2564.     high words or the 32-bit registers are not saved automatically and
  2565.     that the run-time library may trash them if, e.g., you use longint
  2566.     operations.  The easy way around this is to do "Test8086 := 0;"
  2567.     before installing the interrupt handler.
  2568.  
  2569.     Did you chain improperly to the original interrupt?  You need to
  2570.     restore the stack to the way it was upon entry to your routine, then
  2571.     do a far jump (not call) to the original interrupt service routine.
  2572.     (The process is a little different in high-level languages.)
  2573.  
  2574. ------------------------------
  2575.  
  2576. Subject: 7.08 - How can I write a device driver?
  2577.  
  2578.     Many books answer this in detail.  Among them are {Advanced MS-DOS}
  2579.     and {DOS 5: A Developer's Guide}, cited in the preceding Q.  Michael
  2580.     Tischer's {PC System Programming}, ISBN 1-55755-036-0, has an
  2581.     extensive treatment, as does Dettman and Kyle's {DOS Programmer's
  2582.     Reference: 2d Edition}, ISBN 0-88022-458-4.  For a really in-depth
  2583.     treatment, look for a specialized book like Robert Lai's {Writing MS-
  2584.     DOS Device Drivers}, ISBN 0-201-13185-4.
  2585.  
  2586. ------------------------------
  2587.  
  2588. Subject: 7.09 - What can I use to manage versions of software? 
  2589.  
  2590.     A port of the Unix RCS utility is downloadable as
  2591.  
  2592.         /pub/msdos/gnuish/rcs55ax.zip (EXE and docs) from SimTel
  2593.         /pub/msdos/gnuish/rcs55as.zip (source) from SimTel
  2594.         /pc/unix/alrcs5ex.zip (EXE and docs ?) from Garbo.
  2595.  
  2596.     This version of RCS is no longer limited to one-character extensions
  2597.     on filenames (for example, .CPP and .BAS are now OK).
  2598.  
  2599.     An RCS56 is available at a number of archive sites, but it appears
  2600.     to be unauthorized.  In response to a query, Keith Petersen, SimTel
  2601.     administrator, said that RCS56 was removed from SimTel at the
  2602.     author's request because it did not contain source code and thus was
  2603.     in violation of the GNU copyleft.
  2604.  
  2605.     As for commercial software, I posted a question asking for readers'
  2606.     experiences in July 1993 and seven readers responded.  PVCS from
  2607.     Intersolv (formerly Polymake) got five positive reviews, though
  2608.     several readers commented that it's expensive; RCS from MKS got one
  2609.     positive and one negative review; Burton TLIB got one negative
  2610.     review; DRTS from ILSI got one positive review.
  2611.  
  2612. ------------------------------
  2613.  
  2614. Subject: 7.10 - What's this "null pointer assignment" after my C program
  2615.                executes? 
  2616.  
  2617.     Somewhere in your program, you assigned a value _through_ a pointer
  2618.     without first assigning a value _to_ the pointer.  (This might have
  2619.     been something like a strcpy() or memcpy() with a pointer as its
  2620.     first argument, not necessarily an actual assignment statement.)
  2621.     Your program may look like it ran correctly, but if you get this
  2622.     message you can be certain that there's a bug somewhere.
  2623.  
  2624.     Microsoft and Borland C, as part of their exit code (after a call to
  2625.     exit() or a return from your main function), check whether the
  2626.     location 0000 in your data segment contains a different value from
  2627.     what you started with.  If so, they infer that you must have used an
  2628.     uninitialized pointer.  This implies that the message will appear at
  2629.     the end of execution of your program regardless of where the error
  2630.     actually occurred.
  2631.  
  2632.     To track down the problem, you can put exit() calls at various spots
  2633.     in the program and narrow down where the uninitialized pointer is
  2634.     being used by seeing which added exit() makes the null-pointer
  2635.     message disappear.  Or, if your program was compiled with small or
  2636.     medium models, which use 16-bit data pointers, tell the debugger to
  2637.     set a watch at location 0000 in your data segment.  (If data
  2638.     pointers are 32 bits, as in the compact and large models, a null
  2639.     pointer will overwrite the interrupt vectors at 0000:0000 and
  2640.     probably lock up your machine.)
  2641.  
  2642.     Under MSC/C++ 7.0, you can declare the undocumented library function
  2643.  
  2644.         extern _cdecl _nullcheck(void);
  2645.  
  2646.     and then sprinkle calls to _nullcheck() through your program at
  2647.     regular intervals.
  2648.  
  2649.     Borland's TechFax document TI726 discusses the null pointer
  2650.     assignment from a Borland point of view.  It's one of many documents
  2651.     downloadable as part of
  2652.  
  2653.     <ftp://oak.oakland.edu/pub/msdos/turbo-c/bchelp10.zip>
  2654.     <ftp://garbo.uwasa.fi/pc/turbopas/bchelp10.zip>
  2655.  
  2656. ------------------------------
  2657.  
  2658. Subject: 7.11 - How can a batch file tell whether it's being run in a DOS
  2659.                box under Windows? 
  2660.     
  2661.     When Windows 3.0 or 3.1 is running, the DOS environment will contain
  2662.     a definition of the string windir, in lower case.  That's not really
  2663.     useful, however, because the batch statement
  2664.  
  2665.         if "%windir%" == "" ...
  2666.  
  2667.     will test for an environment variable WINDIR in upper case.
  2668.  
  2669.     Your only real option is to write a program as suggested by the
  2670.     following Q, and have it return a value which your batch file can
  2671.     test via "if errorlevel".
  2672.  
  2673. ------------------------------
  2674.  
  2675. Subject: 7.12 - How can my program tell if it's running under Windows?
  2676.  
  2677.     Execute INT 2F AX=4680.  If AX returns 0, you're in Windows real
  2678.     mode or standard mode (or under the DOS shell).  Otherwise, call INT
  2679.     2F AX=1600.  If AL returns something other than 0 or 80, you're in
  2680.     Windows 386 enhanced mode.  See PC Magazine 24 Nov 1992 (xi:20)
  2681.     pages 492-493.
  2682.  
  2683.     For more information, see PC Magazine 26 May 1992 (xi:10) pages 345-
  2684.     346.  A program, WINMODE, is available as part of
  2685.  
  2686.     <ftp://oak.oakland.edu/pub/msdos/pcmag/vol11n10.zip>
  2687.     <ftp://garbo.uwasa.fi/pc/pcmag/vol11n10.zip>
  2688.  
  2689.     PC Magazine 29 March 1994 (xiii:6) pages 312 and 320 published a new
  2690.     program, WINVER.  This would be in
  2691.  
  2692.     <ftp://oak.oakland.edu/pub/msdos/pcmag/vol13n06.zip>
  2693.     <ftp://garbo.uwasa.fi/pc/pcmag/vol13n06.zip>
  2694.  
  2695. ------------------------------
  2696.  
  2697. Subject: 7.13 - How can a program tell whether ANSI.SYS is installed?
  2698.  
  2699.     In DOS 4.0 and above, call INT 2F AX=1A00.  If the value FF is
  2700.     returned in AL, ANSI.SYS is installed.  For more information, see
  2701.     Ralf Brown's interrupt list (question 1.17).
  2702.  
  2703. ------------------------------
  2704.  
  2705. Subject: 7.14. How do I copyright software that I write? 
  2706.  
  2707.     You can download a very comprehensive answer from the Internet.
  2708.     Terry Carroll posts a six-part Copyright FAQ to misc.legal,
  2709.     news.answers and other groups.  A short answer follows, not based on
  2710.     that article.
  2711.  
  2712.     Disclaimer: I am not a lawyer, and this is not legal advice.  Also,
  2713.     there are very likely to be differences in copyright law among
  2714.     nations.  No matter where you live, if significant money may be
  2715.     involved, get legal advice.  The following is adapted (and greatly
  2716.     condensed) from chapter 4 of the Chicago Manual of Style (13th
  2717.     edition, ISBN 0-226-10390-0).
  2718.  
  2719.     In the U.S. (at least), when you write something, you own the
  2720.     copyright.  (The exception that matters most to programmers is
  2721.     "works made for hire", i.e., code you write because your employer or
  2722.     client pays you to.  A contract, agreed in advance, can vest the
  2723.     copyright in the programmer even if an employee; otherwise the
  2724.     employer owns the copyright.)  You don't have to register the work
  2725.     with the Copyright Office unless (until) the copyright is infringed
  2726.     and you intend to bring suit; however, it is easier to recover
  2727.     damages in court if you did register the work within three months of
  2728.     publication.
  2729.  
  2730.     From paragraph 4.16 of the Chicago Manual:  "... the [copyright]
  2731.     notice consists of three parts: (1) the symbol [C-in-a-circle]
  2732.     (preferred because it also suits the requirements of the Universal
  2733.     Copyright Convention), the word 'Copyright', or the abbreviation
  2734.     'Copr.', (2) the year of first publication, and (3) the name of the
  2735.     copyright owner.  Most publishers also add the phrase 'All rights
  2736.     reserved' because it affords some protection in Central and South
  2737.     American countries ...."  Surprise: "(C)" is legally not the same as
  2738.     the C-in-a-circle, so those of us who are ASCII-bound must use the
  2739.     word or the abbreviation.
  2740.  
  2741.  
  2742. ------------------------------
  2743.  
  2744. Subject: Section 8.  Downloading
  2745.  
  2746. ------------------------------
  2747.  
  2748. Subject: 8.01 - What are SimTel, Garbo, and Wustl?
  2749.  
  2750.     These are three of the most popular archive sites, with a few
  2751.     bazillion files available for free downloading by ftp.  (For email
  2752.     access, see "8.02 - I have no ftp access.  How can I get files from
  2753.     the archives?".)  Many of the files are shareware and you're
  2754.     expected to send a payment directly to the authors if you use them
  2755.     regularly.
  2756.  
  2757.     In comp.archives.msdos.d, Samuel Ko posts a two-part "Useful MS-DOS
  2758.     Programs at SIMTEL20 and Garbo"; it's downloadable as
  2759.  
  2760.         /pub/msdos/info/useful34.zip at SimTel
  2761.         /pc/filelist/useful34.zip at Garbo
  2762.         /pub/usenet/news.answers/msdos-archives/part* at rtfm.mit.edu.
  2763.  
  2764.     For rtfm.mit.edu instructions, see "1.13 - Where are FAQ lists
  2765.     archived?"
  2766.  
  2767.     A few words about file names and versions:  Many files at the
  2768.     archive sites are updated from time to time.  I verified every
  2769.     filename in this FAQ as of 24 Mar 1994 by ftp to the named sites, or
  2770.     by consulting their index files.  If you can't find a file given in
  2771.     these articles as mumble12.zip, perhaps there's a newer version; try
  2772.     mumble13.zip or mumble14.zip, or mumble*.zip if your ftp program
  2773.     supports wildcards (most do so).  Please let me know of any out-of-
  2774.     date file names.
  2775.  
  2776.     This FAQ should show both Garbo and SimTel directory and file names,
  2777.     if available, for every file mentioned for downloading.  If you see
  2778.     a listing for only one of them, it means that the file was not found
  2779.     at the other site, or that the other site's catalog shows an old
  2780.     version.
  2781.  
  2782.     Also remember that caps and lower case filenames are not
  2783.     interchangeable at most archive sites.
  2784.  
  2785.     1) SimTel = oak.oakland.edu is located at the University of
  2786.     Rochester in the USA, and there are also many mirror sites including
  2787.     wuarchive.wustl.edu, archive.orst.edu, ftp.uu.net, nic.funet.fi,
  2788.     archie.au, and nctucca.edu.tw.  For instructions, see these monthly
  2789.     articles in comp.archives.msdos.announce:
  2790.  
  2791.         How to find files in the SIMTEL20 msdos collection
  2792.         How to order SIMTEL20 files via e-mail
  2793.         How to upload files to SIMTEL20
  2794.  
  2795.     These are downloadable from SimTel as
  2796.  
  2797.         /pub/msdos/filedocs/aaaread.me
  2798.         /pub/msdos/filedocs/mailserv.inf
  2799.         /pub/msdos/filedocs/upload.inf.
  2800.  
  2801.     2) Garbo = garbo.uwasa.fi [128.214.87.1] is located at the
  2802.     University of Vaasa in Finland and maintained by Timo Salmi
  2803.     (ts@uwasa.fi) and others.  Garbo and SimTel contain many of the same
  2804.     files, but there are many differences too.  Among them: the
  2805.     directory structures differ greatly, and case is significant in
  2806.     directory and file names at Garbo.
  2807.  
  2808.     3) wustl = wuarchive.wustl.edu [128.252.135.4] mirrors, among
  2809.     others, Garbo (in /systems/ibmpc/garbo) and SimTel (in
  2810.     /systems/ibmpc/msdos).  As with any mirror site, it may lag by a day
  2811.     or two, so you may not want to try it on the same day you see an
  2812.     upload notice posted.
  2813.  
  2814.     4) others:
  2815.  
  2816.     A comprehensive list of MS-DOS archive sites is downloadable as
  2817.  
  2818.         /pc/pd2/moder35.zip at Garbo
  2819.         /pub/msdos/info/moder35.zip at SimTel.
  2820.  
  2821.     For archie.au via Telnet (different from the Archie file-finding
  2822.     mail servers):  Oceanian users should try archie.au first.  Paul
  2823.     Brooks has written to say that it "mirrors Garbo and SimTel-20 (in
  2824.     /micros/pc/simtel-20, /micros/pc/garbo) as well as many other
  2825.     archives.  Telnetting to 'archie.au' and logging on as 'archie' (no
  2826.     password) will access the Oceanic ARCHIE server." Email Craig Warren
  2827.     (ccw@archie.au) for instructions if needed.
  2828.  
  2829. ------------------------------
  2830.  
  2831. Subject: 8.02 - I have no ftp access.  How can I get files from the
  2832.                 archives?
  2833.  
  2834.     First, be sure that you have no ftp access before trying email
  2835.     methods.  (Ask your sysadmin, or a knowledgeable user at your site.)
  2836.     ftp is better for you because it's faster, and it uses less net
  2837.     resources too.
  2838.  
  2839.     When using an email server, make sure the Reply-to path in your
  2840.     message is valid.  If it's not, you'll get no reply from the server.
  2841.     Do wait a few days before assuming you're not going to get a
  2842.     response; some servers have long pending queues.  After a suitable
  2843.     wait, get your sysadmin's help to correct your reply-to, and send
  2844.     your message again.
  2845.  
  2846.     Occasionally a machine goes down for an extended period, which may
  2847.     prevent a timely reply to your message.  If you're sure your message
  2848.     bears a good reply path and you haven't got a reply in a week or so,
  2849.     you might send your message again, once.  Don't post it as an
  2850.     article in a newsgroup.
  2851.  
  2852.     For files from SimTel, see "How to order SIMTEL20 files via e-mail",
  2853.     posted monthly in comp.archives.msdos.announce; or send email
  2854.     containing only the word "help" to listserv@vm1.nodak.edu.  For
  2855.     instructions on using Garbo's email server, send a request to Timo
  2856.     Salmi at ts@uwasa.fi.
  2857.  
  2858.     The DEC Western Research Labs server will get files from any ftp
  2859.     site by ftp and then email them to you.  Send email containing
  2860.     "help" to ftpmail@decwrl.dec.com.
  2861.  
  2862. ------------------------------
  2863.  
  2864. Subject: 8.03 - Can I get archives on CD-ROM?
  2865.  
  2866.     Copies of the SimTel MS-DOS, Macintosh and Unix-C collections (also
  2867.     of wuarchive, cica, and others) are available from Walnut Creek
  2868.     CDROM, 1547 Palos Verdes, Suite 260, Walnut Creek, CA 94596-2228,
  2869.     telephone (800) 786-9907 or +1 510 674-0783, or FAX +1 510 674-0821,
  2870.     or email rab@cdrom.com.
  2871.  
  2872.     For a catalog of disks available, send email to info@cdrom.com, or
  2873.     ftp the catalog as /cdrom/catalog from cdrom.com.
  2874.  
  2875. ------------------------------
  2876.  
  2877. Subject: 8.04 Where do I find program <mumble>?
  2878.  
  2879.     You _are_ asking about shareware, freeware, or public-domain
  2880.     programs, right?  Commercial software is not legally distributed
  2881.     through the net, in general.  (Occasionally vendors will make
  2882.     patches available, but these are useful only to upgrade software you
  2883.     already own.)
  2884.  
  2885.     That said, there are several newsgroups to help you find a program.
  2886.     comp.binaries.ibm.pc.wanted is generally the best place to ask your
  2887.     question.  Please review the guidelines in "108. What other
  2888.     technical newsgroups should I know about?"
  2889.  
  2890.     Download and check the indexes from SimTel and Garbo (see "8.05 - How
  2891.     can I check SimTel or Garbo before I post a request for a
  2892.     program?").  Unless what you're looking for is commercial software,
  2893.     there's a good chance it will be at one or both of those sites.  The
  2894.     Archie servers maintain directories of many (not all) ftp sites
  2895.     worldwide.  You can Telnet to a server or client to search for
  2896.     files, or perform a search by email.
  2897.  
  2898. ------------------------------
  2899.  
  2900. Subject: 8.05 - How can I check SimTel or Garbo before I post a request
  2901.                for a program?
  2902.  
  2903.     SimTel and Garbo have indexes of their contents, which you can
  2904.     download and then search off line.
  2905.  
  2906.     Garbo's index file, /pc/INDEX.ZIP, contains an annotated list, often
  2907.     updated, of the MS-DOS files there.  The news file /pc/pd2/news-pd2
  2908.     contains selected news on all MS-DOS directories at Garbo.
  2909.  
  2910.     SimTel's index files, in /pub/msdos/filedocs, are updated several
  2911.     times a month.  simlist.zip contains a list in text format.  But you
  2912.     may prefer the file simindex.zip, which is comma-delimited for easy
  2913.     use with any of these search facilities:
  2914.  
  2915.     - Two downloadable search programs are simtel35.zip and
  2916.       simdir22.zip.
  2917.  
  2918.     - dBASE III or IV users can load the index from simindex.zip using
  2919.       instructions in simibm.inf and simibm.db3.
  2920.  
  2921.     - PC-FILE users should get simibm.hdr, which tells how to use
  2922.       simibm.ibm.
  2923.  
  2924. ------------------------------
  2925.  
  2926. Subject: 8.06 - How do I download and decode a program I found?
  2927.  
  2928.     See the "Starter kit" and "Beginner's guide to binaries" in
  2929.     comp.binaries.ibm.pc, usually posted on the first and 15th of every
  2930.     month.  Please wait for these articles to come around; don't post a
  2931.     request.  If you can't wait, they are downloadable from
  2932.  
  2933.         Garbo as /pc/doc-net/starter.kit and bin.man
  2934.         rtfm.mit.edu in /pub/usenet/comp.binaries.ibm.pc .  The file
  2935.             names are quite long; try look for names of the form
  2936.             *starter.kit* and *bin.man*
  2937.  
  2938.     For rtfm.mit.edu instructions, see "1.13 - Where are FAQ lists
  2939.     archived?"
  2940.  
  2941.     Most binaries are posted and sent through email in 'uuencode'
  2942.     format.  The starter kit contains a uudecode program to turn this
  2943.     file back into binary.  Since the uuencoded file is bigger than the
  2944.     binary, you'll save connect time if you can uudecode it and then
  2945.     download the binary file.  Remember to set file type to binary.
  2946.  
  2947. ------------------------------
  2948.  
  2949. Subject: 8.07 - Where is UUDECODE?
  2950.  
  2951.     You can find it at SimTel and Garbo, but it's easier to take it from
  2952.     the "starter kit" mentioned in the preceding Q.
  2953.  
  2954.     If you're logged in at a Unix site, there's almost certainly a
  2955.     uudecode there:  just type "uudecode" followed by a space and the
  2956.     file name.  The binary file is 25% smaller than the uuencoded file,
  2957.     so you'll save connect time if you can uudecode it on the Unix host
  2958.     and then download the binary file.  Remember: set file type binary.
  2959.  
  2960. ------------------------------
  2961.  
  2962. Subject: 8.08 - Why do I get errors when extracting from a ZIP file I
  2963.                 downloaded?
  2964.  
  2965.     There are many possible causes, but two of them probably account for
  2966.     95% of all problems.
  2967.  
  2968.     1) File transmission:  You must tell the archive site to transfer
  2969.     ZIP files in binary mode.  Depending on your software, you may also
  2970.     need to set your local software to receive files in binary mode.
  2971.  
  2972.     2) Unzipping program:  Make sure you aren't using an obsolete
  2973.     version.  In <9303290853.kp28285@tacom-emh1.army.mil> on 29 Mar
  2974.     1993, Keith Petersen, SimTel administrator, wrote:  "SIMTEL20 has
  2975.     standardized on the Info-ZIP group's ZIP and UNZIP because they are
  2976.     freely distributable and they have no restrictions on exporting.
  2977.     The latest version of Info-ZIP's ZIP and UNZIP can always be found
  2978.     in directory" /pub/msdos/zip "and will always have the name 'Info-
  2979.     ZIP' in the description to make them easy to locate."  PKUNZIP
  2980.     version 1.10 may not unzip newer stuff from archive sites because
  2981.     site administrators have now embraced version 2.04.  Also see "9.03 -
  2982.     What's the current version of UNZIP?"
  2983.  
  2984.  
  2985. ------------------------------
  2986.  
  2987. Subject: Section 9.  Vendors and products
  2988.  
  2989. ------------------------------
  2990.  
  2991. Subject: 9.01 - How can I contact Borland? *revised*
  2992. Date: Wed, 11 Jan 95 15:34:00 CDT
  2993.  
  2994.     Individual employees of Borland post here sometimes.  Their
  2995.     addresses all take the form person@borland.com.
  2996.  
  2997.     Files from FTP:
  2998.  
  2999.     Patches, examples, and product info can be found at ftp.borland.com in
  3000.     the /pub directory.
  3001.  
  3002.     All materials reside within the "/pub" subdirectory.  Below
  3003.     this directory are the following areas:
  3004.  
  3005.     custserv/      Customer Service related information
  3006.     filxdir.txt    File Directory cross-reference
  3007.     partners/      Borland Business Partners
  3008.     eduinfo/       Educational Institutions
  3009.     libs/          File Libraries
  3010.     support/       Support Programs & Options
  3011.     INDEX          List of all files at FTP.BORLAND.COM
  3012.     README         Information about FTP.BORLAND.COM
  3013.  
  3014.     Borland has set up these email addresses.  However, none of them is
  3015.     for technical support such as help with finding your own programming
  3016.     errors and explaining compiler messages.
  3017.  
  3018.     - bp7-info@borland.com will reply to any message with 17K of info on
  3019.       Borland Pascal with Objects 7.0 and Turbo Pascal 7.0.
  3020.  
  3021.     - customer-support@borland.com is for questions about prices and
  3022.       features of products, replacing bad or missing disks, info on
  3023.       upgrades, etc.  They do not accept emailed credit-card numbers.
  3024.  
  3025.     - bugs@borland.com will take "a well-documented bug report" and send
  3026.       an automated response, but will not give you a work around or a
  3027.       scheduled fix date or even confirm that it is or is not considered
  3028.       a bug.  "The purpose of bugs@borland.com is to improve future
  3029.       products sooner, not as a substitute for tech support channels."
  3030.  
  3031.     - techinfo@borland.com will subscribe you to the Borland TechInfo
  3032.       newsletter.
  3033.  
  3034.     Email tech support is available only through Compuserve (GO BOR).
  3035.  
  3036.     Telephone support is provided through separate phone numbers for
  3037.     most products.  If you're calling from the U.S., dial (800) 841-8180
  3038.     for a recorded list of toll numbers to call.  Borland's BBS is at +1
  3039.     408 439 9096.  The surface-mail address is Technical Support
  3040.     Department, Borland International, P.O. Box 660001, Scotts Valley CA
  3041.     95067-0001, USA.
  3042.  
  3043.     You'll need to give your product's name, version, and serial number.
  3044.  
  3045.     Borland's TechFax documents are also available for download:
  3046.  
  3047.     <ftp://oak.oakland.edu/pub/msdos/turbo-c/bchelp10.zip>
  3048.     <ftp://garbo.uwasa.fi/pc/turbopas/bchelp10.zip>
  3049.  
  3050.     These documents are detailed answers to common questions about Turbo
  3051.     C and Borland C products, and aggregate several hundred Kbytes.
  3052.  
  3053. ------------------------------
  3054.  
  3055. Subject: 9.02. How can I contact Microsoft?
  3056. Date: Wed, 09 Oct 95 15:34:00 CDT
  3057.  
  3058.     Individual employees of Microsoft (not MicroSoft, please!) post here
  3059.     sometimes.  Their addresses all take the form person@microsoft.com.
  3060.     However, Microsoft as a company does not answer individual questions
  3061.     via email through the Internet.
  3062.  
  3063.     1) information available via anonymous ftp
  3064.  
  3065.     Microsoft's anonymous FTP server (ftp.microsoft.com) offers
  3066.     a variety of information for developers. This ftp server is
  3067.     run using Windows NT Version 3.5, so it supports both UNIX-
  3068.     like and DOS-like path names. For example \SOFTLIB\INDEX.TXT
  3069.     and /SOFTLIB/INDEX.TXT are both valid. Filenames are not case
  3070.     sensitive.
  3071.  
  3072.     These files in the root directoy may be of interest:
  3073.  
  3074.     index.txt   Information about FTP.MICROSOFT.COM
  3075.  
  3076.     dirmap.txt  List of all directories at FTP.MICROSOFT.COM
  3077.  
  3078.     ls-lr.zip   FTP.MICROSOFT.COM file list. Compressed using
  3079.                 PKZip Version 2.04g
  3080.  
  3081.     Directory List:
  3082.  
  3083.     ADVSYS               Advanced Systems, Networks, Mail
  3084.       |----- LANMAN      LanMan & other networks
  3085.       |----- MAIL        Mail and Schedule+
  3086.       |----- MSCLIENT    Microsoft Networking Client
  3087.       |----- SQL_ODBC    SQL and ODBC
  3088.       |----- WINNT       Windows NT
  3089.        ----- WINSOCK     Windows Sockets information
  3090.  
  3091.     DESKAPPS             Desktop Applications
  3092.       |----- ACCESS      Access
  3093.       |----- DOSWORD     Word for MS-DOS
  3094.       |----- EXCEL       Excel
  3095.       |----- GAMES       Entertainment Packs, Flight Sim, etc.
  3096.       |----- HOMEAPPS    Home applications 
  3097.       |----- MISCAPPS    Other applications
  3098.       |----- MMAPPS      Multimedia Titles
  3099.       |----- OFFICE      Microsoft Office
  3100.       |----- POWERPT     PowerPoint
  3101.       |----- PROJECT     Project
  3102.       |----- PUBLISHER   Publisher
  3103.       |----- WORD        Word for Windows & Macintosh
  3104.        ----- WRKS_MNY    Works and Money
  3105.  
  3106.     DEVELOPR             Developer Tools and Information
  3107.       |----- BASIC       Quick Basic & other Basics
  3108.       |----- DEVCAST     DevCast information
  3109.       |----- DEVUTIL     MS Test, Delta, EXEMOD, EXEPACK, LIB Utility
  3110.       |----- DRG         Developer Relations Group
  3111.       |----- FORTRAN     Fortran and Fortran PowerStation
  3112.       |----- FOX         FoxPro and FoxBase
  3113.       |----- MAPI        Messaging API information
  3114.       |----- MASM        Macro Assembler
  3115.       |----- MSDN        Microsoft Developer Network
  3116.       |----- MSJ         Microsoft Systems Journal
  3117.       |----- OLE         OLE
  3118.       |----- TAPI        Telephony API information
  3119.       |----- VB          Visual Basic
  3120.       |----- VISUAL_C    Visual C++, MFC, & other C products
  3121.       |----- WIN_DK      Windows SDK, DKs & At Work
  3122.        ----- WIN32DK     32 bit Development Kits
  3123.  
  3124.     MSEDCERT             Microsoft Education and Certification
  3125.       |----- EDUCATIO    Microsoft Education information
  3126.        ----- CERTIFIC    Microsoft Certified Professional info
  3127.  
  3128.     MSFT                 Microsoft shareholder information
  3129.       |----- ANNREPT     Microsoft Annual Report
  3130.       |----- BACKGRND    Background information on Microsoft
  3131.       |----- PRESSREL    Microsoft Press Releases
  3132.        ----- SEC         Recent filings with the Securities and
  3133.                          Exchange Commission
  3134.  
  3135.     SOFTLIB              Instructions & index for software library
  3136.       |----- MSLFILES    Software library files (> 1500 files)
  3137.  
  3138.     PEROPSYS             Personal Operating Systems and Hardware
  3139.       |----- HARDWARE    Mouse & other Hardware
  3140.       |----- MSDOS       MS-DOS
  3141.       |----- WINDOWS     Windows (all versions)
  3142.        ----- WIN_NEWS    Information on Windows 95
  3143.  
  3144.     TECHNET              Information on TechNet
  3145.       |----- SERVDIR     Microsoft Services Directory
  3146.  
  3147.     2) information via U.S. Mail
  3148.  
  3149.     Microsoft Product Support is at 16011 NE 36th Way, Box 97017,
  3150.     Redmond WA 98073-9717, USA.
  3151.  
  3152.     You can subscribe to the {Microsoft Developer News} by mailing a
  3153.     request to Microsoft Developer Network, P.O. Box 51812, Boulder CO
  3154.     80322-1812, U.S.A.  The nearest I can figure, this is free;
  3155.     certainly I've never paid for it or been asked to.
  3156.  
  3157.     3) tech support via modem
  3158.  
  3159.     On Compuserve, GO MICROSOFT; or call Microsoft's BBS at +1 206 936-
  3160.     6735 in the U.S., or +1 416 507-3022 in Canada.
  3161.  
  3162.     4) tech support via voice telephone lines
  3163.  
  3164.     If you want to place an order or get general pre-sales information,
  3165.     call the appropriate sales and service number:
  3166.  
  3167.         U.S. end-user sales                   (800) 426-9400
  3168.         U.S. corporate/gov't/reseller/
  3169.                  educational sales            (800) 227-4679
  3170.         Canadian sales                        (800) 568-3503
  3171.         International sales                  +1 206 936-8661
  3172.  
  3173.     For tech support you must make an ordinary long-distance phone call.
  3174.     Microsoft has separate incoming phone numbers for many products.
  3175.     Since it's your nickel, first check your documentation to see if a
  3176.     phone number is listed.  Here are phone numbers (as of 1 June 1992)
  3177.     for a few products of most interest to the readers of this group:
  3178.  
  3179.         C/C++               (206) 635-7007
  3180.         MASM                (206) 646-5109
  3181.         DOS Upgrade Users   (206) 646-5104 (for 90 days after first
  3182.             call)
  3183.         Windows Users       (206) 637-6098
  3184.  
  3185.     If you can't find the direct number any other way, call the "master"
  3186.     numbers below or the sales numbers a few paragraphs above.  You'll
  3187.     get the "voice mail phone tree from h-ll" but you'll eventually get
  3188.     to the right department.  They don't provide technical assistance,
  3189.     but a voice menu will help you find the current phone number for the
  3190.     department you need.
  3191.  
  3192.         U.S. end-user product support         (206) 454-2030
  3193.         U.S. languages support                (206) 637-7096
  3194.  
  3195. ------------------------------
  3196.  
  3197. Subject: 9.03. What's the current version of UNZIP?
  3198.  
  3199.     (Revised: 05/09/1994)
  3200.  
  3201.     The current version of PKWare's PKZip is 2.04g.
  3202.     The current version of InfoZip's ZIP is 2.0.1.
  3203.     The current version of InfoZip's UNZIP is 5.12.
  3204.  
  3205.     Since April 1993, the administrators of Garbo and SimTel have
  3206.     accepted uploads in the ZIP 2.0 format.  You can use the free Info-
  3207.     ZIP versions, or PKZIP 2.04g (not 2.04c or 2.04e).  SimTel has
  3208.     standardized on the Info-ZIP versions for several reasons, as
  3209.     explained in an article posted 29 Mar 1993 in
  3210.     comp.archives.msdos.announce.
  3211.  
  3212.     The primary source of the free Info-ZIP programs is at ftp.uu.net,
  3213.     directory /pub/archiving/zip; or at quest.jpl.nasa.gov, directory
  3214.     /pub.  Files are in those directories or in subdirectories as shown
  3215.     below.  The DOS executable for UNZIP is self extracting; all others
  3216.     require UNZIP 5.0, 5.1, 5.11 or 5.12:
  3217.  
  3218.         MSDOS/unzip512x.exe - DOS executable and doc, UNZIP 5.12
  3219.         unzip512.zip - source code for UNZIP 5.12, all platforms
  3220.         MSDOS/zip20x.zip - DOS exe and doc, ZIP without crypt support
  3221.         zip201.zip - source code for ZIP 2.0, all platforms
  3222.         MSDOS/zcryp20x.zip - DOS exe and doc, ZIP with crypt support
  3223.         zcrypt21.zip - source code for ZIP crypt support
  3224.         WINDOWS/wunz20x.zip - Windows 3.1 WIZUNZIP 2.0 exe and help file
  3225.         WINDOWS/wunz20sr.zip - Windows 3.1 WIZUNZIP 2.0 source
  3226.  
  3227.     The essential files are also available at SimTel in /pub/msdos/zip
  3228.     and at Garbo in /pc/arcers.
  3229.  
  3230.     PKZIP and PKUNZIP are shareware products of PKWARE Inc.  The current
  3231.     version is 2.04g, which is the third official version after 1.10.
  3232.     They are downloadable
  3233.  
  3234.         from PKWARE's bulletin board, +1 414 354 8670, or
  3235.         from Garbo as /pc/arcers/pkz204g.exe
  3236.         from SimTel as /pub/msdos/zip/pkz204g.exe
  3237.  
  3238.     By the way, if you want to develop your own utilities, you will find
  3239.     the ZIP 2.0 data structures described in the downloadable file
  3240.  
  3241.     <ftp://oak.oakland.edu/pub/msdos/zip/appnote.zip>
  3242.  
  3243. ------------------------------
  3244.  
  3245. Subject: 9.04. What is the phone number for a vendor's BBS?
  3246.  
  3247.     Robert Baker (rbakerpc@delphi.com) uploaded a list of 800 bulletin-
  3248.     board support numbers operated by software vendors as of August
  3249.     1993.  It is downloadable as /pub/msdos/bbslist/bbs_9308.zip from
  3250.     SimTel.
  3251.  
  3252. (End of comp.os.msdos.programmer FAQ Version 2.01)
  3253.