September, 2001 - NT Internet Goodies

Andy Bruce

Last issue we went over free Web servers for Windows/NT. This issue, I'm doing more of a grab-bag of interesting and useful software I've come across over the past six months. I'll cover some generic system utilities as well as some quite useful C++ software I've used in my own projects.

C++ Portability Toolkits

In order to create an Internet Goodie, one must (of course!) use a programming language of some kind. C++ remains a popular language for both systems- and application-level programmers. C++ programmers need a good set of tools that allow them to take their Killer Apps and make them work on many different platforms without requiring a tremendous amount of research and development.

Although rapidly being supplanted in the corporate world by other, "friendlier" languages, C++ remains the lingua franca of the Open Systems computing world. However, many folks complain about the enormous learning curve required to build C++ programs successfully. The language design itself comes under criticism; for example, assume you want to do a case-insensitive compare on two string variables. On Windows you do something like:

#include <string.h>


char *str1 = "TEST" ;
char *str2 = "test" ;

// returns 0 if two strings are lexicographically equivalent 
int result = stricmp( str1, str2 ) ;

Unfortunately, the C++ language standard does not define this type of operation. Rather, string comparison (and lots of other functions) falls under the "vendor-specific" category. This means that on UNIX the above code doesn't work. Instead you must do something like:

#include <strings.h>

char *str1 = "TEST" ;
char *str2 = "test" ;

// returns 0 if two strings are lexicographically equivalent (most UNIX platforms)
int result = strcasecmp( str1, str2 ) ;

And, finally, if you're a Very Smart Programmer, you might end up with something like this:

#include <string.h>		// applies to all platforms
#ifndef _Windows
#	include <strings.h>	// applies to non-windows platforms only
#endif

// handle case-insensitive comparisons
#ifdef	_Windows
#	define MY_STRICMP	stricmp
#else
#	define	MY_STRICMP	strcasecmp
#endif

char *str1 = "TEST" ;
char *str2 = "test" ;

// returns 0 if two strings are lexicographically equivalent
int result = MY_STRICMP( str1, str2 ) ;

Now, string comparisons fall under the genre of "basic operations," and you can see the amount of work (and knowledge) required for programming them correctly in source code. Just imagine the complexity of doing something difficult—say, network programming (which can have completely different models for Windows and UNIX) or multithreaded development (which does have different function calls on every operating system).

This type of development difficulty created the market for the C++ third-party portability library. A good portability library can turn a six-month job into a two-week job. C++ programmers tend to get rather emotional about their toolkit(s) of choice. (Sample conversation: "The FooBar toolkit rules!" "No, it doesn't, the BarFoo toolkit is what real programmers use; FooBar is for idiots!" "You're both idiots; even marginally sentient beings realize that the FooBarFoo toolkit is the only possible solution" ...)

The Internet gives you a wealth of toolkits from which to choose. I'll cover just a few of them here, but even more are just a simple Web search away from you.

