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

x
?
Solved

DLL Load/Unload

Posted on 2009-05-09
5
Medium Priority
?
851 Views
Last Modified: 2012-05-06
Hi, i have an application that use a DLL, and it is working for a long time.
DLL file resides in the same folder as EXE file.
Application has ShareMem (in a future will be FastShareMem, but "one step at a time") as its first uses unit.
The application shares data through BDE Alias thats is located in the server.
All works fine.
I have multiple users accessing the same application in different pcs, each of them has a link for executing the application with this data:
- it points to the exe file in the server
- working folder is a local folder, in which resides the copy of the DLL
So, when a user starts the application in his workstation, the exe is executed locally, and inmediatelly loads the DLL.
This works great as if i need to update the application, i am only need to change the exe file in the server.

Here is the problem & question:
How can i update the DLL file in each workstation, dinamically (by now, i am doing this by hand!!!)?
I think on this solution:
- put the new DLL version in data folder in server (this folder is acceded from all application running in all workstations).
- if date of local DLL file is older that server DLL file, i replace the local file with that on the server.

This seems to be a ratherly good solution, but, as my application loads the DLL file inmediatelly, i cannot do this.
I think this has to be related to load/unload of the dll at entry point or something like this, but i has no experience at all in here. My DLL has only a few functions, and my application uses an interface unit that declares all function and define them as externals.

