Hi...
I'm new to c# and got some problems in rewriting "C" code in "C#".
I got this error message "You can only take the address of an unfixed expression inside of a fixed statement initializer" and i'm not sure whats wrong??? can anybody light my path?
here's the "C" code:
and this is what i have done so far:
I'm new to c# and got some problems in rewriting "C" code in "C#".
I got this error message "You can only take the address of an unfixed expression inside of a fixed statement initializer" and i'm not sure whats wrong??? can anybody light my path?
here's the "C" code:
Code:
USHORT APIENTRY16 PrtOpenDevice (HFILE * _Seg16 PrtHandle, USHORT PrtDriver); HANDLE PrtHandle; /* Printer handle */ USHORT PrtDriver; /* Logical device driver */ USHORT rc; /* Return code */ PrtDriver = 1; /* 1st logical device driver */ rc = PrtOpenDevice (&PrtHandle, PrtDriver);
Code:
unsafe public partial class Form1 : Form { [System.Runtime.InteropServices.DllImportAttribute("WNTDFPRT.DLL", EntryPoint = "PrtOpenDevice")] public static extern ushort PrtOpenDevice([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.U8)] long *PrtHandle, ushort pPort); public long PrtHandle = 0; public Form1() { InitializeComponent(); ushort rc = PrtOpenDevice(&PrtHandle, 1); MessageBox.Show("return code : " + rc.ToString()); } }
Comment