|
Use the Handle returned by OpenPrinter , as the input Handle for FindNextPrinterChangeNotification
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
You seem to have missed the point ... I know openprinter returns a handle which is then used by FindFirstPrinterChangeNotification which itself returns a handle which is then used by the FindNextPrinterChangeNotification api. I've written out several items including the handle values, which are correct and don't change between the FindFirst and FindNext calls, but the FindNext call always errors with an invalid handle - but why with network printers ?
|
|
|
|
|
Did u get the answer for this...if yes please post it ...
|
|
|
|
|
Sorry no never got it working, abandoned the project a year or so ago.
|
|
|
|
|
Hey finally got the fix for this...
open windows firewall(run->firewall.cpl)
open advanced tab and check file and printer sharing option
Let me know if you face any problem with this...
|
|
|
|
|
hi,I have got this problem,
The situation is I have close my firewall,
and the printer is a network printer
when I look up the property of the printer, its port is USB002,
so, I don't know how to fix it,
can anyone help?
|
|
|
|
|
P Gibson wrote: ...my application fails with an Invalid Handle from the FindNextPrinterChangeNotification api call.
What does GetLastError() return?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Using the tried and trusted ErrorBox method as follows
void ErrorBox (DWORD dwError, LPCSTR lpString)
{
#define MAX_MSG_BUF_SIZE 512
char *msgBuf;
DWORD cMsgLen;
cMsgLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ALLOCATE_BUFFER | 40,
NULL, dwError,
MAKELANGID(0, SUBLANG_ENGLISH_US),
(LPTSTR) &msgBuf, MAX_MSG_BUF_SIZE,
NULL);
MessageBox( NULL, msgBuf, lpString, MB_OK );
LocalFree( msgBuf );
#undef MAX_MSG_BUF_SIZE
it displays ... each and every time for a network printer !
The handle is invalid.
|
|
|
|
|
Ok, is the call to FindFirstPrinterChangeNotification() fine?
What do the calls to OpenPrinter() and WaitForSingleObject() look like?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
here is my code, I have taken out some debug strings, but the printername is valid as are the values of the handles returned. The code has been taken from the Microsoft Printmon example with just a few changes as I am using this in a class, hence the use of 'this'
// setup printer name
strcpy (pPrinterName, this->m_PrinterName);
// open Printer, if access denied return
ZeroMemory (&pd, sizeof (pd));
pd.DesiredAccess = PRINTER_ACCESS_USE;
if((nReturn = OpenPrinter (pPrinterName, &hPrinter, &pd)) == ERROR_ACCESS_DENIED) return FALSE;
// initialize local copy of the printer queue data
ZeroMemory (&Queue, sizeof(Queue));
Queue.Printer.hPrinter = hPrinter;
GetQueue (&Queue);
// prepare for notifications, we want when a job is added, check for an error
hPrinterNotification = FindFirstPrinterChangeNotification (hPrinter, PRINTER_CHANGE_JOB, 0, &NotificationOptions);
if (hPrinterNotification == INVALID_HANDLE_VALUE) return 0;
Queue.Printer.hPrinterNotification = hPrinterNotification;
// loop while we are stilling waiting on Notifications
while (Queue.Printer.hPrinterNotification != INVALID_HANDLE_VALUE)
{
if (WaitForSingleObject (Queue.Printer.hPrinterNotification, INFINITE) == WAIT_OBJECT_0)
{
// get the changes and reset the notification
if (!FindNextPrinterChangeNotification (Queue.Printer.hPrinterNotification, &dwWaitResult, &NotificationOptions, (void **)&pNotification))
{
ErrorBox(GetLastError(), "FindNextPrinterChangeNotification ...failed\r\n");
}
Note also that the Printmon example also fails at the FindNextPrinterChange call with an invalid handle when the printer is a network one, so the error is consistent.
|
|
|
|
|
In c++ and c, use LPCTSTR p = "string" or const TCHAR p[] = "string", which better and why?
|
|
|
|
|
using LPCTSTR, you only have a pointer.
using const TCHAR[], you have a tab, which size is set at the first allocation. so after that, if you affect the tab to another string, it could be truncated or throw an overflow access.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I don't find any difference.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Both of them are creating data at stack memory. I'm not feeling any differnce!!!
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
That's partially correct.
The "string" litteral, in fact, stays in the BSS segmment (where all costant reside on the disk), loaded in memory as part of the EXE and exist for the entire life of the process.
It's acessiblilty happens trhoug an on-stack variable that is declared as a pointer to the BSS (first case) or as an array (on-stack) that is a copy of what stays in the BSS.
The most of the compiler optimize this (unspec. array size) by transforming such array into ... a pointer(!)
Just try to watch in the debugger what the pointer points to and what is the array address in bopth the case you don't declare a size or you do.
Then, declare an int just before the array and look its address: is it 4 bytes before the first array element?
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
|
See here.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hello folks, I need your help:
I need to know the Ethernet Permanent Mac Address
and I would like to know how to detect if a ethernet
card is :
1) removable (tipical of laptop) or fixed (on the bus)
2) on board on a dockin station
3) avoid mac addres like 00-53-45-00-00-00 (wireless
card??)
Im work with devstudio C++ 7.1
Can you help me ?its very urgent
Thank you a lot in advance for any suggestion/help
Mario
|
|
|
|
|
|
Dear All.
I want to write the MATLAB function cp2tform in C/C++.
Can anyone help me out with the logic.
Precisely , I want to implement the projective transformation. So if there is any other algorithm then also suggest me.
Thanks in advance.
Arun
|
|
|
|
|
Hi all,
What does the WaitForDebugEvent function do? I read it in MSDN, but didn't get a clue as to what it does? Can someone explain?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
I think tihs function is only required if u r creating some debugger related stuff.
See the remarks section in MSDN.
Only the thread that created the process being debugged can call WaitForDebugEvent
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
|
|
#include <stdio.h><br />
<br />
int *pPointer;<br />
<br />
void SomeFunction()<br />
{<br />
int nNumber;<br />
nNumber = 25; <br />
<br />
pPointer = &nNumber;<br />
}<br />
<br />
void main()<br />
{<br />
SomeFunction();
<br />
printf("Value of *pPointer: %d\n", *pPointer);<br />
}
Hi friends,
the above code is working without any problems in VC6.
But it should fail at the line printf("Value of *pPointer: %d\n", *pPointer);
because pPointer is pointing to a local variable,which is already deleted.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|