So at this point I need to just move on, and sending a pre-populated memoryblock works so I’m going to go with that unless someone can show me definitively how to make this work otherwise
I have tried this:
var cParam as CString = param
var cValue as new MemoryBlock(256)
returnValue = GetCameraParam(fgHandle, cParam, cValue)
//where GetCameraParam() is expecting
Private Function GetCameraParam(byref fgHandle as int32, param as CString, cValue as ptr) As int32
And the result is empty. If I put a break in my code to see what cValue contains after calling GetCameraParam, it’s all 0000s and it looks like the size is correct (256) but the value that was returned by the passed parameter is not there.
If I change cValue to have actual text in it:
var cValue as memoryblock = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Then it works, but I need to parse out the excess "~~~"s
If I change cValue to an empty cstring, and pass GetCameraParam that value, my application simply quits in the debugger.
var cParam as CString = param
var cValue as CString
returnValue = GetCameraParam(fgHandle, cParam, cValue)
//where GetCameraParam() is expecting
Private Function GetCameraParam(byref fgHandle as int32, param as CString, cValue as cString) As int32
If I do the tilde trick like I did with memoryblocks, populating cValue (as a CString with tildes), then it also crashes my app.
If I pass it an empty or populated CString, and GetCameraParam passes that to the library byref, then the result is empty (but no crash).
At this point, I need to keep moving forward. The way I’m doing it is working, but ugly. But it works. Unless I’m missing something obvious here, I don’t see how I can simply pass a CString to my library and get it to update the results. And the memoryblock only works if there’s something in it when I send it to the library, not just when it’s set to the right size.