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

3 ビュー (過去 30 日間)
Jason
Jason 2015 年 8 月 18 日
編集済み: Philip Borghesani 2015 年 8 月 18 日
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 件のコメント
Philip Borghesani
Philip Borghesani 2015 年 8 月 18 日
編集済み: Philip Borghesani 2015 年 8 月 18 日
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.

サインインしてコメントする。

回答 (1 件)

Philip Borghesani
Philip Borghesani 2015 年 8 月 18 日
編集済み: Philip Borghesani 2015 年 8 月 18 日
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.

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by