Help needed searching folders

Help needed searching folders

Does anyone have a simple solution to this problem?

From within my program, I need to be able to search a user's computer drive to find all obsolete installs of my application (typically a DLL), and then run the uninstaller in that folder.

Due to migration from XP to Win7, and imposition of Managed Client, the default install location of my applications have changed.  While I have tried to ensure that each version uninstalls earlier versions, this is not always possible.  For some releases, I have asked users to uninstall previous versions, but they do not always do this.  The consequence is intermittent runtime errors when the user loads an obsolete version unintentionally (and usually unknowingly), resulting in the application either failing to find the now out of date license file, or worse, simply crashing.

So I need a way of cleaning up all installs of my application, irrespective of the folder it was installed in, and do this for potentially multiple copies on the machine. I can tell the user to seach for all copies of the DLL and uninstall them, but if I can write a cleanup program to do it, even better.

Thanks for your assistance,


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


There two options you could consider:
1) there is an api routine to list all files (entries) in a directory, which you can call recursively through the directory trees to get a list of all files on the disk, scaning for your appropriate xx.dll.
2) alternatively you could do a system call for "dir c:\*.dll /s > file_list.log" and scan the output, assuming you can create and open the list file.

Both methods (after appropriate consideration of possible error responses, which there can be a few!) would give you a list of files to check. One of the problems with this approach is that you can only list from directories that you have the required viewing rights, so this may not see some directories.

I have successfully used this approach for finding recent files or directory sizes and it does not take too long to run.


The second approach of #2 is a whole lot quicker to program. the /b option might help as the output will be just a  full path file list ( "dir c:\*.dll /s /b> file_list.log" ) without the headers. One problem is that it will hang the program for a long time unless this is a separate thread.

Leave a Comment

Please sign in to add a comment. Not a member? Join today