mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: Jun 2003
Posts: 195
N
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
the auto detect is easy however the only thing you could do is unload. this means your dll would have to detect the first instance (more code) then perform the same command to the first copy (more code) then unload (more code to only remain loaded if its the first copy). It couldnt remain loaded because mirc will still unload both copies when its closed. this would mean you would have to determine at unload time if this is the first copy(more code) before performing its cleanup (such as deleting stored memory etc..) so that the memory remains valid for all copies as the loaded dll's are unwound.

it can be done by adding alot of additional code or by mirc simply checking its loaded dll's. one of the largest complaints i see on various sites is about dll size. most scripters complain if the size is over 100k (wich is incredably small for a file sitting on a 30GB hdd btw). adding alot more code would mean less people will use them. kinda defeats the purpose of writing them ne?

i propose a switch for example /dll -c for copy. this has a major advantage. it requires the scripter to know they are loading a copy. this will avoid accidental loading of a copy.

i agree that scripters should use better code (i have my own /CallDll alias) but this includes not relying on unplanned behaviour.

i doubt it was done that way intentionally or it woulda been in the hlp.

i guess i didnt read your last post too well. No you wouldnt use the filename itself to determine if its been loaded. Most likely the fastest way would be to simply add a property to the mirc window. if that property exists then another copy is loaded and its value is its instance handle (HINSTANCE). Most likely ill add an CreateGlobalData function with the acompanying GetGlobalData function in my sdk. Problem is im the only one using my sdk so other dll's will still have problems (unless then write thier own handling).

Last edited by Narusegawa_Naru; 18/01/05 01:30 PM.

Have Fun smile
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
the auto detect is easy however the only thing you could do is unload. etc etc

Actually it could stay loaded with a reduced foot print, since all it needs to to is pass control to the first loaded copy. (hmmm assuming that didnt unload lol) It is kinda not exactly what dlls were envisioned for I must admit.

Joined: Jun 2003
Posts: 195
N
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
well it could stay loaded provided it doesnt try to remove any data allocated by the first copy but in that case theres really no need to keep it loaded.

The easiest solution would be to simply return an error ReturnError(ERROR_INVALID_INSTANCE); or something similar. This would mean that the call would simply just fail. That would require the least amount of code to handle however ive noticed that more often then not scripters avoid using $dll like it was a plague. So then youd get a boatload of msg's complaining that 'ABC function does not work' lol.

As i mentioned in my previous post i added global support to my sdk for multiple instances

int __stdcall Function(args)
{
gGlobalData *pData = GetGlobalData("nickLUST");
if (pData.GetCreatorInstance() != hSelf) return RelayFunction(pData,same args as fn);
void *pInternal = pData.GetStorage();
//use pInternal here.
}

It works well except you have to add the code to each function you use (the ones exported to mirc). The size difference wasnt too much it only added about 3.5k. that was the actual sdk code and about 20 functions that needed it.

Ill try to come up with a way to stub the functions so i can simply use one call for all functions exported but not until my next project smile


Have Fun smile
Page 2 of 2 1 2

Link Copied to Clipboard