Feb 1996 How-To Columns

Optimizing Windows

What's in a (Long File) Name?

by: John Woram

IT'S QUIZ TIME. Which statement is correct?

A) Windows 95 supports long filenames, which can contain up to 250 characters
(from Introducing Microsoft Windows 95, p. 16).

B) Maximum filename component length is 255 characters
(from Microsoft Windows 95 Resource Kit, p. 680).

C) An LFN may have up to 256 characters, including blank spaces
(from Supporting Microsoft Windows 95, Volume 1, p. 204).

Give up? I did, too. So I decided to go digging for the right answer. I started the dig shortly after Windows 95's introduction, when I discovered my old tape backup utility couldn't handle long filenames.

This month, I'll take a look at why the LFN (long filename) is a potential problem and show you what you can do to resolve it. The problem goes away when you upgrade to a Windows 95-aware utility, but it's helpful to know what's going on behind the scenes, if only to clear up any confusion. For instance, you may have read that Windows 95 is backward-compatible with the Windows 3.x file system, and that an extended MS-DOS File Allocation Table (FAT) file system supports its LFNs.

Initially, you may assume the FAT is extended, but there's no difference between an MS-DOS and a Windows 95 FAT. In fact, Microsoft uses "FAT file system" as a generic descriptor of the two-FATs-plus-directory structure found on any MS-DOS (and now, Windows 95) disk. The "extended" term refers not to the FAT, but to the directory structure only, which may now contain both the long filenames Windows 95 alone recognizes, and the conventional 8.3 filenames.

In order to maintain backward-compatibility, the Windows 95 directory follows the old MS-DOS format. A 16KB root directory has a maximum capacity--at 32 bytes per entry--of 512 entries. As before, each entry includes the eight-character filename, three-character extension, size, attributes and so on. So, how does Windows 95 squeeze its long filenames into that 32-byte space, and still find room for all the other stuff that needs to be there?

Simple: It doesn't. Instead, it writes a conventional MS-DOS style 32-byte directory entry, if necessary truncating a long filename to fit the usual 8.3 space. This entry is now known as the short, or 8.3-compliant, filename, and it always appears in uppercase letters, regardless of what you key in. In the default procedure, Windows picks up the first six characters of the LFN, followed by ~x, where ~x is 1, 2, 3 and so on, as required to differentiate various filenames that would otherwise begin with the same eight characters. If you have more than nine such files, the first five characters are followed by ~xx where ~xx is 10, 11, 12 and so on. If you have more than 99 such files, maybe it's time you took a break.

As for the LFN, it goes into additional 32-byte blocks written into the directory immediately above the just-described short filename entry. The first block begins with an 01 marker byte, followed by the filename's first 13 characters. The second block begins with 02 and the next 13 characters, and so on until the entire name is written, using the 2-byte Unicode character set instead of the conventional ASCII format. The 6 bytes remaining are for the block marker, attributes, type, checksum (one each) and the former cluster pointer (2 bytes). The bytes for the former cluster pointer are set to zero, because the actual pointer still resides in the short-name entry, where both DOS and Windows 95 can find it.

Let's back up a bit

As I mentioned earlier, pre-Windows 95 backup utilities didn't take kindly to long filenames. To verify this, close the Windows 95 GUI and go to DOS mode, or reboot into your previous DOS version. In either case, a directory listing will indicate all those nice long filenames are gone. Well, they're not really gone. It's just that these DOS versions don't recognize the unconventional directory entries, and so they're ignored. The same thing happens with those old backup utilities. Windows 95 reads the directory as though it were a conventional DOS 6.x directory, and ignores any block marked available. It also ignores unused blocks and blocks containing long filenames. As a result, it backs up each file with its short filename intact and its long filename gone.

As an interim solution, Windows 95 provides a long filename utility on the CD-ROM. Look for LFNBK.EXE in the Admin\Apptools\Lfnback folder. Note that this utility backs up long filenames, not the files themselves. Here's how it works.

LFNBK searches the directory for long filenames. If it finds one, it writes both the short and long filename into a database, whose own 8.3-compliant filename is LFNBK.DAT. It leaves the short name intact in the directory, but marks each long filename block available for use. In other words, the long filenames are gone (but not quite forgotten) and a pre-Windows 95 backup utility can now back up all the files, including LFNBK.DAT. After restoring the files later, execute the utility once again to restore the long filenames.

The utility's various switches are listed in the text file. To review them on screen, type LFNBK /?. The utility will automatically "fix" drive C: for you, unless you specify some other drive letter on the command line.

