LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call library function not finding DLL in directory where my LLBs are

Solved!
Go to solution
By a function dispatch structure do you mean a table of function pointers gotten by GetProcAddress, one such entry for each function?

Yes this is the idea.

I think I understand what the wrapper functions need to do.  But I am missing some pieces for the initialize function.  It would have to do LoadLibrary and lots of GetProcAddresses -- that much I get.  But I still don't understand who decides which DLL.  Maybe you mean that the wrapper DLL's initialize function will get the DLL name and path from the registry, load it, try a different path if the load fails, etc.  Is that what you mean?  That could work very nicely.   But from where would it get the registry key?  From the VI?  This is the part that would clearly be different for each product.  I suppose that you had something in mind when you described your solution.

 

Well somewhere at some point you need to decide for which product and which DLL you want to call this interface. One possibility is that you have an Intialize function that accepts a string parameter that identifies the product to call and it then internally resolves that string to the correct DLL name, looking for that based on some heuristics, registry settings or whatever and then loading it with load library and filling in the function dispatch table. You can even add other information to the structure that contains this function table such as version information, instrument class, magic ID to be able to verify in the other fucntion that you got a valid structure etc.The pointer will be returned as a simple pointer sized integer being an opaque handle to the caller.

 

Every function then takes that handle casts it to the structure, verifies its correct version, etc and then indexes the correct function pointer checking if it is not NULL (can allow for minimalistic product drivers that may not implement every function) and then calls it.

 

Rolf Kalbermatter

Message Edited by rolfk on 06-08-2009 10:03 AM
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 11 of 12
(662 Views)

Just to give credit where credit is due -- I really needed to mark three messages here as the "solution" but the system doesn't let me do that.  So I am using the dispatch DLL method suggested by Rolf Kalbermatter , but the initial answers that he and altenbach gave to my original question are an integral part of the solution -- that is the method I use to find the dispatch DLL.

 

So thank you BOTH very much for your help!

 

By the way, someone from NI who was at our office giving a presentation told me I should really be using something called a VI server, but I haven't looked into it yet.......I have to release a product today!

 

Batya Perlman

0 Kudos
Message 12 of 12
(633 Views)