Solved

How to determine if a DLL is in use

Posted on 2004-09-28
6
441 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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