As you can see from my custom graphic in Screen 8 (under Name and to the
left of HP Printer 1), I'm not much of an artist. Fortunately, VC++ makes it
easy to borrow from existing graphics so you don't have to create bitmaps and
icons from scratch. Let's start by swiping some graphics from NT's surplus of
neat icons and bitmaps.
- Assuming VC++ is running and the SMSCust project is open with Screen 9
(page 149) showing, select File, Open from the VC++ me
- In the Open dialog box, select Executable Files (*.exe,*.dll,*.ocx) in
the Files of Type drop-down list box, and choose Resources in the Open As
drop-down list box.
- Navigate the Open dialog box to your NT System32 subdirectory (e.g.,
c:\winnt\system32). On NT 4.0, find the file shell32.dll (if you're running an
earlier version of NT, look for progman.exe or main.cpl). Select this file,
check the Open as Read-Only box to protect it from accidental change, and click
Open.
- In the right pane of VC++, you'll see several folders under the
shell32.dll folder. Expand the Icon folder, which you see in Screen 9. (Notice
that all the numbers are resource names.)
- Now you can start pilfering resources. I happen to know that the number
17 resource contains several good printer resources, and number 173 reminds me
of fonts. Drag these resources onto the SMSCust resources script folder in the
left pane. VC++ automatically creates an Icon folder under SMSCust resources and
.ico files in the project subdirectory. VC++ generates the filenames from the
resource names, so you don't have to worry about them.
- You'll want to rename these resources from their exciting numeric names.
Let's change 17 to "PDG_PRINTER_PRINTER_DETAILS" and 173 to "PDG_STD_PRINTER_FONTS".
You change these names the same way you previously changed the bitmap name to "PRINTER_PRINTER".
Right-click the Icons, and choose Properties from the Context menu.
Change the ID: fields to "PDG_PRINTER_PRINTER_DETAILS" and "PDG_STD_PRINTER_FONTS"
(remember to include the quotes).
- Close shell32.dll, and save your project files (select File, Save All
from the VC++ menu).
- Select Build, Build SMSCust.dll from the VC++ menu to incorporate the
new resources into smscust.dll.
- Copy smscust.dll from the Release subdirectory into c:\smsres. Close the
SMS Administrator, and restart it. You will still see the Printer bitmap
representing HP Printer 1 in the SMS Administrator Sites window.
- Open the properties window for HP Printer 1. You will see the custom
graphics, as in Screen 10.
Congratulations! Not only have you created a professional looking result in
SMS, you're also a C++ programmer! As I promised, you didn't have to do any
coding beyond what you had to enter for smscust.cpp (and we stole that from the
SMS software development kit--SDK). If you have VC++, you don't even need that
code. You can create a blank file, name it smscust.cpp, and add it to the
SMSCust project, and VC++ will automatically generate the DllMain code behind
the scenes. Say, what do all these C++ programmers do anyway?
You can try adding icons and bitmaps using the naming conventions I've
described in this article. For example, we didn't add anything specific for the
Laser Printer role. Try out some of these combinations.
If you put in a little work, you can have some very intuitive graphics for
specific types of objects and generic catch-alls as you add new inventory. An
interesting DLL to peruse for graphics is the SMS standard resource DLL,
smsres.dll. You'll find most of the SMS icons and bitmaps there, including some
that have Hermes in their names (Hermes was Microsoft's code name for SMS). You
can override these standard SMS graphics. The sample in the SMS SDK makes some
of these standard objects look like a human eye--interesting, but kind of eerie!
My next article will explain how you can add personnel data such as
employee name, title, and department to the SMS inventory database directly from
a human resources database. You can then use this information to associate
workstations with a user or department. This ability is useful when you are
distributing software based on organizational needs.
LISTING 1: The regscrpt.ini Script File
\Registry\Machine\Software\Microsoft\SMS
ResDlls
Installed = REG_MULTI_SZ "DLLNum1" "DLLNum2"
DLLNum1
PathName = REG_SZ myres.dll
DLLNum2
PathName = REG_SZ myicons.dll
DLLNum3
PathName = REG_SZ notready.dll