Although it's not necessary to run LFNBK if you use Windows 95's backup applet, some have described the latter as one of those not-quite-ready-for-prime-time add-ons. To minimize grief, you may want to use it just for full backups, and get one of the full-featured Windows 95 backups for more critical requirements. These started to appear a month or two after Windows 95 hit the shelves, and should be widely available by the time you read this.

The Windows 95 utility doesn't back up the Registry files, USER.DAT and SYSTEM.DAT, and for good reason. With any luck, you'll never need your backup tapes. But if your luck runs out, the last thing you'll want to do is restore old, and presumably outdated, .DAT files. There is, however, a configuration backup utility on the Windows 95 CD-ROM in the Other\Misc\Cfgback folder. The first time you execute it, CFGBACK.EXE creates two new files in your C: \Windows folder. The regback.ini file contains the name and creation date for up to nine registration backup files, and REGBACKx.rbk (x = 1-9) is the backed-up database. As a bit of Registry trivia, note the .INI file is written in lowercase characters, while the database is a mix of upper- and lowercase. Not so trivial is the fact that the utility backs up only the HKEY_LOCAL_MACHINE and HKEY_ USERS branches of the Registry tree. It doesn't back up the other branches because they change so frequently, often several times within a single Windows 95 session.

If you do want to back up the entire Registry, you can do it from within the Registry Editor. First, highlight My Computer in the Editor window, then select Registry/Export Registry File, enter a convenient filename and click on the Save button. To back up a single branch, highlight that branch instead of My Computer and then repeat these steps.

As a final Registry protection option, Windows 95 saves its own USER.DAT and SYSTEM.DAT backups every time it opens successfully. It saves both files with a .DA0 extension, so if the Registry is damaged later on, shut down Windows and type COPY *.DA0 *.DAT at the command prompt. The backed-up Registry files will overwrite the damaged versions, and Windows 95 should once again open as it did prior to whatever event damaged the Registry.

And the answer is ...

Two hundred fifty. If you forgot the question, go back to the beginning of the column. To verify this, copy any convenient file into the C: \ root folder and highlight it. Then open Explorer's File menu and select Rename. Type in 1234567890, but don't press Enter. Instead, highlight the complete string, press Ctrl+C to copy it and repeatedly press Crtl+V. You'll find you can paste in 25 strings, with a grand total of 250 characters. If you replace any character with a period, the characters following it become the extension, but the total length remains unchanged.

Now, try to copy the file into the C: \Windows folder. You'll get an error message that the filename is either invalid or too long. In this case it's invalid because it's too long. Turns out there's a further limitation--the path plus filename can't exceed 258 characters, as in C: \TEMP\250 characters here. Technically, the limit is 260 characters, but apparently you have to factor an invisible line feed and carriage return (or something) into the character count. So if you must squeeze this ultralong filename into the C: \Windows folder, you'll have to shave three characters from its name. Cut off another seven characters to copy it into the C: \Windows\System folder, and so on.

So, keep on reading those Microsoft manuals. There may be another pop quiz in a future column.

Senior Contributing Editor John Woram is the author of Windows Configuration Handbook (Random House, 1993). Contact John in the "Optimizing Windows" topic of WINDOWS Magazine's areas on America Online and CompuServe. To find his E-Mail ID Click Here

Dramatic Before and After Shots

This before-and-after directory listing shows how long
filenames get lost if the backup utility doesn't support LFNs.

Before Backup

UPPER SYS 12 02- 15-96 3:55p UPPER.SYS

LOWER SYS 12 02- 15-96 3:55p lower.sys

LONGFI~1 SYS 12 02- 15-96 3:55p LONG FILE NAME IN
UPPERCASE.SYS

LONGFI~2 SYS 12 02- 15-96 3:55p long file name in lowercase.sys
4 file(s) 48 bytes

After Restore

UPPER SYS 12 02- 15-96 3:55p UPPER.SYS

LOWER SYS 12 02- 15-96 3:55p LOWER.SYS

LONGFI~1 SYS 12 02- 15-96 3:55p LONGFI~1.SYS

LONGFI~2 SYS 12 02- 15-96 3:55p LONGFI~2.SYS

4 file(s) 48 bytes

Getting Started

Let Me Lend A Helping Hand

by: Jim Boyce

EVER HAVE ONE of those days when you need a helping hand with your PC, but you don't know where to turn? As a beginner, you're bound to run into both minor and major problems with Windows. This month I'll extend that helping hand.

One place you can always find me is online, either on America Online (Keyword: Winmag) or CompuServe (Go: Winmag). You can post your questions in these two areas' Getting Started sections, or you can chat with other readers, many of

