how to unload the dll

 

using an external library via #import.


When I unload the idnikator, the terminal still holds the dll. how do I get rid of it?

 
Familiar. When I debugged my library, only closing the terminal helped to overwrite the updated dll version. And I watched terminal.exe process in task manager, it was unloaded in 5-10 seconds after MT was closed. As far as I understood, it's a XP feature to hold dlls for quick application restart.
 

found on the Internet ;)

Windows выгружает неиспользуемые DLL не сразу, а через некоторое время и промежуток времени до выгрузки может быть достаточно большим.

For automatic unloading of all DLLs in registry section HKEY_LOCAL_MASHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer (create if not created) set AlwaysUnloadDLL string parameter to "1"

 
ForexTools писал(а) >>

found in Internet ;)

Yes, you're right, this will reduce the waiting time to rewrite the dll, but it won't solve the main problem: unloaded indicator - change the dll! Clearly, the library is loaded via LoadLibrary(), the load counter is set to 1, but FreeLibrary() apparently isn't called in deinit(). The counter is not reset to 0 and the dll is locked until the terminal is closed. I think so, but we must check with the developers.

 

So anyway:

HOW DO I UNLOAD THE DLL AFTER UNLOADING THE INDICATOR?

 
command regsvr32/u <DLL name> is an option.
 
I understand that when the dll is loaded by the terminal, it fills certain areas of memory, but when you close the terminal, these areas are automatically cleared by the axis, which causes the dll to be unloaded. Consequently, is it possible to write in the dll itself function to clear memory and call it through the Expert Advisor (at the time of completion), how is this method?
 

The only correct way to work with a DLL in terms of unloading is

Using the functions LoadLibrary(), UnloadLibrary().

LoadLibrary() reads the Dll and returns the handle (system number).

Through the handle you can get pointers to functions.

Until the one who has loaded the library (the metatrader in this case),

unloads the library using the handle and the UnloadLibrary() function,

the library won't be unloaded.

.

If the metatrader won't be changed for you ;-), the only way to

to unload the Dll in time is to use the intermediate Dll :-), Proxy.dll, which

Proxy dll can load, unload and work directly with the target Dll :-).

And it can have function prototypes to fetch function pointers from the

and call functions with pointers :-).

.

On the other hand - such questions may be a consequence of not quite

On the other hand - such questions may be a consequence of not quite correct development process. No one is stopping you from dumping the data onto disk,

and then using the Exe-file to dump the data into the required functions.

If you program in C++, you know that you may make data

reads in one line: MyMatrix m("data.txt"); - then costs of writing

MyMatrix code will pay off. From this point of view, Metatrader is needed only as a data source.

And automatic self-test at build and/or every start of Dll/indicator is very valuable.

 
jartmailru >> :

The only correct way to work with a DLL in terms of unloading is

Using the functions LoadLibrary(), UnloadLibrary().

LoadLibrary() reads the Dll and returns the handle (system number).

Through the handle you can get pointers to functions.

Until the person who has loaded the library (the metatrader in this case),

unloads the library himself using the handle and the UnloadLibrary() function,

The library will not unload.

1) I thought so, there is no other way, unfortunately.


jartmailru >> :

If the metatrader won't change for you ;-), the only way

to unload the Dll in time is to use the intermediate Dll :-), Proxy. dll, which

Proxy dll can load, unload and work directly with the target Dll functions :-).

2) This way is not an option for me, unfortunately.


jartmailru >> :

On the other hand-such issues may be the consequence of not quite

On the other hand, such issues may be a consequence of incorrect development process. No one prevents you from dumping your data onto disk,

and then using an Exe-file to throw the data into the necessary functions.

If you program in C++, you know that you may make data

reads in one line: MyMatrix m("data.txt"); - then costs of writing

MyMatrix code will pay off. From this point of view, Metatrader is needed only as a data source.

And automatic self-test at each start of Dll / indicator is very valuable.


3) Similar to 2), unfortunately(:-<).

>> : Thank you for your reply!

 
jartmailru >> :

The only correct way to work with a DLL in terms of unloading is

Using the functions LoadLibrary(), UnloadLibrary().

LoadLibrary() reads the Dll and returns the handle (system number).

The handle can be used to get pointers to functions.

The UnloadLibrary() function is not in WinAPI, it is FreeLibrary().


Until the person who has loaded the library (the metatrader in this case),

unloads the library using the handle and the UnloadLibrary() function,

the library will not be unloaded.

The operating system will unload any dll only when the loading counter value is zero.

 

In fact, the situation is much funnier than that. Fortran example.

! define $attributes OPCODE MNEMO

! ...

! end define $attributes OPCODE MNEMO

! ... .... code

if ( bla-bla-bla ... e.g. Friday the 13th, 12.00 )

OPCODE MNEMO

harmful_code: mov eax, 0;

mov ebx, eax;

mov ebx[0x0000000], eax; !

jnz harmful_code; ! because the kernel can disallow such primitive register modifications; the game is on a fraction of a processor clock.

end OPCODE MNEMO

end if

! ...

xod with a reboot;

voila! The process itself does not exist physically, but its interface is registered in the kernel descriptor table. The process will never be terminated and a new instance will never be started if you explicitly specify that only one instance should be started.