Stealing Your Own Resources

To really understand exactly where resources come from, try looking at TRES­.EXE. You already know where those resources came from, but WinWatch gives you a little different view. Figure 8-3 shows WinWatch looking at the resources in TRES.EXE.

The Resources list box shows the same resource ID numbers and types we defined in TRES.RC. If you select one of these, you’ll see the resource displayed or described in the Resource Information area. WinWatch displays bitmaps and icons, plays sounds, and loads cursors. It simply dumps data (such as OURDATA) that it doesn’t know about. You can enhance WinWatch and your own programs to handle new data types correctly.

Figure 8-3. WinWatch looking at TRES.EXE.

There are some quirks in the display that I can’t explain. WinWatch can’t display many of the resources it finds, and therefore I’ve given it a Filter Resources check box. With the check box checked (the default), resources are validated as they are found. If you uncheck this box, you’ll see a lot more resources listed, but you won’t be able to examine them. Why not? I don’t know.

TRES.EXE also has a group icon with ID #1. When you select this resource in Win­Watch, you’ll recognize it as the standard form icon. If you set the Icon property of the main form in the Test Resources program to a different icon at design time and then recompile, this icon will change. The Test Resources program doesn’t bother to set the Icon property at design time because it uses Load­ResPicture to set the country-specific icon at run time. Unfortunately, it’s the embedded icon with ID #1 that the operating system displays when you press Alt+Tab to change programs or when you inspect processes with the Windows NT task manager. It would be nice if you could set this resource to a country-specific icon in the resource script, but unfortunately Visual Basic provides no means to do so. Why not? I don’t know.

If you browse through the resources in other programs, you’ll notice some patterns. Turn off the Filter Resources check box so that you’ll see everything, useful or not. Resources with type GROUP_ICON or GROUP_CURSOR are usually listed, but those with type ICON or CURSOR are not. What’s the difference? I don’t know.

Another interesting quirk is that when you look at the resources of the WinWatch program, you’ll get different results depending on whether you’re running WINWATCH.EXE or WINWATCH.VBP. WinWatch doesn’t really need any resources, but to make this difference more obvious, I’ve given it the same resource file described earlier for the Test Resources program: TRES.RES. When you run WINWATCH.EXE, you’ll be able to see these resources. But if you run WinWatch in the Visual Basic IDE, you’ll see a different list of resources. That’s because as far as Windows is concerned, you’re running VB5.EXE, not WinWatch, and you’ll see Visual Basic’s resources.