[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to delete a shared windows DLL

Posted on 1998-10-04
9
Medium Priority
?
184 Views
Last Modified: 2010-04-06
I want to replace an older DLL ( comctl32.dll ) with a new version with my own setup program. When I try to replace this file an error occured : Sharing violation. Is there any solution to erase shared DLL or even make it non-shared ?

Motaz from Sudan.
motaz1@yahoo.com
0
Comment
Question by:Motaz
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 80 total points
ID: 1341670
I think this DLL is in use by another (or by some other) process(es). So you just can't delete or replace this file on the fly. You cannot change the share mode, either. What you can do is what every setup program does: Restart Windows and make Windows replace this DLL right after the restart.

Win95:
Create/Edit the file "c:\windows\wininit.ini". Add this:
   [Rename]
   c:\windows\comctl32.dll=c:\windows\comctl32.$$$

WinNT:
MoveFileEx('c:\windows\comctl32.dll','c:\windows\commctl32.$$$',MOVEFILE_DELAY_UNTIL_REBOOT or MOVEFILE_REPLACE_EXISTING);

Win95/WinNT:
Now copy the new DLL version to "c:\windows\comctl32.$$$" and restart Windows (using ExitWindowsEx).

Regards, Madshi.
0
 
LVL 5

Expert Comment

by:inter
ID: 1341671
You are faster man ;-) here is my contribution

Yes you can,
however you should restart the windows in order your DLL be copied succesfully. Because every body uses comctl32(even windows shell) it is not advisable to kill those processes and copy comctl32. So it can be done with the following API but different for Win95 and NT

FOR NT:
-------------

 MoveFileEx('c:\temp\myinstall\comctl32.dll','c:\winnt\system32\comctl32.dll',
    LPCTSTR lpNewFileName,      // address of new name for the file
    MOVEFILE_DELAY_UNTIL_REBOOT );

FOR 95+
---------------

procedure MoveFileEx95(src, dest : string);
var
  inif : array[0..255] of char;
  inif : array[0..255] of char;
begin
  GetWindowsDirectory(szWinInitFile, uSize);
  StrCat(inif, '\WININIT.INI');
  WritePrivateProfileString('Rename', 'NUL', PChar(dest), inif);
  WritePrivateProfileString('Rename', dest, src, inif);
end;
//do not forgetto reboot! You can do this with the following API call

ExitWindowsEx(EWX_REBOOT, 0);

regards, igor
0
 
LVL 7

Author Comment

by:Motaz
ID: 1341672
Thanks all of you. A very nice solution... but need some clearifications :

-[Rename] not exist in Win.ini.. Must I add it ?.. and what happend if it is already exist?
- Is it posible to append win.ini.. no error will occure if I try to do so ?..
- After that did the windows remove this lines from win.ini after finishing this task ?

Thanks for your help.
Motaz
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:inter
ID: 1341673
Yes, combine the info we supplied and windows automatically handles the rest.
0
 
LVL 7

Author Comment

by:Motaz
ID: 1341674
Inter, you don't mention the file name which I must replace ?
0
 
LVL 5

Expert Comment

by:inter
ID: 1341675
You are right,
for WinNT do exactly what Madshi wrote, for Win95 call my proc

MoveFileEx95('source file name','dest file name'); and reboot.

I strongly recomend you to test those on a dummy file. For example create a file called x.dat on c:\ and replace it with the above method. Once succesful you try the actual replacement. In addition if in MoveFileEx95 proc NUL does not work try NULL instead.
regards, igor
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1341676
Hi Igor. I thought you wanted to call me "madshi" instead of "Madshi"!?  :-)

Motaz, ATTENTION!!!!!! It is NOT "Win.ini", but "WinInit.ini"!!!
The file "WinInit.ini" is handled from Windows at startup and then renamed to "WinInit.bak".

BTW, I think you don't need to delete the old file before replacing it. At least I don't do this in my programs...
Also you don't need to give in the windows path to WritePrivateProfileString. So I think you can shorten igor's nice procedure like the following:

procedure MoveFileEx95(src, dest: string);
begin
  WritePrivateProfileString('Rename', pchar(dest), pchar(src), 'WinInit.Ini');
end;

Regards, Madshi.
0
 
LVL 7

Author Comment

by:Motaz
ID: 1341677
Thanks Igor and Madshi... it did work.

Motaz
0
 
LVL 7

Author Comment

by:Motaz
ID: 1341678
Sorry I mean Inter and Madshi
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

656 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