Why do I get this error?

T

trint

Here's the code:

bool GetJobs(HANDLE hPrinter, /* Handle to the printer. */

JOB_INFO_2 **ppJobInfo, /* Pointer to be filled. */
int *pcJobs, /* Count of jobs filled. */
DWORD *pStatus) /* Print Queue status. */

{

DWORD cByteNeeded,
nReturned,
cByteUsed;
JOB_INFO_2 *pJobStorage = NULL;
PRINTER_INFO_2 *pPrinterInfo = NULL;



}

the error is here:

bool GetJobs(HANDLE <<<<<on handle

here is the error:

error CS0246: The type or namespace name 'HANDLE' could not be found
(are you missing a using directive or an assembly reference?)
Thanks,
Trint
 
W

Willy Denoyette [MVP]

It looks like you are compiling C code using a C# compiler, C# is no C.
HANDLE and DWORD are C style typedef, their equivalent types are IntPtr and
uint respectively.
JOB_INFO_2 is a C style struct, how did you declare it in your code?
pointer dereferences (*) denotes an unsafe code block and needs to be
compiled using the /unsafe compiler switch.

Willy.
 
T

trint

I know...I've been banging my head for a week trying to moniter the
status of a laserjet printer. Looks like it isn't possible.
Thanks,
 
W

Willy Denoyette [MVP]

trint said:
I know...I've been banging my head for a week trying to moniter the
status of a laserjet printer. Looks like it isn't possible.
Thanks,

Wouldn't it be better to ask precise questions instead of posting a snip of
C code and ask why you get an error when compiling it with another language
compiler?
Sure it is possible to get a printer status, for local connected and network
shared printers you can get all you need using System.Management and WMI,
search for "Win32_Printer" in MSDN and check the System.Management namespace
documentation.

Willy.
 
B

Bruce Wood

Just for future reference, you might want to include more information
in your posts. You'll get more helpful responses that way.

Without writing a novel, you should state what you're trying to do
(overall): "I'm trying to monitor the status of a laserjet printer."
Then include a brief summary of how you solved the problem including a
code snippet if that is relevant. "I decided to use the GetJobs()
routine from the Win32 API. Here is the code." Then, finally, a
description of what is going wrong: "The compiler is giving me this odd
error."

That way, readers understand more context. Perhaps there is a
completely different way of going about what you're trying to do, and
the code snippet is irrelevant to the final solution. Or perhaps in
order to understand the code snippet one has to understand the overall
problem.

I'm not trying to slam you, just help you get better information next
time you have a problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top