Click to See Complete Forum and Search --> : Changing DLL versoins runtime ( Non-COM - WIN32 dlls)


Ravi Kiran
December 17th, 1999, 01:48 AM
Hi,

My question is: How to switch between different non-com/"simple" dll at run time (in VB ofcourse!).

I Can use LoadLibrary but, i dont know how to call the functions after that.. using GetProcAddress or whatever..

--
I have a win32 dll ( which interfaces with a Image processing board) and it comes in 2 different versions.. implements different ideas actually.

Original idea was i would finalise on one of them.. how ever it appears that i might need to provide support for both..
Function interfaces are little different etc.. so til now, i had defined the Declare statements in a Compiler Switch and change ths switch and compile.. and things were working fine.. now "HE", you know who:-), wants both to be there.. so how to?

Memory is another limitation. I cannot afford to have two versions of essentially same stuff loaded up, just to use a few functions of both. Being Image proc. stuff, it really takes up huge memories etc.

Any help would be greatly appreciated

RK

Chris Eastwood
December 17th, 1999, 02:38 AM
Hi Ravi

Just an idea, but why don't you wrap the standard DLL in an ActiveX DLL and give it the same interface as your existing COM DLL - you could then switch between them at run-time depending on which ever one you wanted (you could make it nice and OO if you use Implements).



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Ravi Kiran
December 17th, 1999, 03:35 AM
Hello Chris,

Thanks for replying. I have a class wraped up around that dll. But it is not active-x... yet!...

I will explain: memory is one big constraint..
You see, VB has this good feature of loading dlls only on first use.. but how to tell it to unload? In my experience, i notice, that once the app loads the dll (std WIN32), the memory used by all things "below" ( like driver, other dlls.. what ever, it accesses a IPboard mind you) starts to get counted on My App!. Runs into 12MB+ at times. Now if i have 2 dlls essentially same functionality, and both get loaded.. and memory doesn't release.. then i better pack up & go!

In this situation do you think active-x component helps? Before i take a plunge, it would be worth while to consider.. Both dlls have little different interfaces, that is not a big deal...

RK

ps: By the way, i use "Implements" else where in the project. SO you think i am programing OO way ?:-)

RK

Chris Eastwood
December 17th, 1999, 03:46 AM
In my experience VB only unloads the 'standard' DLL's once your program has finished running (well, sometimes the IDE does strange things and keeps the DLL in memory, but that's another story). This would mean that using an ActiveX DLL 'in-process' would still require the DLL to be loaded in memory.

What you could do is create an ActiveX Exe that handles your 'standard' DLL, then call this from an ActiveX DLL - that way, you know that the 'standard' DLL will only be loaded in memory when required and then released when no longer needed - I know it's a huge kludge, but we've all had to write them at one point of our career. I'd still recommend that you use a standard interface for both your DLL's (ActiveX wrapper DLL and ActiveX other DLL) - this way you could just 'plug-in' other dll's at a later stage.

As for 12mb of memory being used - that's nothing ! I've worked on systems that use up to 60mb of memory depending on the number of windows that app has running. It didn't slow the app (machines had to have 128mb memory) but was interesting to watch on the system resource monitor. I also use JBuilder3 at work and that things a monster - you need 96MB of memory just to run it and hitting F1 for the help, pushes memory usage up to around 160mb (depending on the size of the project) !


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Ravi Kiran
December 17th, 1999, 04:17 AM
I will probably go ahead and give it a try, then.

On this memory subject., true it is interesting to watch stats on Resource monitor/TaskManager. After the First run of my program, from IDE, the memory registered under VB.exe goes thru the top!. It doesn't seem to relinquish any not-used memory at all. I feel sorry!, when i look at the 100+ commited mem.pages.... But then i have no control over it!.. "What the heck, any only MY APP is supposed to run on the machine!", every developer seems to think:-), that includes me too .... just joking...

Thanks again.

RK