Delete loaded dlx file



I’ve made .dlx extension for my script and load it with LoadDllsFromDir.
It loads and works perfectly, and now I’m making installer/uninstaller script that should copy/delete all script/icons/dlx files.

My problem is that some 3dsMax versions (2013 for example) locks dlx file and I can’t delete it in uninstall procedure. I thought that 3dsMax should lock all loaded dll files, but 2016 and 2019 don’t. In 2016 and 2019 I can easily delete dlx and uninstall script.
I understand that dlx is still in RAM while 3dsmax is running. My task is to make reliable uninstaller for script that will kill this dlx file.

  • Why 2013 locks file, but 2016 and 2019 don’t? Is it some kind of deprecated feature of 3dsmax?

  • Can I force 3dsmax 2013 (and other versions that lock dll) to unlock these files so I can delete them? I don’t need to “unload” dlx functions, I just want to kill a file.

  • Should I worry about killing loaded dlx file if I can do that? I have 2 functions in this dlx, both of them work after file delete, but I don’t need them after script uninstall anyway. I mean, may 3dsmax become unstable after such actions?


do you really need to uninstall your stuff when max is running?
i can believe that pure system can safely survive after deleting a DLL/DLX, but no one can guaranty the same for 3rd party tools which might store some related data… undo/redo (restore objects), callbacks, event handlers, etc.


Those 2 functions inside dlx are used only by my scripted tool and both return some mesh data and that’s all. Scripted tool will be killed before dlx, so it’s not a problem.
Anyway, these functions work after I delete dlx in max2016.

I see your point, obviously it’s safer to keep dlx while 3dsmax is running. I have another option - that will be copied to userscripts\startup and it will delete dlx and itself at next 3dsmax session. This option is safe, but it needs second 3dsmax session to delete file, and things get a little more complicated when multiple 3dsmaxes are opened.

What is most correct way to make uninstaller for script+dlx? My installer/uninstaller is inside .mzp btw.
And do you know why 2013 locks dll and 2016 doesn’t?


Klvnk did some investigation.

I do all un-installations with MAX closed. (as well as installations).


Ok, thanks.
Hope Klvnk will see this post :slight_smile:


the code/hack I use are for debugging/testing and are not suitable for any kind of “public” tool. Also though you can unload a dlx/script extension you’ll run into problems/crashes loading a new dlx there are also issues with function publishing. As above do the install uninstall with max closed it will save you a lot of heart ache down the line.