By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

dumb question...

P: n/a

This might be an extremely dumb question; I'm new to Visual C++, and am trying to use the simple Spooler API, OpenPrinter, but when I try to compile my source file, it says OpenPrinter is an undeclared identifier. Here's how I'm trying to use it

HANDLE newPrinter = NULL
BOOL op = OpenPrinter(ps09, &newPrinter, NULL)

Now, as far as I'm concerned there should be nothing wrong with that code, but does anyone else know what might be the problem? I'm using Visual C++ 6.0 on Windows XP. Thanks

Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Need Help wrote:
This might be an extremely dumb question; I'm new to Visual C++, and
am trying to use the simple Spooler API, OpenPrinter, but when I try
to compile my source file, it says OpenPrinter is an undeclared
identifier. Here's how I'm trying to use it:

HANDLE newPrinter = NULL;
BOOL op = OpenPrinter(ps09, &newPrinter, NULL);

Now, as far as I'm concerned there should be nothing wrong with that
code, but does anyone else know what might be the problem? I'm using
Visual C++ 6.0 on Windows XP. Thanks!


Did you #include <windows.h>?

-cd
Nov 17 '05 #2

P: n/a
Need Help wrote:
Yes, windows.h was included. There isn't anything other than that I
should have to include to get OpenPrinter, right?


Nope. The following compiles:

// Code
#include <Windows.h>

int main()
{
HANDLE hPrinter;
OpenPrinter("",&hPrinter,NULL);
}
// End of code

Exactly what error(s) are you getting?

-cd

Nov 17 '05 #3

P: n/a
Here's the error I got
error C2065: 'OpenPrinter' : undeclared identifie

My boss suggested it might have something to do with the fact that I'm not an administrator on the machine, and that perhaps this API tries to do something with the registry that I don't have access to. He's going compiling it on his and see if it works there. Thanks

----- Carl Daniel [VC++ MVP] wrote: ----

Need Help wrote
Yes, windows.h was included. There isn't anything other than that
should have to include to get OpenPrinter, right


Nope. The following compiles

// Cod
#include <Windows.h

int main(

HANDLE hPrinter
OpenPrinter("",&hPrinter,NULL)

// End of cod

Exactly what error(s) are you getting

-c


Nov 17 '05 #4

P: n/a
No, the compiler knows nothing about who is and isn't an administrator, so
that can't be it (which doesn't mean that it won't work on your boss'
machine).

Can you post a complete example that doesn't compile for you? (Something
small - not your entire app. Frequently attempting to make a small program
that reproduces the problem will lead you to discover what's really wrong).

-cd

Need Help wrote:
Here's the error I got:
error C2065: 'OpenPrinter' : undeclared identifier

My boss suggested it might have something to do with the fact that
I'm not an administrator on the machine, and that perhaps this API
tries to do something with the registry that I don't have access to.
He's going compiling it on his and see if it works there. Thanks!

----- Carl Daniel [VC++ MVP] wrote: -----

Need Help wrote:
> Yes, windows.h was included. There isn't anything other than

that I > should have to include to get OpenPrinter, right?

Nope. The following compiles:

// Code
#include <Windows.h>

int main()
{
HANDLE hPrinter;
OpenPrinter("",&hPrinter,NULL);
}
// End of code

Exactly what error(s) are you getting?

-cd

Nov 17 '05 #5

P: n/a
It turned it just some goofy pre-compiled header that Visual C++ adds in for you. I got rid of it and now it works fine. Thanks for your help!
Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.