?
Solved

How to determine if a DLL is in use

Posted on 2004-09-28
6
Medium Priority
?
451 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
[X]
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
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 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