Replace running dll

Posted on 2011-05-02
Medium Priority
Last Modified: 2012-05-11

As the version of the MySQL databaseserver is changing, I need to upgrade the libmysql.dll mon the customer machine (this is either a Windows laptop/desktop of a Windows server).
The libmysql.dll is currentlt in use.

How can I replace the dll anyway from within my delphi application.
Question by:Stef Merlijn
LVL 19

Expert Comment

ID: 35505515
The dll must be unloaded to replace it from within your application.

If you use static dll loading, the dll is always loaded, when your application is started. Therefore you cannot replace it.

Load you dll dynamically, so you can replace it, when it is not in use...

Dynamic Link Libraries (DLL) and Delphi
LVL 24

Expert Comment

ID: 35505529
You can try the function MoveFileEx to replace the DLL with the new after providing the paths to both of them.
LVL 24

Expert Comment

ID: 35505541
Hi Thommy, long time man. Where have you been?
LVL 38

Accepted Solution

Geert Gruwez earned 2000 total points
ID: 35511867
you can not do that, if you're application is not the only one using it

the quick and dirty way ...
rename the dll
copy the new in the same location

newly started apps will use the new dll

Author Closing Comment

by:Stef Merlijn
ID: 35511914
Thank you very much.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 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