MATLAB: How to retrieve a BOOL type value returned from a .dll function

booleanccalllibdlldriverexternal interfacelib.pointerlibrarypointer

Hi! I'm new to the external interface tools of MATLAB and I'm not very familiar with C/C++ so I was wondering if anyone here has experience.
I'm writing a control script for a near-infrared camera, which came with a driver .dll file and a brief description of the functions within it.
For example, I have a function described as:
BOOL DLL_Get_Spectra(double* pdblData, double* pdblCaseTemperature);
Description: Acquire one snapshot spectrum.
Parameter: double* pdblData: Pointer of spectrum power array allocated by the user (Buffer size >= pixel count)
double* pdblCaseTemperature: Pionter of case temperature.
Return value: Boolean TRUE: Operation completed FALSE: Operation failed
After loading dll and using libfunction, we see that the library is loaded without any problems:
[lib.pointer, doublePtr] DLL_Get_Wavelenth(double, doublePtr)
I have read how to pass pointers into MATLAB, but not much on how to read pointers from MATLAB, do I just use doublePtr.Value?
Also, MATLAB does not have a BOOL type, so how am I suppose to read the returned lib.pointer as TRUE or FALSE?
Thanks!

Best Answer

That function should not be returning a lib.pointer to MATLAB something went wrong loading the dll. What warnings were reported when loading the library?
BOOL is not a traditional c data type and should be returned to MATLAB as a simple number 0 for false and 1 for true. However a header file is frequently needed to define BOOL for a library. In this case I expect the library header expects windows.h to be included before it is used.
You can fix the header file by adding appropriate typedefs or includes. Or you can generate a prototype file and fix that using uint8 or logical as the data type.
Related Question