I am modifying the WDK "genprint" Print Processor example. Everything is working great, and I can compile fine, but I am running into a snag with one thing.
Part of my modification knowingly triggers a print error, and Windows re-submits the print job automatically in the spool. I need to track the number of "copies" the user requested. I decided to put it in a text file, which I would decrement with each completed print.
Of course, having coded in PHP for so long, I have gotten VERY sloppy with data types (last real C programming was in 94). I can read and write into the file, but somewhere, somehow, I'm botching it up on the data type.
Code to READ the file in (strVal is a char):
hFile = CreateFile(cfnDest,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(ReadFile(hFile,strVal,1024,&wmWritten,NULL)) {
nCopies=(int)strVal;
}
CloseHandle(hFile);
But nCopies is not an int like I want it. Please excuse my ignorance, but I am just trying to get the char strVal[1024] into an int.
Code that writes into the file:
StringCchPrintf(pszDest, cchDest, TEXT("%d"),nCopies);
hFile = CreateFile(cfnDest,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
WriteFile(hFile,pszDest,(DWORD)(sizeof(pszDest)),&wmWritten,NULL);
CloseHandle(hFile);
When I open the file in notepad.exe, the number from nCopies is there... so, this part works... I think.
Any help would be GREATLY appreciated.