Call to unmanaged dll function
-
Does anybody know what is the problem in the below code. The InPtr returned by the funcion is always 0 means null. Why? //////////////// public class ThumbnailExtractor { [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acdbGetPreviewBitmap@@YAPAUtagBITMAPINFO@@PB_W@Z")] extern static private IntPtr acdbGetPreviewBitmap(string filename); static Bitmap GetBitmapFromDwg(string filename) { return Marshaler.BitmapInfoToBitmap(acdbGetPreviewBitmap(filename)); } public Bitmap GetImage(string filename) { return GetBitmapFromDwg(filename); } } /////////////////// Thanks in advance
-
Does anybody know what is the problem in the below code. The InPtr returned by the funcion is always 0 means null. Why? //////////////// public class ThumbnailExtractor { [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acdbGetPreviewBitmap@@YAPAUtagBITMAPINFO@@PB_W@Z")] extern static private IntPtr acdbGetPreviewBitmap(string filename); static Bitmap GetBitmapFromDwg(string filename) { return Marshaler.BitmapInfoToBitmap(acdbGetPreviewBitmap(filename)); } public Bitmap GetImage(string filename) { return GetBitmapFromDwg(filename); } } /////////////////// Thanks in advance
Not sure where this acdb17.dll is coming from, but the EntryPoint is looking really strange. In most cases you can simply p/invoke functions from Win32 DLLs by just declaring the static method with the same name as the function in the DLL. The EntryPoint attribute is only neccessary if you want to (or have to) name you function differently. So I'd suggest trying:
[DllImport("acdb17.dll")]
extern static private IntPtr acdbGetPreviewBitmap(string filename);Does it work then?
Regards, mav -- Black holes are the places where god divided by 0...