cstring doesnot name a type

Hi

I am using this code

CString GetDefaultPrinterName()

But while compiling the code I am getting the error

"cstring doesnot name a type"

Is there any header file I am missing

IDE --> Dev-C++
OS--> WIndows XP Professional

Regards
Karan
CString is part of MFC (Microsoft Foundation Classes), which is an old object library no longer developed by MS.

You cannot compile MFC applications unless you are using VC++. (Since you are using Dev-C++, I suspect that your compiler is the MinGW port of GCC.)

Systems like MFC or Borland's VCL etc. make dealing with the printer seem much easier than it really is. Unfortunately, with GCC you must do it in pure Win32 API. Microsoft's Printing and Print Spooler reference is the place to start:
http://msdn.microsoft.com/en-us/library/ms535673%28VS.85%29.aspx

While using the Win32 API makes for more involved coding, it is actually fairly straight-forward.

Sorry for the discouraging answer. It is possible that someone has made a library to do this stuff in C++. (But I don't know of any.)
Hi

I have a query.

As I am using Dev-C++. If I want to search in google. Which keyword should I write. I normally write "printers tutorials in C++". But when I try to execute the code I encounter an error.

Kindly advice

Regards
Karan Gupta
The keywords you list brings up a lot of good hits for me.

The thing to remember is that with MinGW you have to stick to pure Win32 API functions. Anything that says MFC you cannot use. Stick to stuff that says GDI and Win32.

Also, a lot of links will be targeted at VC++, which has its own way of doing things. You must make sure to identify and remove or modify all the VC++-specific code to standard C++ code. (For example, get rid of the #include <stdafx.h> at the top.)

I am sorry there isn't a simpler answer (at least not one that I know of). Alas.
Topic archived. No new replies allowed.