whom are just as knowledgeable as we are. You'll also find back issues of the magazine, files to download and more.

If you're not a member of America Online or CompuServe, send your questions via the Internet to jboyce@cmp.com. I won't be able to answer every question, but I'll address the most common problems in this column.

And that brings me to this month's questions, which I culled recently from reader posts on CompuServe and America Online.

Q: I want to reformat my hard disk and start from scratch, reinstalling everything before I install Windows 95. I have compressed some of the disk space using DoubleSpace. When I try to reformat the hard disk, I get an error message stating I must use DoubleSpace. When I try to reformat drive C: in DoubleSpace, I get an error message that C: is a host drive and can't be formatted. It's a catch-22. How do I get around this?

A: DoubleSpace and DriveSpace are disk compression tools included with DOS 6.x that enable you to compress part of a hard disk, which allows the disk to hold more data. A compressed disk is really just a special type of hidden file on the host disk, which in your case is drive C: . The compressed disk shows up as drive D: or E: , depending on whether your system has any other hard disks or CD-ROM drives. Before you can format a host disk, you must remove the compressed disk. So, first make sure you don't need any files on either the compressed disk or the host disk. If you do need them, make sure you've backed them up. Once you remove the compressed disk and reformat the hard disk, those files will be gone forever unless you have backups.

Then use DoubleSpace's DOS version to delete the compressed volume. Exit to DOS, and enter DBLSPACE. When the DoubleSpace window appears, choose Advanced, then Delete, to delete the compressed drive.

After you've deleted the compressed volume, format the disk with the FORMAT command. Then, instead of reinstalling all your applications (which will require that you also reinstall Windows 3.x), install Windows 95. After you install Win95, you can reinstall your applications.

Q: I backed up some of my files using the Microsoft Backup program included with DOS and Windows 3.1. Now I've installed Windows 95, and its Backup program won't read my backups. What can I do?

A: If you have the CD version of Windows 95, you'll find a copy of Backup in the Other/Msdos/Msbackup folder. You can use this to restore files from your old backup disks. If you have the Windows 95 diskette version, which doesn't include these files, you can download the Backup program from www.microsoft.com. Or, contact Microsoft sales (800-426-9400, 206-882-8080) to order the CD-ROM Extras for Windows 95, a diskette set that contains all the extra files from the Windows 95 CD. The last option is the best, because you'll not only receive the Backup program, but also the CD's other goodies.

Q: I just bought a new PC with Windows 95 for my home office. I kept my old PC, which still has Windows for Workgroups on it. I want to hook up the two computers to share a printer. I don't know anything about networks, and a network is probably overkill, anyway. What's the best way to hook up the printer to both computers?

A: A network isn't overkill. Your new PC probably has a much larger hard drive than your old PC, so you can move some files and programs from your old PC to your new one to gain room on the old hard drive. And a simple network is a reasonably inexpensive way to share a printer between two computers, as long as you can also benefit by sharing hard drive space. Instead of describing how to set up the network, I'll give you an overview so you'll know whether you want to try it. Then you can discuss network hardware with your local computer dealer.

First, you'll need to install a network adapter in each PC. The network adapter is a card that fits in the PC just like your video card and other cards. For a small network, I recommend a 10Base2 (thin Ethernet) card. This connects the computers by coaxial cable similar to that used by cable TV. Because Windows for Workgroups and Windows 95 both have built-in network software, the two network cards and a cable are all you need, and it shouldn't cost more than about $125.

If you don't want to spend that much or don't have any use for disk sharing, the cheaper (and easier) alternative is to buy a printer sharing switch. The printer connects to the switch, and the switch connects to the two PCs. When you want to use the printer with a particular PC, you turn the switch accordingly. Or, for a few dollars more, you can buy a smart switch. This device senses which PC is trying to use the printer and gives it access automatically. Your local computer dealer should have the switch, or you can order one from almost any computer mail-order house.

Click Here to see a 21.8KB bitmap image of artwork which goes with this article, entitled:
What a Character!

Q: I'd like to include special characters in my documents, but I don't know how to type them. For instance, how do I enter a copyright symbol, em dash and so on? Do you press special keys to put them in the document?

A: Although you can enter special characters by pressing various key combinations, Windows' Character Map program gives you the easiest method of inserting them into a document. In Windows 3.x, Character Map is in the Accessories group. In Windows 95, choose Start/Programs/Accessories/Character Map to start the program.

