c# - Convert intptr to ulong array -


i calling method c# this:

[dllimport(@"phash.dll", callingconvention = callingconvention.cdecl)] public static extern intptr ph_dct_videohash(string file, ref int length); 

and here method calling library

ulong64* ph_dct_videohash(const char *filename, int &length){      cimglist<uint8_t> *keyframes = ph_getkeyframesfromvideo(filename);     if (keyframes == null)         return null;      length = keyframes->size();      ulong64 *hash = (ulong64*)malloc(sizeof(ulong64)*length);     //some code fill hash array     return hash; } 

how can read ulong array intptr?

consider using unsafe code:

intptr pfoo = ph_dct_videohash(/* args */); unsafe {     ulong* foo = (ulong*)pfoo;     ulong value = *foo;     console.writeline(value); } 

Comments