Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline
Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Register and Manipulate Files in Whidbey
Visual Studio .NET 2005 offers better file and Registry handling, but there's still room for improvement.
by Josef Finsel

January 7, 2005

Technology Toolbox: VB.NET

Exchange Server 2003 features a BadMail folder where Exchange places undeliverable messages. This directory comes complete with a small warning flagged as important: "Items in this folder must be manually deleted. You should include regular maintenance of this folder in your administration policy."

ADVERTISEMENT

You could run a script to delete the e-mails in this folder, but if your system is small enough, you can scan and delete the e-mails without much fuss by opening the directory and looking at the files. The problem is that each e-mail creates three files, all with the same name but different extensions: BAD for the e-mail; BDR, which contains information about why the file was not deliverable; and BDP, which contains binary information related to the file. It isn't a big deal to open all the BAD files and take a quick look at them, but there is a better, simpler way.

Visual Studio 2005 (code-named Whidbey) lets you create a listbox that displays all the pending bad e-mail files and a textbox that displays the contents of the files. You can even add the ability to store the path to the BadMail directory so you don't need to enter it every time the program runs. This adds a little complexity to the program, but it's worth it because you end up with a module that simplifies working with the Registry. Download a working version of the app, including source code.

The Registry has long been a convenient place to store information for programs, but Visual Basic programmers have never really had easy ways to access it. For a long time, using the Registry effectively required using API calls—beasts that could be unforgiving if you made a mistake. This led many programmers to develop a BAS file with functions using those API calls that could be included in a project to make Registry calls easier. The good news is that Registry manipulation is much easier in Visual Studio 2005. The bad news is that it still isn't as easy as it could be. However, I'll show you how to build a module that includes all the tools you'll need to make Registry access easy.

The Registry is a database of information used to operate your computer. It consists of five hives, which correspond to tables in a database (see Table 1). Each hive can contain a large number of keys or subkeys. They behave similarly to the way folders and subfolders behave on the hard drive, an image reinforced by the way RegEdit displays the information.

Every key can contain either entries or more keys, with entries available as one of five types of information. For example, if you open up RegEdit (Start | Run | RegEdit), you'll find five folders that correspond to the five hives listed above. If you open HKEY_CURRENT_USER, then Software, then Microsoft, and finally Notepad, you'll find a list of values (see Figure 1). Notepad uses each of these values to display a text file.

As you can see in Figure 1, I've set the font for Notepad to Lucida Console. Every time Notepad starts up, it opens up \\HKEY_CURRENT_USER\Software\Microsoft\Notepad to read how all of the settings were when it was last closed. This keeps users from having to change these settings to their preferences manually every time they open up the application—exactly what you want to avoid with this utility.




Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home