I have function getMemory() which returns VARIANT (mfc).
It is said that in ulVal member is pointer to memory i need to access.
int m_memAddr = object.getMemory().ulVal; //get pointer to memory
Then I need to have this pointer into char*
I’ve tried
char* pointer = (char*)m_memAddr;
It compile but I get error when program running.
How to debug it?
Function getMemory:
VARIANT object::getMemory()
{
VARIANT result;
InvokeHelper(0x4a, DISPATCH_METHOD, VT_VARIANT, (void*)&result, NULL);
return result;
}
//edited from documentation of camera lib i use:
VARIANT GetImageMem()
Description
GetImageMem() returns the pointer to the starting adress of the internal image memory where the image is stored. If you use ring buffering, GetImageMem() returns the starting address of the image memory last used for image capturing.
The pointer to the image memory is returned in the element ulVal of the VARIANT data type.
Parameters
Return values
Pointer to the image memory in ulVal of the VARIANT data type.
This is description of functions which returns memory where my camera store image.
I want to process this image with OpenCV so i need char* to set it as IplImage imageData.
Now I hope it’s more clear what is the problem.
From the documentation
You are passing NULL for
pbParamInfo, which I assume means that no data will be stored in the returned variant, so of course the pointer is invalid.If you follow the documentation further, you find that passing
VTS_BSTRspecifies that you can initialize the variant with a pointer-to-char (pass that as the next argument after pbParamInfo).