Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to determine if a DLL is in use

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Clicking on Print  property changes format of printing result 1 82
Issue testing the Class Library 4 58
dialer.exe 4 63
What namespace do I need to import? 2 38
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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