Hi ALL
Please check the code below. OpenPrinter method returns Access is Denied error. Serial Printer is connected to the the IP address with name given at COM1
public enum ACCESS_MAS
PRINTER_ACCESS_ADMINISTER = 4
PRINTER_ACCESS_USE = 8
PRINTER_ALL_ACCESS = 98305
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)
public struct PRINTER_DEFAULTS
public string strDataType
public IntPtr ptrDevMode;
public ACCESS_MASK eDesiredAccess
[DllImport("winspool.drv", EntryPoint="OpenPrinterA", SetLastError=true, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)
public static extern long OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string strPrinterName, out IntPtr phPrinter, ref PRINTER_DEFAULTS pdDefaults)
public void TestPrint(string strData
IntPtr ptrPrinter;
PRINTER_DEFAULTS pdDefaults = new PRINTER_DEFAULTS();
pdDefaults.eDesiredAccess = ACCESS_MASK.PRINTER_ACCESS_ADMINISTER;
long lReturn = OpenPrinter("\\\\111.11.11.11\\Code 39", out ptrPrinter, ref pdDefaults
if(lReturn == 0 || ptrPrinter == IntPtr.Zero
{
int intError = Marshal.GetLastWin32Error()
Marshal.ThrowExceptionForHR(unchecked((int)0x80070 000 | Marshal.GetLastWin32Error()))
Note: Also can anybody tell me the link to get the exact declaratons of these APIs
Please help. Thanx in advance