473,382 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Why do I get this error?

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

Nov 16 '05 #1
4 2228
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.

"trint" <tr***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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

Nov 16 '05 #2
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,
Trint
Willy Denoyette [MVP] wrote:
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.

"trint" <tr***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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


Nov 16 '05 #3


"trint" <tr***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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.

Nov 16 '05 #4
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.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include...
0
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
2
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template...
2
by: khalidanwar123 | last post by:
i am getting the following error while updating a clob field. ERROR java.sql.SQLException: Data size bigger than max size forthis type: 4003 19:28:27,499 ERROR at...
15
by: madhu.ab | last post by:
Hi All, I am getting the following errors when i am including header file winuser.h I dont know whats happening. How will an error occur in winuser.h?? Please help. \microsoft visual...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.