I'm trying to get a pointer to a string
, where the pointer is of type int
. I'm not sure if I'm doing it correctly. I just found out yesterday about unsafe and fixed, so I'm still questioning this a bit. Can I just cast the char*
to int
? I'm not getting any errors, but the methods are not working, so I'm not sure if the pointer is wrong or if I'm doing something wrong with the 3rd party OCX (for which there's no support).
3rd Party Documentation for C++ calls:
BlobToVariant(VARIANT *pV, long BlobPointer)
WriteVToFile(VARIANT *pV)
What VS2010 C# Intellisense says:
BlobToVariant(ref object v, int BlobPointer)
WriteVToFile(ref object v)
Here is my code:
string imageBlob = "superlongstring";
// 3rd Party ActiveX control for tiff image files
TIFFLib.TIFF tiff = new TIFFLib.TIFF();
// Variant object that will hold image
object blobVariant = new object();
unsafe
{
fixed (char* p = imageBlob)
{
int blobPointer = (int)p;
tiff.BlobToVariant(ref blobVariant, blobPointer);
tiff.WriteVToFile(ref blobVariant);
}
}