This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
|
Windows 2000 for Web Developers Dino Esposito |
Our resident Cutting Edge columnist puts a beta of Windows 2000 through its paces and lives to write about it.
Editor's note:
This article is based on the beta 2 release of Windows 2000. As this article went to press, it was learned that beta 2 would no longer be available after February 15. The next beta release of Windows 2000 is expected in the Spring of 1999.
I've been a loyal fan of the Microsoft® Windows® 9x family of operating systems, but I've never found the same level of comfort and ease of use under Windows NT®. I regularly install up-to-date copies of Windows NT, but up until now, I've only used it to test my software. That was then. I've started to use a beta version of Windows 2000 (formerly known as Windows NT 5.0), and it's so full of features that anyonesystem administrators, system engineers, programmers, managers, and, of course, plain old userscan find good reasons to use it. Windows 2000 features both improved Web browser software (Microsoft Internet Explorer 5.0) and Web services such as Microsoft Internet Information Services (IIS) 5.0. Next month, MIND will preview IIS in depth; Cutting Edge will concentrate on various new browser features in the months to come. Let's go over what's new and useful in Windows 2000 for each category of user. Remember this is a beta version and features discussed here may change in the final release. System Administrators Being a system administrator means that you have to manage users' rights and permissions, define and apply policies, distribute the resources among users in a balanced way, and configure the system directories. This often gets repetitive and boring. Windows 2000 comes with significant improvements to reduce the drudgery: Active Directory Services (ADS), group policies, disk quotas, systemwide scripting capabilities, and a new task scheduler. ADS let you manage shared and choice objects distributed across any kind of network. Here, "directory" refers to a shareable information source that people might want to access, such as printers, faxes, databases, folders, and even apps. One of the system administrator's tasks is managing how these objects can be used. A directory service is the module that makes directories available to the clients. If a directory service is compliant with the Windows 2000 Active Directory specifications, it's considered to be an ADS. ADS virtualizes the physical distribution and the physical structure of the shared objects published on a network. Likewise, the Virtual Memory Manager (a standard Windows component) lets your programs address up to 4GB of memory space even if you installed only 32MB of physical RAM. The various ADS components let you see printers, faxes, OCRs, and so on as logical groups on the network. For example, an ADS can show you printers that are located in different rooms as part of the same node. This kind of abstraction brings a number of advantages to system administrators. First and foremost, an ADS lets you set privileges and visibility flags over a group of resources. This allows you to enforce security and control who's accessing a given resource. With ADS, you can also implement a user-friendly search engine to help anyone find an object more easily, even without specifying technicalities like the names of printers or their servers. Another good feature is replication. Because ADS provides a logical view of the hardware, applications can continue working even if a directory server is temporarily replaced for maintenance. Under Windows NT, each group of users needed its own settings and desktop configuration. By applying policies, you could mandate registry settings, force startup and shutdown scripts, and decide which applications would be available and which apps would appear on the desktop to groups of users. Windows 2000 provides an integrated tool for accomplishing these tasks more comfortably. The Group Policy Editor, which comes as a Microsoft Management Console (MMC) snap-in module. Figure 1 shows the Group Policy Editor in action, along with all the other system tools. Disk quotas are another cool feature that will make administrators happy. The idea is simple: you can assign a maximum amount of disk space to each user and be notified when he or she exceeds an intermediate warning level. |
Figure 1: The Group Policy Editor |
Figure 2 shows the property page that allows you to define disk quotas. All of this is transparent to users, who are simply shown a filtered value for their free disk space. Even if the disk is 10GB, you can have each user see and occupy no more than 1GB. This is similar to what ISPs do when they parcel out Web space for home pages. You pay for a certain amount of space and can't take up more. (Windows 2000 disk quotas, however, are free!)
Figure 2: Defining Disk Quotas |
Disk quotas are a file system feature, and are based on the logical sizes of files. In other words, the system sums the sizes of all the files you've created to determine if you've exceeded the limit. It doesn't matter if a file is compressed and occupies less physical space. Note that disk quotas are supported only on NTFS volumes.
System administrators often have to execute batch operations or schedule repetitive tasks. But old-fashioned MS-DOS® .bat files are not powerful enough to drive operations on modern graphical operating systems. The Windows Scripting Host, which I covered in the June and December 1998 issues of MIND, is much more suitable for these purposes. Windows Scripting Host is not the only script-based feature of Windows 2000. Another feature, ScriptIt, is not a traditional scripting language and it doesn't offer many of the typical language constructs, but it could be useful for starting a process and sending a set of keystrokes to active windows.
Figure 3: The Task Scheduler Wizard |
Figure 3 shows the new task scheduler wizard, which looks much the same as the one in Windows 98. The bare functionality is nothing new, but the UI is a great step forward.
Windows 2000 doesn't introduce new tasks for system administrators, nor does it eliminate others. Instead, it gives administrators new and far more powerful tools.
System Engineers
System engineers are normally involved in design decisions that affect the file system, device drivers, and networking. A great number of changes are being introduced to NTFS, the Windows 2000 preferred file system format. I'm going to touch on all of them, but for more in-depth information I recommend that you look at the article, "A File System for the 21st Century: Previewing the Windows NT 5.0 File System" (Microsoft Systems Journal, November 1998).
NTFS can be invaluable when you design applications that need to get the most out of the system. With NTFS volumes (which, unfortunately, are unavailable to Windows 95 or Windows 98), you can take advantage of hard links, streams, and automatically encrypted files.
Figure 4: Setting Encryption Flags |
Windows 2000 uses the CryptoAPI to protect your data using the Encrypted File System (EFS) of NTFS. You can set the encryption flag on a single file or an entire folder, as shown in Figure 4. This process takes place behind the scenes and adds minimal overhead. While it doesn't prevent other unauthorized users from seeing your files, they still can't work with and understand them because the system doesn't decrypt the files for them. Figure 5 shows a message that may appear if another user tries to open a file.
Figure 5: Alert Box |
I explained how to exploit CryptoAPI to silently encrypt and decrypt document files yourself from within an MFC application in my article, "Supporting CryptoAPI in Real-World Applications" in the June 1997 issue of MIND. In a nutshell, you derive your document class from the supplied CCryptoDoc class instead of CDocument and have the framework encrypt and decrypt the file for you while calling the standard Open and Save document's methods. This is the same sort of thing NTFS does for you.
If you've ever been asked to figure out an efficient and effective way to store the data managed by a program, chances are that you ended up considering OLE compound files. In its simplest form, an OLE compound file is a structured file whose contents are articulated in terms of storages and streams. Typical examples are Microsoft Excel or Word documents. The stored information is partitioned into folders and subfolders called storages. Each chunk of data contained in a storage is called a stream.
A couple of features in the NTFS file system could affect the way you design the storage of your documents and applications. Under NTFS, each file can be seen as a collection of streams. What is normally perceived as the file is only the contents of the main, unnamed stream. In practice, you can store a number of subfiles inside a single file entity and still be able to retrieve them in the original format. For example, I worked on an image data bank whose elementary items were multiresolution images composed of up to four different sizes: thumbnail, 500, 1000, and 2000 dpi. I wrote my own API to deal with this file format. A Windows 2000-based machine and NTFS stream-aware software would have helped considerably.
Windows 95 brought us the notion of shortcuts. A shortcut works at the application level to mirror a given file object. You can have multiple copies of the same shortcut in different directories and different drives addressing the same physical file. Now think of how file system-level shortcuts would work.
In Windows 2000, these shortcuts are called hard links. Hard links are unlike shell shortcuts. Shortcuts are files that point to other files, while hard links are multiple directory entries for the same file or directory. By creating a hard link, you ask the system to create a virtual shortcut to a file. Note that hard links must be on the same NTFS volume. The virtual shortcut, of course, is a metaphor to indicate a little data structure that links a physical file with multiple locations. For example, by creating hard links to a shared DLL you can make it visible to all the applications that need it without copying anything in the Windows folder. For compound files and streams, you could also use the AppPaths key in the HKLM registry node, but this solution works at the application level, while hard links are a system feature.
Figure 6 shows the world's simplest ATL COM object that exposes a method to create hard links. Figure 7 shows a little Windows Scripting Host script that uses it. Notice how some of the Windows 2000 features mentioned earlier work together. Hard links exist only in Windows 2000, so in your code you need to explicitly indicate the target platform to link against the right libraries:
#define _WIN32_WINNT 0x0500
ATL puts a similar directive in the stdafx.h file. All you have to do is plug in the correct version number. Once created, hard links work as independent directory entries to the same file, so you can rename and delete them separately without affecting the others.
Another fundamental improvement in Windows 2000 is plug and play. It represents a dramatic evolution over the original plug and play implemented in Windows 95. In general, plug and play is the result of the interaction between BIOS, hardware, device drivers, and the operating system. With Windows 2000 there's a new specification called Advanced Configuration and Power Interface (ACPI), which defines the interface that system boards and BIOS must provide to successfully communicate with the OS. ACPI replaces Windows 95 Advanced Power Management (APM) with a more abstract interface that's independent of the actual CPU. Windows 2000 still supports APM and pre-APM hardware.
The uniform Win32® Driver Model outlines the binary structure of drivers that include support for plug and play and power management, and that are configurable by the OS. Of course, these drivers aren't the only supported type. Windows 2000 still accepts existing kernel-mode drivers, but they can't provide plug and play and power management features. Win32 Driver Model drivers can be employed on both Windows 2000 and Windows 98.
Programmers
For programmers, Windows 2000 is not as revolutionary as Windows 95 was, but it still serves up lots of changes. There are new APIs, entirely new or completely revised SDKs, and a new basic technology: COM+.
This, of course, is a topic worthy of an article (or a book) in itself, so I'll attempt to isolate the most important aspects. I'll skip over all of the enhancements already available under Windows NT 4.0 and Windows 9x through the Active Desktop shell update. Details and lots of useful examples about this can be found in my book, Professional Visual C++ Windows Shell Programming (Wrox, 1998).
Some of the new SDKs, products, and technologies you can find in Windows 2000 are summarized in Figure 8. This is by no means an exhaustive list, but it should give you a reasonable idea of what's new in Windows 2000. Figure 8 also includes some new API functions.
Among the new technologies, TAPI 3.0 deserves special mention. TAPI 3.0 provides its telephony services through COM interfaces instead of API calls, so you should consider TAPI 3.0 as a completely new set of functionality. Microsoft is still committed to supporting the old 2.1 API. COM interfaces, media stream access through DirectShow, and Active Directory integration are the highlights of this new edition of the telephony API. Also interesting is the group of functions that lets you manage jobs. A job object is a collection of processes that are seen as a single unit. The processes share the same settings such as priority, security, user interface restrictions, and the like.
The Zero Administration for Windows program, intended to reduce the total cost of ownership of a large Windows-based enterprise system, is embodied in the new Windows Installer. The Windows Installer exposes a revolutionary set of functions that lets you write applications capable of just-in-time installation across a network. An application based on the Windows Installer can detect missing or corrupted files and automatically download them from the Web or a CD-ROM. Taking this concept to the limit, you can create applications that install themselves only when actually invoked for the first time by the user.
Snooping around among the new and improved API functions, I noticed AllowSetForegroundWindow. This function helps developers repair the side effects caused by a somewhat sudden change in the behavior of an old Win32 function, SetForegroundWindow. Many developers used SetForegroundWindow to put their window on top of other windows. But with Windows 98 and Windows 2000, unless the window in question belongs to the active process, it is no longer restored and simply flashes on the taskbar. Processes can no longer steal the input focus of another process. The new AllowSetForegroundWindow lets you explicitly restore things to the way they worked in Windows 95 and Windows NT 4.0. Unfortunately, this function isn't supported in Windows 98, and figuring out a workaround is not that trivial.
Two long-awaited functions have appeared: ReplaceFile and GetLongPathName. ReplaceFile replaces an existing file with another one, while GetLongPathName returns the long name of a path given its 8.3 representation.
On the shell side, you'll see a wave of new COM interfaces that are the second or the third version of existing ones. IPersistFolder2, IPersistFolder3, IShellView2, IShellFolder2, and IShellChangeNotify add new functionality to the shell and affect the way you write namespace extensions. They make it easier to provide Web views of folders. Another new interface, ICommDlgBrowser2, is supposed to make it possible for a namespace extension to be actively hosted in the common dialogs. However, the File Open dialog itself underwent a dramatic change that is completely transparent to applications. Under Windows 2000, the GetOpenFileName function produces a completely new and cool dialog like the one in Figure 9. Notice that it is resizable.
For developers, COM+ is the most important feature of the Windows 2000 family of operating systems. While thorough coverage here is impossible, I'll provide a brief summary. For a quick overview of COM+, refer to Steve Zimmerman's Extreme C++ column in the May 1998 issue of MIND, and also have a look at the help file in the Windows 2000 beta 2 CD.
Figure 9: The New File Open Dialog |
COM+ is the next step in the evolution of COM. One of the factors that resulted in its development was the advent of Microsoft Transaction Service (MTS), a component of Windows NT Server. Among other things, MTS introduced the idea that many tasks that developers take care of could be accomplished more effectively by the system. Thus, COM+ handles thread allocation and security, object pooling, and just-in-time activation. In addition, it provides a runtime service to make available default implementations of the most common interfaces.
Managers
For managers, the good news about Windows 2000 is that it is a family of products. Windows 2000 was intended to be an operating system with four flavors: Professional, Server, Advanced Server, and Datacenter Server. Windows 2000 Professional looks like Windows 98, but retains the typical robustness of Windows NT. In other words, it adds to Windows NT what people liked most about Windows 98. The Windows 2000 Server family scales up to meet a corporation's needs. The basic version supports two-way symmetric multiprocessing (SMP). Advanced Server (formerly known as Enterprise Edition) supports four-way SMP. Datacenter Server, a brand new product, will support 16-way SMP and up to 64GB of physical memory.
Two other specifications contribute to making managers happier: the Windows DNA (Distributed InterNet Applications) and the Windows Logo spec for developing applications for Windows 2000. Windows 2000 includes a large number of DNA componentsMTS, Microsoft Message Queue Service, Microsoft Internet Information Service, and Index Service are included services in Windows 2000.
The Microsoft Windows Logo specification identifies a set of technical criteria for writing reliable and manageable Windows applications. Software products that wear the Windows logo have been tested by an independent lab to confirm compliance with this specification. The ultimate goal of the Logo program is to improve the quality of the Windows experience for customers by ensuring that applications interoperate properly with Windows. Customers can search among all logo products at www.microsoft.com/windows/compatible.
Microsoft is significantly updating the specification for the Windows 2000 operating systems. The Windows 2000 Logo program distinguishes between two levels of adherence: basic tier and gold tier. The basic logo identifies products that run properly under Windows, install properly, and interoperate well with other programs. The gold logo identifies applications that exploit new Windows 2000 features to reduce total cost of ownership for customers. Gold logo applications are IntelliMirror enabled, run in a secure Windows environment, and make proper use of the new ACPI power management.
The full specification (still in draft form) is available at http://msdn.microsoft.com/winlogo/default.asp. You might also look at http://www.veritest.com/mslogos/windows2000/index.htm, where you'll find a description of the most frequent causes of test failure.
Joe Users
I installed the Windows 2000 Professional beta over an existing copy of Windows NT 4.0. The entire process was fast and completed seamlessly. Interestingly, all the settings were maintained and the configuration data was inherited. Thus, I had no need to recreate the network connections in the Dial-Up folder, nor did I need to reinstall applications to synchronize the registry.
The coolest feature is undoubtedly plug and play. I bought a new machine and attached an existing hard disk with two boot options: Windows NT 4.0 and Windows 98. Both went crazy with all that new hardwaredisplay and network adapters, various controllers, CD-ROM, CD-R, a secondary hard disk, a sound card, and a modem. After a dozen reboots, all was fine with Windows 98. However, I needed to completely reinstall Windows NT 4.0, and it still wasn't able to see the modem due to port problems. After all this work, I put Windows 2000 on top of Windows NT 4.0. Once it finished copying files, it rebooted, and voilą, the sound card and modem were correctly detected.
Figure 10: Found New Hardware |
Under Windows NT, a dialog like the one in Figure 10 is really a feast for the eyes! Furthermore, Windows 2000 comes with its own New Hardware Wizard (see Figure 11) to scan the PC, searching for devices, plug and play or otherwise. Another great piece of news is that Windows 2000 recognizes FAT32 volumes. It elegantly solved the problem of having an existing secondary FAT32 hard disk used to store global data across the two boots.
Figure 11: Found New Hardware Wizard |
The overall user interface of Windows 2000 has been improved. There's a noticeable improvement in the shell internals, since the shell appeared to respond more quickly to custom shell and namespace extension setups. The Find dialog is integrated in the browser's frame as a new Explorer desk bar where it's been renamed Search (see Figure 12). A couple of new dialogs show off the Favorites menu: Manage Offline Pages and Organize. Manage Offline Pages lets you maintain a collection of pages that can be synchronized and updated, then browsed offline.
Figure 12: The Search Explorer Bar |
The whole process can be seen as a specialized, Web-oriented version of the Briefcase. Figure 13 shows the way tools are available to help you organize your favorite links. In general (at least in the beta 2 version) I noticed a mix of Dynamic HTML and traditional form-based dialogs in the UI. While you can get the same level of expression with HTML, it can rarely be obtained with common controls.
Figure 13: Organize Favorites |
Conclusion
Figure 14 shows information about the IRQs used by the installed devices. It shows a pretty cool user interface (an MMC snap-in) and presents hardware information in a pleasant and readable manner. Windows 2000 really helped me get out of the usual setup troubles you run into when you buy a new machine or combine new and existing hardware. My personal top five favorite features are, in order of preference: plug and play, NTFS enhancements, the UI of setup dialogs, the integration with some BackOffice® components, and Internet Explorer 5.0.
Figure 14: IRQs for Installed Devices |
Of course, Windows 2000 Professional Workstation beta 2 is still incomplete. For example, icons often lose their colors and the Internet Connection Wizard doesn't finalize the process of creating new accounts. To get my email, I needed to import the necessary registry settings from Windows 98. Overall, however, Windows 2000 is an excellent development platform for client workstations as well as server machines. Try it out!
From the March 1999 issue of Microsoft Internet Developer.