Assistance trying to load 3rd party dll/headers into Matlab

3 views (last 30 days)
Greetings, I'm not a programmer so please be gentle :)
I have a program that was written in C# (I think) that creates a gui that controls a unique custom camera. Unfortunately this program was not written to be automated and there is no support or documentation on the software. I want to use Matlab to automate some testing so I thought if I can access the dlls the software uses to communicate with the camera that I may have a shot. I've only used loadlibrary once before to control some NI hardware, but that had pretty good documentation to help me get that working.
So what I've done is search the sln file of the camera gui to look for any dlls it's calling and found one dll, lets call it nm1.dll. I found a header file called nm1.h so I'm assuming that's the correct header to use for this dll.
Looking at nm1.h, I see it includes 3 more headers: #include windows.h #include CyAPI.h #include "nm2.h"
Looking at nm2.h, I see even more headers, which call other headers and so forth.
When I load in the nm1.dll file, do I need to addheader for every child header, i.e. loadlibrary(nm1.dll, 'nm1.h', 'addheader','nm2.h', 'addheader','windows.h', 'addheader','CyAPI', 'addheader',....and so forth)?
I'm using Matlab 2015a 64bit on Windows 7 and using windows SDK7.1 as the compilier.
Thanks, Jason
  1 Comment
Philip Borghesani
Philip Borghesani on 18 Aug 2015
Edited: Philip Borghesani on 18 Aug 2015
You may be better of modifying the c# code to produce a .net object/library and directly calling that using the MATLAB .net api. In general this technique should be more robust to novice mistakes (you should crash MATLAB less) because you will have full type safety.

Sign in to comment.

Answers (1)

Philip Borghesani
Philip Borghesani on 18 Aug 2015
Edited: Philip Borghesani on 18 Aug 2015
Only use addheader when a function you want does not appear in libfunctions or the prototype file. Find the header containing the definition of that function and addheader it.
Unless you want to call a function in Windows addheader will never be needed for windows.h. Think of addheader as "also load the functions found in this header when processing any #include statements for it"
Enums and structures will be included if needed from any header without needing an explicit addheader.

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!