I'm trying to call the GetJob() method documented here. I think I'm having problems with the syntax of the routine right now, both calling and defining. I've finally got something to compile which is the following.
[DllImport(
"winspool.drv",
EntryPoint = "GetJob",
SetLastError = true,
CharSet = CharSet.Ansi,
ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
private static extern bool GetJob
([InAttribute()] IntPtr hPrinter,
[InAttribute()] Int32 JobId,
[InAttribute()] Int32 Level,
[OutAttribute()] out byte[] pJob,
[InAttribute()] Int32 cbBuf,
[OutAttribute()] out Int32 pcbNeeded);
...
...
...
...
const int BUFFER_SIZE = 250;
int pcbNeeed = 0;
unsafe
{
byte[] byteBuffer = new byte[BUFFER_SIZE];
bResult = GetJob(m_PrinterHandle, jobID, 1, out byteBuffer, BUFFER_SIZE, out pcbNeeed);
}
According to the documentation here, it seems I should be able to use a byte[] without any special marshaling code because it is "blittable". In anycase, I get a runtime exception that says:
Unable to find an entry point named 'GetJob' in DLL 'winspool.drv'. at NQBB.Printer.PrintQueueMonitor.PrinterWatcher.GetJob(IntPtr hPrinter, Int32 JobId, Int32 Level, Byte[]& pJob, Int32 cbBuf, Int32& pcbNeeded)
I think I just have some syntax wrong here. Can anyone see the problem?