Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

CristiFati
Copy link

The main one is setting functions argtypes and restype. Modern Python versions raise an exception:

Traceback (most recent call last):
  File "..\..\GitHub\CristiFati\code\recipes\Python\305690_Enumerate_printer_job\recipe-305690.py", line 194, in <module>
    prt.EnumJobs(pJob, prt.pcbNeeded)
  File "..\..\GitHub\CristiFati\code\recipes\Python\305690_Enumerate_printer_job\recipe-305690.py", line 164, in EnumJobs
    ret = ws.EnumJobsA(self.OpenPrinter(),
ctypes.ArgumentError: argument 5: <class 'OverflowError'>: int too long to convert

preventing funky Undefined Behaviors: [SO]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer).

I'm not sure how some of the code worked (if it did). Still uncertain about ReadPrinter part.

There are other problems to be addressed:

  • Some harcodings (int values)
  • Error checking (via GetLastError)
  • Some structures are out of date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant