Ideas on why this DLL can be used exactly like a MATLAB function?
Show older comments
Hi,
Previously my experience with DLLs in MATALAB was that you must load the DLL library in question with "loadlibrary()", and then you can request use of its functions using "calllib()". Recently I received a new piece of hardware that came with a DLL written in C to pass commands to the device. They gave me a sample m-file for using the DLL, but I was confused since they never make a loadlibrary call, and also they directly call on the DLL just like an m-file function, with the DLL placed in the same directory as the script (i.e. no "calllib()" is made). Below is the first snippet of code, with the DLL in question "CgCall.dll".
% Variables used for system_command in CgCall()
INITIALIZE = 1;
QUERY = 2;
CONFIGURE = 3;
DO = 4;
%There was some more parameter declarations here that I've left out
%Initialize the CompuGen system
NumBoards = CgCall(INITIALIZE);
Now this script didn't work before I installed the hardware drivers, but after I did it worked just fine (no surprise). So installing the drivers must have done something that allows this dll "CgCall.dll" to work just like MATLAB function, with no "loadlibrary()" and subsequent "calllib()" requests. Moving the DLL out of the current directory also makes it stop working, so it isn't like the DLL became part of MATLAB's library.
Does anyone have any ideas as to how this is possible? I've contacted the company, but they are very slow at response.
Thanks,
-Greg
EDIT: Also, to be clear, it appears that this CgCall.dll only contains the one CgCall function
Accepted Answer
More Answers (1)
Image Analyst
on 1 Feb 2013
0 votes
Why can't CgCall() just be an m-file that contains the loadlibrary() call inside of it?
Categories
Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!