I am writing a dll which receives a picture box'handle in a call like:
**Declare Sub ERPInitialize Lib "C:\Desenv\EBioNet\EBioNet\Debug\ERPDll.dll" (ByVal PicHandle As Long)**
and it is called in this way:
**Call ERPInitialize(PictureBox1.Handle)**
I would like to store this handle and get back the PictureBox1's managed pointer back from the stored handle so that I can draw an image on it.
Any clue? Thanks in advance
If I pass PictureBox^ in the the call ERPInitialize I cannot stored it, for later use as a global, because managed pointers are not allowed in CLR.
I tried
PictureBox ^_pbPic;
IntPtr Ptr_Picturebox = (IntPtr)PictureHWD;
GCHandle handle2 = (GCHandle)Ptr_Picturebox;
_pbPic = (PictureBox ^ )(handle2.Target);
but it causes an exception 0xc0000005.