[DllImport("winspool.drv", SetLastError=true)]
public static extern bool GetPrinter(IntPtr hPrinter, Int32 dwLevel, IntPtr pPrinter, Int32 dwBuf, out Int32 dwNeeded);
[DllImport("winspool.drv", SetLastError=true)]
public static extern bool GetPrinter(IntPtr hPrinter, uint dwLevel, IntPtr pPrinter, uint dwBuf, ref uint dwNeeded);
Declare Function GetPrinter Lib "winspool.drv" (TODO) As TODO
None.
None.
Please add some!
IntPtr pHandle;
PRINTER_DEFAULTS defaults = new PRINTER_DEFAULTS();
OpenPrinter(PrinterName, out pHandle, defaults);
uint cbNeeded = 0;
bool bRet = GetPrinter(pHandle, 2, IntPtr.Zero, 0, ref cbNeeded);
if (cbNeeded > 0)
{
IntPtr pAddr = Marshal.AllocHGlobal((int)cbNeeded);
bRet = GetPrinter(pHandle, 2, pAddr, cbNeeded, ref cbNeeded);
if (bRet)
{
PRINTER_INFO_2 Info2 = new PRINTER_INFO_2();
Info2 = (PRINTER_INFO_2)Marshal.PtrToStructure(pAddr, typeof(PRINTER_INFO_2));
// Now use the info from Info2 structure etc
}
Marshal.FreeHGlobal(pAddr);
}
ClosePrinter(pHandle);
Do you know one? Please contribute it!