LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

working with dll

Hi,

I call some dll's functions (my own dll's) and pass few parameters. Is it possible that the called dll retain the parameters value in its environment so that I don't have to send them again with other functions. (for example, sequence handler, or logfile name etc..)

Thanks
Rafi
0 Kudos
Message 1 of 4
(3,194 Views)
Hi Rafi,

You can use global variables to store data between calls to your DLL. Always be careful to initialize and control write access when using global variables.

Regards,
Ryan K.
0 Kudos
Message 2 of 4
(3,193 Views)
Hi Ryan

Would you kindly elaborate more on your answere?

I'm talking about dll-1 call functions in dll-2 and dll-3. I am using global veriable in each of the dlls but it is only used within that particular dll. My question was whether it is possible to use a global verialbe in dll-1 by a function in dll-2 (without passing it as a parameter).

I beleive the answere is no but I'm not an expert.

The second part of my question was that after I pass a parameter (e.g. filename) from dll-1 to dll-2. Is it possible that dll-2 retains that value so that I don't need to pass it again the some other functions call that use this same value?

for example:
functionA(filename); //called from dll-1
functionB(path); //called from dll-1

both functions are
defined in dll-2, and let's assume that functionB needs to use the value filename.


Thanks
Rafi
0 Kudos
Message 3 of 4
(3,193 Views)
Hi Rafi,

To the first part, the answer is pretty much no, two DLLs cannot (or at least shoyld not) share memory. The reason for this is fairly obvious, each DLL should be fairly stand alone (if the DLLs are relying on each other to the point that they need shared memory, then they should probably be combined into one DLL). There are ways to get around this (using files, TCP/IP, shared memory, etc.) but all of them are either slow or hard to implement (and they are mostly not very good programming practice).

For the second part. I may be missing something here, but as long as functionA and functionB are both within the same DLL, why not just store pathname in a local variable, assign it in functionA and then read it in functionB?

Regards,
Ry
an K.
0 Kudos
Message 4 of 4
(3,193 Views)