Standard Function Library (freeware, http://www.imatix.com/html/sfl/sfl1.htm). This library (not to be confused with the Standard Template Library!) offers a wealth of functions that every C developer can find useful. While I don't use the library myself, I do use (and have covered in prior columns) the Xitami Web server from iMatix. I'm quite happy with the quality of the software from this fine development shop, and feel comfortable recommending it to any developer.

Simple Multi-Threading Kernel (freeware, http://www.imatix.com/html/smt/index.htm). This, another useful utility library from iMatix, makes it easier to develop multithreaded applications. It requires the use of the Standard Function Library above, as well as another iMatix tool called Libero (which iMatix used to develope their free Web server). Given the high success of the Xitami Web server from iMatix, I don't think you can go wrong by using this particular library.

Standard Template Library (SGI) (freeware, http://www.sgi.com/tech/stl/). The Standard Template Library (STL) is the name for a common set of object-oriented functions that most (all?) C++ compilers support. The STL attempts to provide a workable framework of useful "objects" (see sidebar) that allow developers to concentrate on providing functionality in their applications. One reason for choosing to use a specific implementation of STL (such as the SGI version of it) is that each compiler has its own unique "flavor" of STL support. This can and does lead to subtle programming errors. By using a specific STL implementation, programmers can feel reasonably confident that calls to the same function will work the same, regardless of the platform. SGI provides a robust, world-class product you can feel confident in using in your own software.

You can also get a nice introduction to the STL at http://www.sgi.com/tech/stl/stl_introduction.html.

Standard Template Library (STLport) (freeware, http://www.stlport.org/). I used this implementation of STL in a large commercial application myself, so I can speak from experience here. I'm quite impressed with this particular STL package, and have had quite a bit of interaction with the folks behind the scenes (they make their money by providing consultation/support for the package). I especially like the debugging features "built-in" to the library. (Unfortunately, I've needed to use these features to find problems in the product more than I'd care to admit!) I also appreciate the ease of use on both Windows and non-Windows platforms (I believe it even works on MVS!). I can't recommend this package enough—in fact, we went to it specifically because of problems we found in the GNU compiler's implementation of the STL.

Free GUI (Graphical User Interface) Toolkits (freeware and others, http://www.geocities.com/SiliconValley/Vista/7184/guitool.html). Unfortunately, most applications do require a GUI front-end. (I speak as a back-office, hard-core command-line-oriented Hacker Dude; I've yet to meet a GUI I like!) While I try to ignore this inconvenient fact, other programmers appear to enjoy interacting with human beings rather than providing interfaces for programmers, machines, and other reasonable entities. The Web site listed above should give you a good choice of freeware for your own applications.

Various Free Toolkits (freeware and others, http://www.faqs.org/faqs/C++-faq/libraries/part1/). I've gotten a lot of use from this particular toolkit page; I appreciated the Game Programming library provided at http://photoneffect.com/. (I used this library when I dabbled with computer gaming for an instructional course I wrote for McGraw-Hill.) It includes source code and lots of examples; in fact, it'd make a great column in and of itself. Unfortunately, that's probably too off-topic for me to get away with :-(.

Interesting System Utilities

Everyone needs a good set of system utilities for their computer! Let me share some of the interesting Web sites and tools I collected over the last few months.

Encryption/File Wiper Utility (free for personal use, http://www.jetico.sci.fi/index.htm#/bcwipe.htm). This interesting little toolkit allows you to feel confident that your critical information remains protected. Also, you ensure that sensitive data truly gets deleted from your hard disk. The encryption utility works by creating a "virtual" hard disk on your computer that you can use to store data. This virtual disk is just a disk file, so you can back it up, move it to another computer, and so on. However, the virtual disk appears as a drive letter on your computer, so you can use it as you would any other drive. You get real power from this approach once you start dragging and dropping files onto the drive—no muss, no fuss!

The File Wiper utility extends the standard Windows Explorer Shell with a new command: "Delete with wiping." This does exactly what you would expect it to do. The File Wiper extension also allows you to wipe the free space on your hard disk. I've used this, and apart from the rather lengthy time involved in performing the wipe (I have some BIG partitions on my computer!) it works quite well.

Free System Tools from SysInternals (freeware, http://www.sysinternals.com/ntw2k/utilities.shtml). Use this site to find loads of free utilities that make it easier to manage your NT boxes. I don't cover all of them, since many I haven't used, and many others I plain disapprove of. (Some that come to mind are the utilities supporting dual-booting between NT and 95, or between NT 4 and Windows 2000. I just plain don't like dual-booting! I say, "Make up your mind which you want, or scrounge up another computer and a couple of cables!") However, I found enough interesting and highly useful tools on this page to make it well worth your while to peruse the rest of this column ;-)

CPUMon, http://www.sysinternals.com/ntw2k/freeware/cpumon.shtml. Have you ever wondered just what your CPU is doing behind your back—for example how many misaligned instructions got executed? Then this tool is for you! While a little unusual, and requiring somewhat of an intuitive leap to use effectively with the built-in Perfmon tool, you can find out loads of internal info on your processor.

DebugView, http://www.sysinternals.com/ntw2k/freeware/debugview.shtml. Wow! What an interesting and useful tool for developers! When writing low-level applications (such as device drivers), you troubleshoot problems by writing "system-level" debug messages. However, to see the debug messages from your low-level application, you must have the "debugging" version of the NT operating system installed! Hmmm, I see a problem here. Some errors simply don't show up until your program runs underneath the non-debug version of the OS. Net effect: you don't see your debug messages when you need them most. This tool rectifies that deficiency. It intercepts system-level debugging messages and allows you to keep track of what your application is doing.

DiskMon, http://www.sysinternals.com/ntw2k/freeware/diskmon.shtml. I really like this utility, primarily because it gives me a visual clue on the taskbar when disk activity occurs. (In fact, the only thing I don't like is the fact that it only shows disk activity in red, which to me indicates an error!) The small size and very detailed disk read/write information makes this utility a must for many different levels of developers.

Handle, http://www.sysinternals.com/ntw2k/freeware/handle.shtml. This updated program has proven itself invaluable to me. As a back-office developer, any type of memory or resource leak (such as socket handles or file handles) interests me strangely. The "Handle" program mentioned here tracks down at least part of this problem, since it lists the open file handles for a given process (or all processes). I've used this tool to debug a problem in my own applications, so it has a special significance for me.

PortMon, http://www.sysinternals.com/ntw2k/freeware/portmon.shtml. This interesting utility serves as a "poor man's packet sniffer" for your printer. It basically looks at all the traffic on the serial/parallel ports on your computer (or a remote computer!). Thus, you can use it to help debug printing problems or basic communication problems. Too bad it won't monitor your communication ports as well!

Contig, http://www.sysinternals.com/ntw2k/freeware/contig.shtml. While Windows/2000 comes with a built-in defragmenter tool, you can download this (tiny!) binary to defragment files on your Windows/NT system. It runs only in command-line mode, so that if you want drag'n'drop functionality you must do a little work yourself. (For example, you can write a small script file that invokes the program, and then store the script file as a shortcut on your desktop.)

PageDefrag, http://www.sysinternals.com/ntw2k/freeware/pagedefrag.shtml. As far as I know, this is the only tool available that allows you to manage the fragmentation of your registry "hives" (the registry data files) or the system paging files. By using the registry portion of this tool in conjunction with a good registry pruner, I achieved a measurable performance improvement in accessing/updating registry entries. (Believe it or not, I wrote a program to do generic, thorough registry access to prove this, which goes to show I've got waay too much time on my hands!)

BlueSave, http://www.sysinternals.com/ntw2k/freeware/bluesave.shtml. This extremely useful application allows you to save the information from the Windows BSOD ("Blue Screen Of Death") so that you don't have to write down the information for your system administrator. Unfortunately, SysInternals provides only a trial evaluation version of this application, good for capturing three BSOD images. In spite of this, you should download the application; perhaps even consider buying the full version. (I know, I know—why use the Internet if you have to pay for stuff??)

NTRecover, http://www.sysinternals.com/ntw2k/freeware/ntrecover.shtml. This great tool allows an NT administrator to recover a "dead" remote system by means of a serial cable. It works by first requiring you to boot the "dead" system from a floppy disk directly to the NTRecover program. You then connect the "host" (working) system to the dead system by using a serial cable. You can then see the drives from the dead system as logical partitions on the working system. The freeware version allows you to read data from the dead system, which means you can recover all the files you need prior to a reformat or a disk replacement. A fantastic tool!

Locksmith, http://www.winternals.com/products/repairandrecovery/0locksmith.asp. While not a freeware application, you can download and try this application. Its claim to fame is that by using this tool in conjunction with the NTRecover tool above, you can get into any Windows/NT box. While this sounds to me more like a security hole than a great feature, there's no denying that if you've forgotten the Administrator password, such a tool is worth its weight in gold!

RemoteRecover, http://www.sysinternals.com/ntw2k/freeware/remoterecover.shtml. Another tool to recover a "dead" system—this time over a TCP/IP connection. You boot the dead system from a floppy to the RemoteRecover utility (as with NTRecover above). Then you can access the dead system from the "host" (working) system via a TCP/IP connection. I can't offer a better review since I haven't tried this product myself.

And, finally,

BlueScreen Screen Saver, http://www.sysinternals.com/ntw2k/freeware/bluescreensaver.shtml. A little joke here—this screen saver emulates a BSOD (Blue Screen of Death) exactly, even down to the reboot! Use it to shock your less-than-desired coworkers into applying for a transfer to a different department. With any luck (and frequent applications of funny gags like these to their computer systems, preferably during product demos), the targets of your mirth may well remove themselves to a completely different company!

Andy Bruce has been writing software for various operating systems and assorted languages for more than 12 years. He is a primary author of several shrink-wrap products, including Landmark Systems' PerformanceWorks suite and Savant Corporation's Q for Oracle. He also has written many courses in computer programming for McGraw-Hill NRI. He lives and works in the Washington, D.C. area.

</html