ctypes error on exit of win32 application
Gabriel Genellina
gagsl-py at yahoo.com.ar
Wed Jan 31 21:49:27 EST 2007
En Wed, 31 Jan 2007 19:04:13 -0300, Rubic <rubic88 at gmail.com> escribió:
> I'm attempting to use ctypes on a DLL with the following
> signature:
>
> __declspec(dllimport) void process_record(char *, char *);
>
> An example .cpp file has code like this:
>
> int main(int argc, char **argv)
> {
> char record[100];
> char code[6];
> ...
> process_record(code, record);
>
> When I invoke it under Python everything fine
> while the interpreter is running:
>
> >>> from ctypes import *
> >>> record = create_string_buffer("My Record")
> >>> code = create_string_buffer('\000' * 6)
> >>> cdll.grouper.process_recode(code, record)
> >>> print code.value
> '9999'
>
> But when the interpreter exits, either interactively
> or from a script, the following Program Error popup
> gets displayed:
>
> "python.exe has generated errors and will be closed
> by Windows. You will need to restart the program."
Maybe process_record expects some minimum buffer size? The cpp example
uses char record[100], but you are allocating only a few bytes with the
string "My Record"
--
Gabriel Genellina
More information about the Python-list
mailing list