dumb question...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Need said:
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
 
Need said:
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
 
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
 
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 said:
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 said:
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
 
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!
 
Back
Top