The types of special characters you can insert depend on the font you're using. So first choose a font from the Font drop-down list. Character Map will change to show the special characters available. Double-click on the characters you want to use in your document. This places them in the Characters to Copy text box. Now, click on the Copy button to copy them to Clipboard. Switch to your document and choose Edit/Paste or press Ctrl+V to paste the characters from Clipboard to your document.

Here's a Character Map tip. Click on a character and hold down the mouse button in order to view an enlarged copy of the character.

Contributing Editor Jim Boyce is the author of Inside Windows 95 (New Riders Publishing, 1995). Contact Jim in the "Getting Started" topic of WINDOWS Magazine's areas on America Online and CompuServe. To find his E-Mail ID Click Here

Power Windows

Even Computers Make Mistakes

by: Karen Kenworthy

Click Here to see a 9.70KB bitmap image of artwork which goes with this article, entitled:
Party Error Detection

INSIDE YOUR PC, millions of electrical signals, traveling at nearly the speed of light, are sent and received every second. Every minute, bits by the billions flow among your computer's CPU, RAM, static RAM (SRAM), adapter cards and peripherals. The complexity of this traffic is beyond human comprehension.

Ever wonder what would happen if any of this data were somehow garbled during transmission? What would be the consequences if a single electrical pulse were relayed incorrectly?

It's no big deal if a pixel on your screen appears one imperceptible shade bluer than it should. A moment later, the pixel is redrawn as screen information changes, and the error disappears. But a one-bit error could just as easily change a $100 transaction to a $1 million one--or reduce it to zero. If either event happens while you're balancing your checkbook, it's a very big deal. Data errors can also make programs crash or behave erratically, and cause your computer to display almost any error message in its repertoire.

Trillions of error-free operations

Because the consequences of a data error can be so serious, you'd think computer designers would put a lot of work into preventing and detecting these errors. And they do. Modern computers are incredibly reliable, performing trillions of operations without a single mistake. And when an error does occur, systems are ready to handle it. Most critical signal paths within your computer employ error-detection circuits.

The most common form of data error detection is parity checking. This technique ensures the integrity of data stored on hard drives and floppy disks and sent via serial ports, and is often used to detect errors in RAM. Parity checking requires that each byte of data carry an extra bit, called the parity bit. The byte's original eight data bits determine the value of the extra bit whenever new data is stored.

For instance, if the number of 1s found in the original eight bits is odd (1, 3, 5 or 7), the parity bit will be set to 1. If an even number of 1s (0, 2, 4, 6 or 8) appears in the original eight bits, the parity bit will be set to 0. As a result, there is always an even number of 1s in the entire group of nine bits (eight data bits plus the parity bit). That's why this parity checking technique is called "even parity." Another technique, "odd parity," manipulates the parity bit to guarantee the number of 1s in a byte is always odd.

You've probably already figured out how the parity bit allows you to detect errors. If the value of a data bit changes--from 0 to 1, or 1 to 0--the value of the parity bit must change, too. If your computer encounters a byte with a parity bit whose value is inconsistent with those of the other eight bits, it knows an error has occurred.

Unfortunately, that's all your computer knows. One bit is in error, but your machine can't determine which of the byte's bits has changed. Simple even and odd parity checking can also be fooled if more than one bit changes value. If the net effect of the changes doesn't invalidate the parity bit's setting, your computer will trust corrupt data.

To make matters worse, parity checking can actually increase the number of data errors that occur. Parity checking requires 12.5 percent more bits to store and transmit a given amount of data. And the more bits and corresponding circuitry, wires and connectors, the greater the chance that something will go wrong. This, coupled with the fact that a computer can't recover from an error caught by simple parity checking, indicates this type of checking isn't worth the cost.

Thus the need for more elaborate error-detection schemes. All of them rely on more than one extra bit. Some schemes allow the computer to detect all errors involving 1 or 2 bits, and even correct single-bit errors by identifying the balky bit. Fancier techniques that require even more extra bits can detect and correct more extensive errors.

Unfortunately, all the extra bits make these error-detection and -correction methods expensive. For now, you'll find error-correction circuits only inside your hard drive and in the RAM circuits of certain very expensive computers. In an attempt to shave costs, manufacturers are removing even simple parity checking of RAM from many computer models. An extra 12.5 percent of RAM is enough to make a noticeable difference in a PC's final selling price.

Nobody's perfect

That unchecked RAM can cause a variety of problems. You might experience random program crashes, strange messages or images appearing on the screen or printed pages, or mysterious random hangs. If this sounds like an episode of This Is Your Life, here are several things you can do (all with the power off and your computer unplugged):

