G
Gordon Truslove
Has anybody managed to get GetPrinter and PRINER_INFO_2 to work?
I would like to retrieve the printer status.
I would like to retrieve the printer status.
Nicholas Paldino said:Gordon,
What are the definitions you are using? The PRINTER_INFO_2 structure
has a lot of information (if you include the DEVMODE structure as well), and
there could be errors in how you are accessing it.
Can you show the definitions that you have?
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com
Gordon Truslove said:Has anybody managed to get GetPrinter and PRINER_INFO_2 to work?
I would like to retrieve the printer status.
Gordon Truslove said:I've tried about 3-4 variations. Here is the biggest. I've tried avoiding
the devmode and security descriptor but it still fails.
[ DllImport("winspool.drv" )]
public static extern bool GetPrinter(IntPtr hPrinter,long Level,ref
PRINTERINFO2 pPrinter,long cbBuf,ref long pcbNeeded);
[StructLayout( LayoutKind.Sequential)]
public struct PRINTERINFO2
{
[MarshalAs(UnmanagedType.LPWStr)]public string pServerName;
[MarshalAs(UnmanagedType.LPWStr)]public string pPrinterName;
[MarshalAs(UnmanagedType.LPWStr)]public string pShareName;
[MarshalAs(UnmanagedType.LPWStr)]public string pPortName;
[MarshalAs(UnmanagedType.LPWStr)]public string pDriverName;
[MarshalAs(UnmanagedType.LPWStr)]public string pComment;
[MarshalAs(UnmanagedType.LPWStr)]public string pLocation;
public DEVMODE pDevMode;
[MarshalAs(UnmanagedType.LPWStr)]public string pSepFile;
[MarshalAs(UnmanagedType.LPWStr)]public string pPrintProcessor;
[MarshalAs(UnmanagedType.LPWStr)]public string pDatatype;
[MarshalAs(UnmanagedType.LPWStr)]public string pParameters;
public SECURITY_DESCRIPTOR pSecurityDescriptor;
public long Attributes;
public long Priority;
public long DefaultPriority;
public long StartTime;
public long UntilTime;
public long Status;
public long cJobs;
public long AveragePPM;
}
[StructLayout( LayoutKind.Sequential)]
public struct SECURITY_DESCRIPTOR{
public byte Revision;
public byte Sbz1;
public long Control;
public long Owner;
public long Group;
public ACL sACL;
public ACL Dacl;
}
[StructLayout( LayoutKind.Sequential)]
public struct ACL{
public byte AclRevision;
public byte Sbz1;
public int AclSize;
public int AceCount;
public int Sbz2;
}
[StructLayout( LayoutKind.Sequential)]
public struct DEVMODE{
public string dmDeviceName;
public int dmSpecVersion;
public int dmDriverVersion;
public int dmSize;
public int dmDriverExtra;
public long dmFields;
public int dmOrientation;
public int dmPaperSize;
public int dmPaperLength;
public int dmPaperWidth;
public int dmScale;
public int dmCopies;
public int dmDefaultSource;
public int dmPrintQuality;
public int dmColor;
public int dmDuplex;
public int dmYResolution;
public int dmTTOption;
public int dmCollate;
public string dmFormName;
public int dmLogPixels;
public long dmBitsPerPel;
public long dmPelsWidth;
public long dmPelsHeight;
public long dmDisplayFlags;
public long dmDisplayFrequency;
public long dmICMMethod;
public long dmICMIntent;
public long dmMediaType;
public long dmDitherType;
public long dmReserved1;
public long dmReserved2;
}
in message news:%[email protected]...Gordon,
What are the definitions you are using? The PRINTER_INFO_2 structure
has a lot of information (if you include the DEVMODE structure as well), and
there could be errors in how you are accessing it.
Can you show the definitions that you have?
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com
Gordon Truslove said:Has anybody managed to get GetPrinter and PRINER_INFO_2 to work?
I would like to retrieve the printer status.