Solved

How to determine if a DLL is in use

Posted on 2004-09-28
6
438 Views
Last Modified: 2013-12-03
I am in the process of writing an MSI installer for a web application.  Unfortunately the Windows Installer does not check for locked files, if they are not used by an application with a visible window.  The problem is that one of the files I need to replace is an ISAPI DLL, which is only used by IIS, so it does not get detected as 'locked' during setup.  This causes the setup program to require a reboot after it completes.

What I would like to do is write code -- either in C++, or in VBScript -- that will detect if that particular DLL is in use.  My setup program will use this information to notify the use and ask them to stop IIS before proceeding.

Does anybody have code that would do this?  Please note that this is not a COM DLL.

Thanks,
Pando
0
Comment
Question by:tiritas
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Milind00
ID: 12178054
0
 

Author Comment

by:tiritas
ID: 12185822
Milind00,
The code found at the site you posted would allow me to find which DLLs are in use by a particular process.  What I'm trying to find out is whether a DLL is in use by any process.  Essentially, I need to know whether I can overwrite a particular DLL, before actually trying to overwrite it.

- Pando
0
 

Author Comment

by:tiritas
ID: 12186583
I solved my own question with the following code that will test whether any file is locked:

BOOL IsFileLocked(char *filename)
{
      HANDLE hFile;
      hFile = CreateFile(
            filename,
            GENERIC_WRITE,
            0,
            0,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            0);
      CloseHandle(hFile);
      return (hFile == INVALID_HANDLE_VALUE);
}
0
 
LVL 4

Expert Comment

by:Milind00
ID: 12186910
Looks good ...:)
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12220263
Question answered by asker or dialog valuable.
Closed, 250 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now