Try each of these suggestions one at a time until you've solved the problem.

Adapter card culprits

Adapter cards are responsible for a surprisingly large number of data errors. Besides being complex circuits in their own right, adapter cards act as a crossroad for many cables and plug into large sockets. Both factors are likely sources of data error.

In most cases, the data flowing to and from adapter cards isn't checked for errors. As a result, data miscues involving adapter cards often go undiagnosed for a long time. Symptoms include disk corruption and random program crashes, unreliable modem or printer connections, poor sound from your sound card, stray pixels on your screen and other bizarre behavior.

If one or more of these problems affects your computer, here are some steps that may help:

Handle the cards carefully, making sure they don't suffer damage from static electricity. And be sure to perform these steps only when your computer is off and unplugged. I don't want you to experience any high-voltage-induced data errors of your own!

Keep in Contact

Here are some ways to put the spark back in your system.

Electrical contacts occur when signal-carrying metal meets another piece of metal. In computers, these contacts include places where the edge of a SIMM meets the prongs of a SIMM socket, and where the pins of a chip meet the metal receptacles inside a chip socket. Other contacts occur where cords carrying electrical power plug into hard drives and other internal components; where cables connect to your drives and adapter cards; and where the edges of adapter cards meet those 8-, 16- and 32-bit card sockets along the back of your PC.

Normally, electrical signals jump from one metal surface to another without a hitch. But if a surface is dirty or corroded, the signal may become degraded. This can cause a number of problems, from intermittent data errors to the apparent failure of a drive, adapter card or chip.

If you suspect you're experiencing such a failure to communicate, there are ways to put the spark back in your system. First, clean the metal surfaces that meet at the corrupted contact point. The metal fingers on the edges of adapter cards and some hard drives are easy to clean. Just take a rubber eraser and gently "erase" the contact surface. The white synthetic erasers sold in art supply stores are best--they don't leave as many crumbs. Avoid very abrasive erasers, and be careful not to rub too hard or for too long. You want to remove the dirt and corrosion, not the metal underneath.

You can also clean many contacts with alcohol. Pure isopropyl alcohol is best because it doesn't leave a residue when it dries, but it's hard to find. Ordinary rubbing alcohol, the kind you find in any drugstore, will do in a pinch. If the contact surface is hard to reach or attached to your motherboard or a card, wet a cotton or foam swab and gently wipe the contact's surface. Repeat the procedure, using a new swab for each treatment, until the swab comes out clean. If you're cleaning cables or other contacts that you can remove from the computer, you may be able to rinse the contact with alcohol to remove large amounts of debris.

It's not always possible or prudent to clean a contact. For instance, the contacts inside adapter card sockets are hard to reach. And the risk of damaging chips by removing them from their sockets often outweighs the benefits of cleaning their contacts. But even when a contact bath is out of the question, there's still something you can do to improve a connection.

A small company named D.W. Electrochemicals (905-508-7500, fax 905-508-7502) has developed a remarkable liquid called Stabilant 22 that allows even dirty contacts to perform properly. Stabilant is an organic compound that allows electricity to flow where it should, but not where it shouldn't. For instance, within your computer, Stabilant enables signals to travel from one contact surface to another, but not between adjacent pins on a chip.

Stabilant is a great conductor

How does Stabilant pull off this trick? The explanation's a bit technical, but for the hard-core techies and terminally curious, here goes:

Normally, Stabilant is an insulator. But in the presence of a large electric field gradient, it becomes an excellent conductor. An electric field gradient is the "slope" of an electric field. It indicates to what degree voltage levels change over distance (voltage difference between two surfaces, divided by the distance between the surfaces). Within your computer, the distance between a pin and a socket is so small that the gradient is very large (on the order of thousands of volts per inch), causing the liquid to become a conductor. But the distance between adjacent pins is great enough to keep the gradient low (on the order of tens of volts per inch)--well below the level Stabilant needs to make the transition from insulator to conductor.

The diluted form of Stabilant 22, called Stabilant 22a, is best for most computer uses. Apply a drop to the pins of a chip while the chip is still in its socket, and the liquid will penetrate the contacts. Or use an eyedropper or swab to apply Stabilant to contacts inside adapter card sockets, cables, and drive power and cable connectors. You need only a single drop--just enough to cover the contact surfaces to a depth of 1 or 2 millimeters (about 4 to 8 hundredths of an inch).

Karen Kenworthy is a regular WINDOWS Magazine contributor. To find her E-Mail ID
Click Here


Copyright 1995 CMP Publications Inc.