MATLAB: Do I get strange results from a calllib() operation

callliblibpointerlong

I have a DLL function (called DLLStatus) I am accessing using the calllib() operation. An extract from the dll header file for the function is:
long __cdecl DLLStatus(char *errStr, int errStrLen, void *module);
The result of loadlibrary() shows no errors/warnings. The libfunctions() command shows the following result for this function:
[long, cstring, voidPtr] DLLStatus(cstring, int32, voidPtr)
The following code initializes the inputs and makes the call to the library
[notfound,warnings] = loadlibrary('CCDriver','CCDriver.h','alias','CCLib');
pErrStr = libpointer('cstring', repmat('0',255,1));
pModule = libpointer('voidPtr');
[status, pErrStr, pModule ] = calllib('CCLib','DLLStatus', pErrStr, 255, pModule );
The Lib call executes without any warnings or errors. However the value of "status" is quite peculiar. It's data type should be 'long' (which equates to int32 on windows). The following code:
get(status)
results in this output:
CallbackObject = []
CommandWindowSize = [136 40]
CurrentFigure = []
Diary = off
... lots of other elements ...
Type = root
UIContextMenu = []
UserData = []
Visible = on
But seeing as I was expecting a numeric value, this is quite confusing. It appears now that "status" is a class of some sort. Does anyone know why I see this instead of a simple long/int32 output? When I check the data type of result using "class(status)" it confirms that the data type is 'long'.
Also another quirk that I am yet to understand is when I do:
get(pModule)
Does not return any value or output (not even a 0 (zero)). Any ideas regarding this as well?
Thanks in advance. Kane.

Best Answer

If you are expecting status to be numeric, you should not be using get() on it. When you use get() of a numeric value, you are asking for the information associated with the Handle Graphics Object that has that numeric handle. In your case status is coming out as 0, so you are doing get(0) and so getting the information for the root of the handle graphics system.