The error u get is valid and I agree with the fact that, that is how it should work. But in my case I don't even get to the line where I check for GetLAstError. As soon as I execute the line "EnumPorts" I get the following error from the Windows spooler
"spoolsv.exe has generated errors and will be closed by the windows. You will need to restart the program"
and it stops.
And my program terminates.
Thanks
saravana
Main Topics
Browse All Topics





by: SteveGTRPosted on 2002-09-06 at 07:15:29ID: 7267250
Is the error you specify the one returned by GetLastError()?
Here is some text from MSDN:
and the pcbNeeded parameter returns the size, in bytes, of the buffer required to hold the array of structures and their data."
I ran your code on my machine, 2000 Prof/SP3, and it returned 0 (FALSE). GetLastError() returned 122, ERROR_INSUFFICIENT_BUFFER.
"To determine the required buffer size, call EnumPorts with cbBuf set to zero. EnumPorts fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER,
I believe that this is the normal behavior when determining the buffer requirements.
Good Luck,
Steve