I am just learning about API functions and writing a simple program to send data to the printer. Here is what I have so far
This is giving me a linker error - undefined reference to all seven printer functin calls. I have heard I have to link with 'winspool.lib' so I put this inCode:#include <iostream>
#include <windows.h>
#include <winspool.h>
using namespace std;
int main()
{
char test[] = "This is a test line to be printed.";
LPHANDLE hPrinter;
LPBYTE DocInfo;
LPVOID Buff = test;
DWORD read;
LPDWORD written;
OpenPrinter("HP DeskJet 712C", hPrinter, NULL);
StartDocPrinter(hPrinter, 1, (LPBYTE)&DocInfo);
StartPagePrinter(hPrinter);
WritePrinter(hPrinter, Buff, read, written);
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
cout<<"Test line sent to printer"<<endl
<<"Hit <enter> to end";
cin.get();
return 0;
}
but still get the same linker error. I did a search in my compiler directories and could not find 'winspool.lib' but there was a 'libwinspool' in my lib directory. Tried that with the same linker error. Are those two files the same or different? Or is there something else wrong?Code:#pragma comment(lib, "winspool.lib")
I am using DEV-C++