Optimizing Windows. (Compute's Getting Started With)
by David English, Mark Minasi, Clifton Karnes
WHY OPTIMIZE WINDOWS?
Like it or not, Windows is the future of PC software. Making it run more efficiently will increase your software's performance by orders of magnitude. Most of last year's major new software programs were Windows programs, and nearly all of this year's most innovative titles will require Windows 3.0 or Windows 3.1.
Windows programs are easier to use, in part because they're built on a uniform interface: consistent placement of pull-down menus, common keyboard shortcuts, and shared resources such as fonts and printer drivers. We intuitively understand moving and clicking on objects, because that's how we've learned to interact with the world around us. Graphical environments, such as Windows, the Macintosh, and OS/2, make complex programs appear less complicated than they really are.
Therein lies the paradox. Behind the easy-to-use veneer of Windows is a complex operating environment that simultaneously works with DOS and supersedes its functions. While OS/2 replaces DOS, Windows takes on the much harder task of improving on DOS without taking its place. Despite Windows' many ease-of-use features, you still need to be familiar with DOS commands, file-naming conventions, and how to navigate directories. And while Windows makes it easy to add fonts, sound drivers, and printers to Windows programs, it can be a nightmare having to sort through your WIN.INI and SYSTEM.INI when something goes wrong and Windows won't boot.
Fortunately, the Windows 3.1 manual provides much more information than its predecessor on increasing the efficiency of your hard drive, modifying your CONFIG.SYS and AUTO-EXEC.BAT files, and using a memory manager. The Windows 3.1 setup program lets you install or uninstall portions of Windows--so you can save valuable hard disk space by not installing Paintbrush, Terminal, or the Windows games. Windows 3.1 usually lets you back out of an application when something goes wrong, unlike Windows 3.0, which forces you to reboot your entire system. In addition, 3.1 runs noticeably faster that 3.0. If you haven't upgraded yet, do it now. It's the single best way to optimize Windows.
Windows 3.1 does such an excellent job of checking out your particular system, you may run into problems if you copy or backup your Windows directories to another computer. In this situation, you may need to reinstall 3.1 on top of the transferred version so Windows can fine tune itself to the new machine. The installation program keeps your old Program Manager groups so you won't have to rebuild your Windows desktop.
While Windows 3.1 is much more stable than 3.0, there's still room for improvement. You still need to tweak the Windows environment for your particular hardware, applications, and preferences. The following articles will help you get started with the basics of optimizing Windows. A little bit of time spent studying the inner workings of Windows will pay off handsomely in the months and years to come.
HOW TO OPTIMIZE DOS PROGRAMS UNDER WINDOWS
Nice as the power of Windows is, there are plenty of old DOS programs you'll still want to run. And there's basically just two keys to that: good memory management and good PIFs.
You've read in previous issues of COMPUTE about how to set up the DOS 5.0 memory manager to get the most free memory for your DOS session, so I won't repeat that here. It's essential, however, that the DOS 5.0 memory manager as well as the Windows memory manager both understand exactly what your upper memory area looks like. That means heavy use of the I= and X= parameters in your EMM386.EXE statement, and corresponding EMM-EXCLUDE and EMM-INCLUDE statements in your SYSTEM.INI. Be sure that you explicitly map out all the includable and excludable areas both in CONFIG.SYS and SYSTEM.INI.
Memory mapping is essential to get the Windows/DOS system to function reliably in the first place. But that's not all; in order to run a DOS program, you must create a PIF (Program Information File) for that DOS program. As you probably know, you do that with the PIF Editor, a program that comes with Windows. You see the PIF editor's opening screen in Figure 1, and the Advanced Options screen in Figure 2.
Here are a few tips on using the PIF editor.
Which kind of memory does your program need? Consult its manual to find out if it can use EMS memory (also known as LIM or expanded memory). Common examples are Lotus 1-2-3 version 2.x and WordPerfect version 5.1. A variation on extended memory--the memory above the 1024K address on your PC--is called XMS memory, and only a few programs (Lotus 1-2-3 version 3.1, for example) can use it. Note that there are default values of 1024 in the limits; reduce them to zero if you know that your program doesn't need either kind of memory.
On the Advanced PIF editor screen, you'll see check boxes that allow you to lock memory. Lock means "keep this in RAM all the time--don't ever swap it to disk." In general, you won't lock memory unless you find that when you switch away from an application and then switch back that it no longer works properly.
You also may need to adjust the PIF's graphics options. Make sure that all of the check boxes that say monitor ports are not selected. There's no reason to monitor ports unless you have an actual EGA video board. Monitoring ports slows down graphics considerably. You also probably don't have to retain video memory unless you find that switching away from and back to an application causes your screen's colors to change, or part of the screen to become garbled.
Finally, if you're running a program in the background, deselect detect idle time if it seems to stop working after being in the background for a while. Windows sometimes thinks that a background program isn't doing anything, and stops giving it CPU time.
HOW TO OPTIMIZE YOUR SYSTEM.INI
Once you install Windows on your system, you'll notice that you've got a new file extension to add to your collection. In addition to COM, EXE, DOC, SYS, and TXT, you'll have INI (short for initialization) files. These are simple ASCII text files that Windows programs create in order to store your preferences and other settings that you've made in the process of using those programs.
Of all the INI files, one of the most important is used not by a Windows application, but by Windows itself--the SYSTEM.INI file.
Pull up your SYSTEM.INI file with an ASCII text editor (Windows Notepad will do just fine), and you'll notice that it's divided into sections whose names are surrounded by square brackets. For instance, the first section is called [boot].
Here are a few tips that you can use in an important section located a bit later in the file, the [386enh] section. [386enh] controls WIN386.EXE, the multitasking heart of the Windows 386 Enhanced mode.
First, look to see if the line DEVICE=WINA20.386 is still present, left over from the Windows 3.0 days; if so, remove it--it's no longer needed.
If you've got a system that runs at 25 MHz or faster, smooth out your DOS multitasking by adding the line MINTIMESLICE=5. This sets the size of each slice of CPU time doled out to each program. The default of 20 (the units are in milliseconds) is too large, and makes multitasking choppy.
And, while you're at it, tell Windows to temporarily boost the priority of any program that you're interacting with by adding the line KEYBOOSTTIME=.2.
The .2 says to raise an application's priority for 0.2 seconds after each keystroke, the idea being that any application that you're typing characters into is one that you want to receive high priority. (The default was 0.001 seconds.)
Communications programs have a similar possibility in the COMBOOSTTIME parameter--except that the units go back to milliseconds, and the default is 2 ms. Crank it up to 20 ms, and you'll find that your favorite DOS communications programs will run better in the background under Windows.
You may have given up on the notion of running games in the background under Windows, as the multitasking overhead makes them slow, but don't give in until you've added TRAPTIMERPORTS=OFF to SYSTEM.INI.
Many games aren't slow because of multitasking; they're slow because they're keyed to the built-in system timer, and Windows interferes with programs' ability to modify that timer. As a result, your game may reset the timer to provide 100 ticks per second, many more than the usual 18.2 ticks per second. Windows interferes with that, restoring the timer to 18.2 ticks per second. The game doesn't know that and assumes it's now supposed to run a bit over five times too slow. TRAPTIMERPORTS=OFF tells Windows to leave the timer alone when an application modifies it.
If Windows can't control the timer ports, however, the Clock may report an incorrect time; if so, be sure to add the line SYNCTIME=ON after the TRAPTIMERPORTS command.
This has been a brief look at a few of the most powerful SYSTEM.INI comands. If you get the Windows Resource Toolkit from Microsoft, you'll be able to learn even more about those commands and exercise more control over your machine.
HOW TO USE THE CLIPBOARD, OLE, AND DDE
In addition to its graphical and multitasking powers, Windows changes the way that programs work by providing Inter Process Communications (IPC) capabilities. IPCs keep getting better, and Windows 3.1 provides the best IPC yet--Object Linking And Embedding, or OLE (and that's no bull). In a few paragraphs, I can't get into tremendous detail, so I'll use this space to give you an example of Windows' IPCs.
Let's use a simple cut and paste project using the Clipboard to demonstrate the power of IPCs. Open up Paintbrush, Write, and Clipboard Viewer. Doodle around in Paintbrush for a bit. Write a sentence or two in Write. Then select your drawing in Paintbrush, and choose Edit/Copy to place a copy in the Clipboard. At the same time, you'll see the Clipboard Viewer display the picture. Then choose Edit/Paste in Write, and your picture will be incorporated into the Write document, as you see in Figure 3.
Now suppose you want to change the drawing at a future time? Until Windows 3.1 and IPCs, you were out of luck: Write could display a picture, but it couldn't modify it. The only way that you could change your drawing would be if you had saved the picture while you were still in Write.
Many Windows programs now support Object Linking and Embedding. OLE lets you paste text, numbers, or a picture into a document, but the text, numbers, or picture--now called an object--actually remembers where it came from!
To see this, delete the picture from the Write document, and re-copy it from Paintbrush. You'll likely see a dialog box like that in Figure 4. Choose Paintbrush Picture Object and click Paste, and you'll see basically what you saw previously. But now close up Paintbrush, without saving the drawing. Go back to Write and double-click on the picture, and a copy of Paintbrush automatically loads, containing the drawing!
Once you make your changes, and close Paintbrush, you'll see a dialog box like Figure 5. What the dialog box is asking is whether or not you want to reembed the picture in your Write document. Click Yes, and the modified picture will be embedded in the document.
That's simple cut and paste and OLE--but what about DDE? It's the underlying structure upon which OLE is built. DDE is a constant, real-time link between data in one application and data in another application. For example, you could have data--perhaps a news ticker--coming in from your modem to Crosstalk for Windows, which then gets DDE'd to Ami Pro, which formats the news and prints it as it arrives.
In general, however, using DDE requires writing macros. Most major Windows packages include a macro language with DDE support, but it's a bit of work learning DDE from that standpoint. You may be able to get the benefits of DDE without any hard work, however, if your application supports a "Paste Link" option on the Edit menu. If you've got Ami Pro and Excel, try pasting a few numbers from an Excel spreadsheet into an Ami Pro document, but don't Paste them--Paste Link them. Then click over to the spreadsheet, and type over the numbers. You'll see that as you change the numbers in the spreadsheet, the numbers in the word processing document change also.
One final word if you're going to try to use IPCs under Windows: be careful. OLE and DDE are neat, but they don't always work due to some underlying architectural issues in Windows. But for the applications that find relevance in IPCs, it's a terrific facility.
HOW TO USE THE FILE MANAGER IN WINDOWS 3.1
Since the Windows 1.0 days of the MS-DOS Executive, I've hated Windows' file management capabilities. And I'm not the only one.
I routinely ask my Power Windows classes, "Does anyone here use the File Manager for all of her file copying, deleting, and the like--never going out to the DOS prompt?" I use the pronoun her because, if a woman ever raises her hand, I'll propose to her right then and there. I figure that anyone that patient would be an ideal companion. I am, however, still single.
The 3.1 File Manager is a bit easier to live with than its prodecessors, however. And the File Manager can do a few things that are quite convenient. If you've taken that file cabinet icon off your program groups, you ought to put it back. Here's why.
* You can use the File Manager to nuke entire subdirectories and sub-subdirectories in just a few clicks. To this day, DOS lacks a command that will not only delete an entire subdirectory, but all subdirectories below it. You must sequentially delete and RD, delete and RD, until the job is done.
Here's how you do it with File Manager. Choose Options/Confirmation..., deselect the File Delete and Directory Delete check boxes, and then click OK. Click once on the top of the subdirectory tree that you want to delete, and press the Del key. It'll ask for a confirmation, so click OK, and File Manager will zap those files and directories in a twinkling. (Be careful with this, of course.)
* You can selectively move, copy, and delete files and directories. Suppose you want to move just a few files from subdirectory X to subdirectory Y. The old standby COPY command doesn't do much for you, as it requires that you type separate COPY commands for each file.
But in File Manager, just open up two windows, one for each subdirectory. (In case you're wondering, you open the second window by choosing Window/New Window.) Then choose the specific files by Ctrl-clicking each file. Once you've selected all the desired files in the subdirectory X window, just drag the mouse pointer over to the Y window, and release the mouse button. You'll get a dialog box confirming that you do, indeed, want to move the files. Click OK, and the job is done. Alternatively, you can Ctrl-click and Ctrl-drag to copy the files rather than move them.
* Use the Associations to make yourself more productive. For instance, I have hundreds of drawings of the insides of PCs that I've created for my PC troubleshooting books. I can't always remember what a specific one looks like, but they're all drawn with Micrografx Designer, a package that designates files with the DRW extension.
I associate DRW with Designer, and then I can browse through my DRAWINGS subdirectory. When I see an interesting-looking file name, I can simply double-click on it. Windows automatically invokes Designer, and loads the specified diagram.
* If you've got a piece of data that you access regularly--a things to do ASCII text file, for example--you can use the File Manager to put that file on your program groups. Just grab the file and drag it from the File Manager to a Program Manager group, and drop it. It will assume the icon of the program with which it's associated.
In the future, just double click on it, and it'll start up with its associated program. In the things-to-do example, Notepad would start up, displaying the list.
Quickly install Program Manager
Using the Program Manager to install icons can be time consuming, error prone, and tedious.
Drag icons from File Manager to Program Manager.
1. Make sure Program Manager is active, and minimize all other windows.
2. Open File Manager (on the Main group).
3. Double-click on the desktop or press Ctrl-Esc to call Task Manager.
4. Click on Title or press Alt-T to arrange File Manager and Program Manager windows side by side.
5. Drag the files you want to install from File Manager to the Program Manager group.
6. You can drag any program file (with an EXE, COM, PIF, or BAT extension) or any associated document file.
You can drag files to a Program Manager group window that's maximized, restored, or minimized.
Optimize Program Manager's (or any window's) size
Unless you specifically arrange it, Program Manager is usually either too large (obscuring your icons) or too small (so you can't see all its icons and groups).
Use Task Manager to tile Program Manager.
1. Make sure all applications except Program Manager are minimized (note that you must have at least one minimized application icon on your desktop).
2. Double-click on the desktop or press Ctrl-Esc to call Task Manager.
3. Click on Tile or press Alt-T to tile Program Manager's window.
4. Program Manager will fill the screen except for a band at the bottom that's just tall enough to display minimized icons.
5. If you like Program Manager's optimized size, be sure to preserve your setup by saving your changes when you exit Windows.
The Tile command was doubtless intended to be used with a group of windows--to arrange them so you could see the maximum of each one. The fact that Tile works with a single window makes it ideal for optimizing any program's window. Just minimize all applications except the one you want to optimize, and use Task Manager to Tile the application.
Arrange all icons--program, document, and application
Icons are both the joy and the curse of Windows. Using Window's three types of icons will only help you if the icons are arranged in an organized and orderly way.
Learn how to arrange each type of icon.
* To arrange program item icons (the Program Manager icons on which you double-click to run programs), select one and choose Window, Arrange Icons from Program Manager's menu bar.
* To arrange document icons (minimized Program Manager groups), select one and choose Window, Arrange Icons from Program Manager's menu bar.
* To arrange application icons (programs that are running but minimized on the desktop), select one, call Task Manager, and either click on Arrange Icons or press Alt-A.
Save your configuration without quitting Windows
When you've arranged Program Manager's main window, document windows, icons, and document icons just the way you want them, you'll want to save your setup. However, Windows only saves your setup when you exit.
Fool Windows into saving your changes.
1. Hold down Shift.
2. Select File, Exit (using either a mouse or the keyboard). Windows will save your configuration but won't close.
Windows 3.0 or 3.1
1. Load any DOS application other than DOS Prompt by Shift-double-clicking on it, which loads it as a minimized icon rather than full screen. If you're using Windows 3.1, select Options, Save Settings on Exit.
2. Exit Windows by double-clicking on Program Manager's control box. If you're using Windows 3.0, click on Save Changes followed by OK. For Windows 3.1, simply click on OK.
3. You'll see the message "Application still active; exit the application and then try closing Windows."
4. Click on OK. Your setup has been saved, but you're still in Windows.
When you exit Windows, the first thing it does is save your setup. Next, it automatically closes all Windows applications, giving each a chance to prompt you to save changes, if there are any. Windows doesn't have this control over DOS applications, so it aborts the exit and asks you to manually close each program. Windows 3.1, however, will exit if DOS Prompt is still active, so it's wise to choose another DOS application to stop Windows' exit.
Maximize and restore windows without using buttons
All windows have minimize and maximize or restore buttons, but they're small and difficult to click on, especially if you're in a hurry.
Double-click on the title bar.
* Double-click anywhere on the title bar to maximize a restored window.
* Double-click anywhere on the title bar to restore a maximized window.
Create a macro to view nonassociated text files
With File Manager, there are two ways you can view files easily: You can associate the file's extension with Notepad (or another text editing program) and double-click on the file, or you can drag the file to a Notepad icon (in Windows 3.1). The first method only works if the file is associated, and the second method requires that Notepad be minimized on your desktop.
Use a Recorder macro to load the file at the cursor in File Manager (or MS-DOS Executive) into Notepad.
1. In File Manager or MS-DOS Executive, Select a file to load into Notepad.
2. Open Recorder, configure the program to ignore mouse movement, choose a name for your macro, and start recording.
3. In File Manager, press Alt-F, P, and Ctrl-Insert to copy the selected filename to the Clipboard. Press Tab, Tab, Enter to exit the dialog box.
4. Press Alt-F, R, and type NOTEPAD.EXE in the text box followed by a space.
5. Press Shift-Insert to paste the name of the file into the text box.
6. Press Enter.
7. Stop Recording the macro, and assign the macro a keypress such as Ctrl-Alt-N.
Create a macro to display a wildcard listing
To view files by extension type in File Manager, you have to go through slow menus and dialog boxes.
Use a Recorder macro to automatically display all files with the same extension as the file at the cursor.
1. Place the cursor on any filename in File Manager that ends with a three-character extension.
2. Run Recorder and prepare to record a macro.
3. Press Alt-F, P, and press cursor left five times.
4. Press Shift-Home to define the part of the filename before the extension.
5. Press Delete.
6. Press *.
7. Press Home, followed by Shift-End to define the wildcard filename.
8. Press Ctrl-Insert to copy the wildcard to the Clipboard. Press Tab, Tab, Enter to exit the dialog box.
9. Press Alt-V, T (C for Windows 3.0), and Shift-Insert to paste the wildcard into the text box.
10. Press Enter to display files with the wildcard, then stop recording.
This macro works for files with one-, two-, or three-character extensions, but will not work for files with no extension.
Use the typographic symbols for quotes and dashes
Polished documents demand special typographic symbols for single quotes, double quotes, em dashes, and en dashes.
Use Windows extended ANSI character set.
* To produce beginning and ending single quotation marks, make sure Num Lock is on, and press Alt-0145 and Alt-0146 on the numeric keypad.
* To produce beginning and ending double quotation marks, make sure Num Lock is on, and press Alt-0147 and Alt-0148 on the numeric keypad.
* To produce an em dash (often crudely represented by two hyphens --), make sure Num Lock is on, and press Alt-0151 on the numeric keypad.
* To produce an en dash (the typographic symbol that's longer than a hyphen but shorter than an em dash and is used to indicate ranges), make sure Num Lock is on, and press Alt-0150 on the numeric keypad.
Unfortunately, you can't use Recorder to save these keystrokes in a macro. This is a Recorder bug.
Move and copy files with File Manager
When you drag a file from one place to another in File Manager, it sometimes copies the file and it sometimes moves it.
Learn File Manager's defaults and how to override them.
* To copy a file from one drive to another, simply drag the filename. When files are dragged between drives, the default is to copy them.
* To move a file from one drive to another, press the Alt key and drag the file. Pressing the Alt key overrides the default.
* To move a file from one subdirectory to another, drag it. When files are dragged between subdirectories on the same drive, the default is to move them.
* To copy a file from one subdirectory to another, press the Ctrl key and drag the file. Pressing the Ctrl key overrides the default.
Double-time your printer
Windows' Print Manager lets you multitask while you're printing, but it slows down printing considerably.
Tell Windows not to use Print Manager.
1. Run Control Panel, found on the Main group.
2. Double-click on the Printers icon.
3. Uncheck the Use Print Manager box.
Automatically kill the clutter of Windows' temporary files
Windows (and many Windows applications) create temporary files. These files are erased when Windows terminates normally. But when Windows crashes, these files are left to clutter up your disk.
Automatically erase any temporary files in your TEMP directory each time AUTOEXEC.BAT runs.
1. Make sure you have the following two environment variables in your AUTOEXEC.BAT file: SET TEMP = C:/WINDOWS/TEMP SET TMP = C:/WINDOWS/TEMP
2. Near the end of your AUTOEXEC.BAT file, add the line
ECHO Y/ERASE C:/WINDOWS/TEMP/*.* >NUL
This will erase automatically any temp files remaining in your TEMP directory.
Display your name (or anything else) when Windows starts up
The Microsoft Windows startup screen gets boring pretty quickly.
Supply your own startup screen. (For this tip, you'll need WinGIF or some program that can save files in RLE format.)
1. Change the name of your WIN.COM file to WIN._OM.
2. Open Paintbrush and select Option, Image Attributes.
3. For Units, select Peles, and for Width and Height, choose 640 [unkeyable] 480.
4. Create your startup screen, try to keep it simple, and save it.
5. Run WinGIF, load your screen, and save it as an RLE image in your SYSTEM subdirectory.
6. Run DOS Prompt and change to your SYSTEM subdirectory.
7. Enter the following command: COPY/B WIN.CNF + VGALOGO.LGO +
MYLOGO.RLE WIN.COM where MYLOGO.RLE is the name of RLE image you created.
8. Copy your new WIN.COM file to your WINDOWS directory.
9. Exit Windows are rerun it. You'll see your new startup screen.
Change SysEdit's default files
SysEdit always looks for the same four system files, and it always looks on drive C. There's no option to change that.
Edit the SYSEDIT.EXE file with Write.
Let's say your system files reside on drive D (if you're using Stacker, for example), and you want SysEdit to load your CONFIG.SYS and AUTOEXEC.BAT files from the D drive.
1. Copy SYSEDIT.EXE (found in your SYSTEM subdirectory) to SYSEDIT._XE, so you'll have a backup.
2. Run Write, choose File, Open, and type in /SYSTEM/SYSEDIT.EXE.
3. When prompted, select No Conversion.
4. Perform a search for the string C:/CONFIG.SYS and change the drive letter C to a D.
5. Perform a search for C:/AUTOEXEC.BAT and change the drive letter C to a D.
6. Save the file.
Now SysEdit will load your CONFIG.SYS and AUTOEXEC.BAT files from drive D.
Use Help's Annotate feature to record your own notes
When you find a neat Windows shortcut or tip, it's difficult to know just where to store it.
Use Help's annotation feature to record your notes.
1. Open the help file for any application.
2. Select Edit, Annotate.
3. In the text window, type in your annotation and click on Save.
A paper clip appears on the page to remind you that you have an annotation.
Run a specific Recorder macro
Many times, you want to run one single macro in a Recorder file.
Use Recorder's hotkey switch.
1. Make sure your macro specifies a hotkey.
2. On the command line, put RECORDER -h hotkey filename.ext, where filename.ext is the name of the Recorder macro and hotkey is the key combination that normally runs the macro.
For the hotkey, use the following symbols, plus the key name.
As an example, if your hotkey is Shift-F10 and your macro file is named MYMACROS.REC, the command would be RECORDER -h +F10 MYMACROS.REC