( Index )
Brief Information about the November 2000 CSIG Meeting
DLLDUPS - Win32 --- Search Drive for Duplicate DLL Files
3rd Tuesday of the month.
7:30PM - C/C++ Group, SPRS
Welcome to the 2000-2001 season of the C++ Users Group.
This group is a "Special Interest Group" of the ACGNJ devoted to discussing
programming languages in general and C, C++, and C++ for Windows programming in particular.
Each month a hopefully useful program (complete with
source code) is presented for discussion.
At the October meeting of the C++ users group we discussed to a
program called DLLDUPS which searches your hard drive for redundant
DLL files. This tool will help you fix problems caused by DLL file
conflicts often called "DLL HELL" and to provide general auditing of computer
files. "DLL HELL" is a term used when the following happens: 1)
a Windows application fails only on some computers; 2) an
application was working previously but fails after new application is
installed. It is caused by the applications and their DLL files getting
out-of-sync. Older programs may not work with newer DLL's and new
programs may not work with older DLL's. I have even seen a case where a
WindowsNT DLL was installed on a Windows98 computer by a defective
For the November meeting we take that utility one major step forward.
The program is changed into a full blown Windows 32-bit application.
the application uses most of the routines from the previous
program. On Tuesday night we will be discussing the new features that
are required to change it into a Windows program. The program will
use the Visual C++ Microsoft Foundation Classes (MFC) set up as a Single
Document Interface or SDI program.
The program code has a number of special features: a) It uses a recursive file searching
algorithm to search the entire hard drive. b) It uses Microsoft Foundation Library
List Controls in order to store the huge amount of data. c)Once duplicates are found,
each file is interrogated to determine its version number. d) It contains a special
dialog to prompt the user to select a Starting Path from the directory tree.
Good references for MFC include books by Jeff Prosise and books by Mike Blaszczak.
Here's a link which provides file version information from Microsoft:
Detailed Information about the major source module.
The CDllDupsView Module
The module DupsView.cpp contains most of the algorithm's special
procedures. Here's a run down of the procedures that it contains.
The pre-create window procedure created by the application generator
has to be modified to include the styles that we want. This
program is based on a CListView class which simplifies use of the list control.
This class encapsulates list-control functionality with MFC's
Special code is now added to the view class so that it understands
that there are multiple columns. These columns are defined here.
The columns are named:
In addition, since this is the first procedure to run when the program is
started, I get the operating system directory and use it to initialize
the path variable.
| DLL Name
| Size and Date
| Version #
| Full Path and Name
Greater Than Operator
Although I could have created a compare function from scratch, I
decided to use the code from the previous program. This code
overloads The > operator to accept information from structure
pointers. The sort algorithm will require a normal compare
function and this is provided in the next procedure. It uses the
The main function of the program is to search your hard drive. This is
done here. This procedure can be considered an outline
for the entire application. The following actions occur: old
documents are saved and memory is released, TopProcess() is called which
starts the recursive search for DLL files, the files are then sorted
based on name, date, and path, unique files are eliminated, and finally
version information is obtained for the remaining duplicate files.
TopProcess(char * folder)
This procedure simply sets the starting folder and then calls the
recursive file search algorithm.
Process(const char * root)
This recursive search procedure searches through all of
the files on a hard drive. For each DLL file that it finds, it saves
detailed information in memory and then saves a pointer to that
memory in a CListCtrl Object.
The FindDups procedure steps through each line of the CListCtrl
and compares the file in the previous record with that in the
current record. Unique records are deleted and the memory associated
with them is also deleted.
This procedure simply steps through each record in the list and calls
the version number procedure. In addition, several statements are devoted
to making the list visible on the screen as it is working to obtain
the information. (See FileVersion() below.)
NewName(CString & arg, int lineNumber)
The NewName function simply keeps track of whether consecutive records
have the same name.
SpecialWin2k(CString & dir)
There are special directories or folders in Windows 2000 in which
are stored backup copies of DLL files. These folders are ignored
based on this procedure.
FileVersion(CString & name)
This is an exciting procedure that was presented at last month's
meeting. It seems quite simple, to get the version of
file, however the facility for doing this is quite complex. This
procedure does not involve Windows graphics and therefore is identical
to the one presented in the previous DOS box program.
This procedure is quite complex but provides a very nice looking
dialog box for selecting a folder anywhere on the system. This system
can include floppy drives as well as network mapped drives.
OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult)
This is a short but very essential part of the program. For the most part
the CListView class does not store the data. The data is actually stored
in system memory with the statement, pRecord = new Dll_info(record). The
class only stores a pointer to the data. When the system requires the
actual data to paint on the screen, this procedure is called.
At the end of the program when the Windows are destroyed the memory
must be released back to the system.
The status bar created in this program was done manually instead
of using the application generator. Therefore the updating of
this bar has to be done manually whenever the window is changed.
This procedure clears the memory used in the list control as well as
memory which is directly allocated from the system.
"Random Access" questions start at 7:30 Tuesday night.
Source Code Files
For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page