Thanks to you all!!!
0
Comment
Question by:spk2000ar
[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
  • 3
  • 2
5 Comments
 
LVL 4

Author Comment

by:spk2000ar
ID: 24345846
Unit uImpresionInterfaz, is what i uses in my application.
unit uImpresionInterfaz;
 
interface
 
uses uGeneral, uImpresiones, Printers;
 
{$IFNDEF IMPRESION}
procedure ImprimirReciboFantasma(PuestoCaja: string;
                                 ParametrosImpresora: TParametrosImpresora;
                                 Fecha: TDateTime;
                                 Inmobiliaria, Renglon1, Renglon2, Renglon3, Nom: string;
                                 var Pun: real; Concepto: string; Adicionales: boolean); StdCall;
 
procedure ImprimirReciboGeneral(PuestoCaja: string;
                                ParametrosImpresora: TParametrosImpresora;
                                Fecha: TDateTime;
                                Inmobiliaria, Renglon1, Renglon2, Renglon3, Nom, Concepto, Firmante: string;
                                Adicionales: boolean); StdCall;
 
procedure ImprimirRecibo(PuestoCaja: string;
                         ParametrosImpresora: TParametrosImpresora;
                         PuntoVenta, Nro: string; Fecha: TDateTime;
                         Nom, Dom, NomProp: string;
                         SitIVA: integer; Cuit: string;
                         var SItems: TItems;
                         Total: real; Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirReciboHonorarios(PuestoCaja: string;
                                   ParametrosImpresora: TParametrosImpresora;
                                   PuntoVenta, Nro: string; Fecha: TDateTime;
                                   Nom, Dom: string;
                                   SitIVA: integer; Cuit: string;
                                   var SItems: TItems;
                                   var Hon: real;
                                   Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirReciboHonAdm(PuestoCaja: string;
                               ParametrosImpresora: TParametrosImpresora;
                               PuntoVenta, Nro: string; Fecha: TDateTime;
                               Nom, Dom: string;
                               SitIVA: integer; Cuit: string;
                               var SItems: TItems;
                               var Hon: real;
                               Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirReciboVarios(PuestoCaja: string;
                               ParametrosImpresora: TParametrosImpresora;
                               PuntoVenta, Nro: string; Fecha: TDateTime;
                               Nom, Dom: string;
                               SitIVA: integer; Cuit: string;
                               var SItems: TItems;
                               var Total: real; Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirLiquid(PuestoCaja: string;
                         ParametrosImpresora: TParametrosImpresora;
                         Inmobiliaria, PuntoVenta, Nro: string;
                         Fecha: TDateTime; Nom, Dom: string;
                         SitIVA: integer; Cuit: string;
                         var SItemsAlq, SItemsOtros: TItems;
                         Comision, Total: real; Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirFacturaA(PuestoCaja: string;
                           ParametrosImpresora: TParametrosImpresora;
                           PuntoVenta, Nro: string; Fecha: TDateTime;
                           Nom, Dom: string;
                           SitIVA: integer; Cuit: string;
                           var SItems: TItems;
                           var Hon, TasaIVA: real;
                           Comentarios: string; Adicionales: boolean); StdCall;
 
procedure ImprimirFacturaB(PuestoCaja: string;
                           ParametrosImpresora: TParametrosImpresora;
                           PuntoVenta, Nro: string; Fecha: TDateTime;
                           Nom, Dom: string;
                           SitIVA: integer; Cuit: string;
                           var SItems: TItems;
                           var Hon: real;
                           Comentarios: string; Adicionales: boolean); StdCall;
{$ENDIF}
 
implementation
 
{$IFNDEF IMPRESION}
  procedure ImprimirReciboFantasma;    external 'Impresion.DLL' name 'ImprimirReciboFantasma';
  procedure ImprimirReciboGeneral;     external 'Impresion.DLL' name 'ImprimirReciboGeneral';
  procedure ImprimirRecibo;            external 'Impresion.DLL' name 'ImprimirRecibo';
  procedure ImprimirReciboHonorarios;  external 'Impresion.DLL' name 'ImprimirReciboHonorarios';
  procedure ImprimirReciboHonAdm;      external 'Impresion.DLL' name 'ImprimirReciboHonAdm';
  procedure ImprimirReciboVarios;      external 'Impresion.DLL' name 'ImprimirReciboVarios';
  procedure ImprimirLiquid;            external 'Impresion.DLL' name 'ImprimirLiquid';
  procedure ImprimirFacturaA;          external 'Impresion.DLL' name 'ImprimirFacturaA';
  procedure ImprimirFacturaB;          external 'Impresion.DLL' name 'ImprimirFacturaB';
{$ENDIF}
 
end.

Open in new window

0
 
LVL 4

Author Comment

by:spk2000ar
ID: 24345853
DLL code...
library Impresion;
{$DEFINE IMPRESION}
 
uses
  SysUtils,
  Graphics,
  Dialogs,
  Printers,
  uImpresionInterfaz in '..\..\..\Modulos\DLLImpresion;
 
procedure ImprimirLiquid(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                         Inmobiliaria, PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom: string;
                         SitIVA: integer; Cuit: string;
                         var SItemsAlq, SItemsOtros: TItems;
                         Comision, Total: real; Comentarios: string;
                         Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirReciboVarios(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                               PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom: string;
                               SitIVA: integer; Cuit: string;
                               var SItems: TItems; var Total: real;
                               Comentarios: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirRecibo(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                         PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom, NomProp: string;
                         SitIVA: integer; Cuit: string;
                         var SItems: TItems; Total: real; Comentarios: string;
                         Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirFacturaA(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                           PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom: string;
                           SitIVA: integer; Cuit: string;
                           var SItems: TItems; var Hon, TasaIVA: real;
                           Comentarios: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirFacturaB(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                           PuntoVenta, Nro: string; Fecha: TDateTime;
                           Nom, Dom: string; SitIVA: integer; Cuit: string;
                           var SItems: TItems; var Hon: real;
                           Comentarios: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirReciboHonorarios(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                                   PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom: string;
                                   SitIVA: integer; Cuit: string; var SItems: TItems;
                                   var Hon: real; Comentarios: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirReciboHonAdm(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                               PuntoVenta, Nro: string; Fecha: TDateTime; Nom, Dom: string;
                               SitIVA: integer; Cuit: string; var SItems: TItems;
                               var Hon: real; Comentarios: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirReciboFantasma(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora; Fecha: TDateTime;
                                 Inmobiliaria, Renglon1, Renglon2, Renglon3, Nom: string;
                                 var Pun: real; Concepto: string; Adicionales: boolean); StdCall;
begin
end;
 
procedure ImprimirReciboGeneral(PuestoCaja: string; ParametrosImpresora: TParametrosImpresora;
                                Fecha: TDateTime;
                                Inmobiliaria, Renglon1, Renglon2, Renglon3, Nom, Concepto, Firmante: string;
                                Adicionales: boolean); StdCall;
begin
end;
 
exports ImprimirReciboFantasma;
exports ImprimirRecibo;
exports ImprimirReciboGeneral;
exports ImprimirReciboHonorarios;
exports ImprimirReciboHonAdm;
exports ImprimirReciboVarios;
exports ImprimirLiquid;
exports ImprimirFacturaA;
exports ImprimirFacturaB;
 
end.

Open in new window

0
 
LVL 35

Expert Comment

by:Bembi
ID: 24363661
Just some ideas:

Write something like an update program. This can be used, to kick out the DLL out of memory. Usually windows controls memory by itself, this may be the reason, taht you cannot replace the DLL at once as still in memory. But you may be able to force windows to close it as long as initiated by a seperate application.
The more easier option may be, to put the update program into the RUN setion of the registry and replace the DLL during reboot or relogon.
0
 
LVL 4

Accepted Solution

by:
spk2000ar earned 0 total points
ID: 24363826
That's not work for me. I understand what you mean, but i want to keep all the stuff running besides my application. In every workstation as the application run, itself has to verify if there is a new version of the dll and replace the local version.
I found a first step of a solution googling the problem... and that is load DLL dynamically. By now, i am using an static approach.
http://www.scalabium.com/faq/dct0130.htm
http://www.delphi3000.com/articles/article_1138.asp?SK=
I should try, as it is the solution
0
 
LVL 35

Expert Comment

by:Bembi
ID: 24364094
You are welcome...
0

Featured Post

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.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
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