Solved

How to determine if a DLL is in use

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

17 Experts available now in Live!

Get 1:1 Help Now