The main use of the EnumPrinters function in Winspool.drv, the code is as follows:
[DllImport ("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)]
[Return:marshalas (Unmanagedtype.bool)]
private static extern bool EnumPrinters ([MarshalAs (UNMANAGEDTYPE.U4)] Printer_enum flags,
[MarshalAs (UNMANAGEDTYPE.LPSTR)] string sname,
UINT Ilevel,
IntPtr Pprinterdesc,
UINT Isize,
[MarshalAs (UNMANAGEDTYPE.U4)] ref UINT ineeded,
[MarshalAs (UNMANAGEDTYPE.U4)] ref UINT ireturned
);
Description: The Marshal property provides marshaling of data to managed and unmanaged code.
The EnumPrinters WIN32 API is defined as follows:
BOOL EnumPrinters (
DWORD Flags,//Printer object types
LPTSTR name,//Name of printer object
DWORD level,//information level
Lpbyte Pprinterenum,//printer information buffer
DWORD cbbuf,//size of printer information buffer
Lpdword pcbneeded,//bytes received or required
Lpdword pcreturned//Number of printers enumerated
);