Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Problems with ctypes in Python 2.4.4 in Windows 7
  2. #include <string.h>
  3.  
  4. struct config_info_t {
  5.     unsigned int count;
  6.     char string[64];
  7. };
  8.  
  9. struct config_info_t conf;
  10.  
  11. __declspec(dllexport) int set_global_config(struct config_info_t * cfg)
  12. {
  13.     conf.count = cfg->count;
  14.     strcpy(conf.string, cfg->string);
  15.     return 0;
  16. }
  17.        
  18. from ctypes import *
  19. Dll = WinDLL ("test.dll")
  20.  
  21. class CONFIG_INFO(Structure):
  22.    _fields_ = [("count", c_int),
  23.                ("string", c_char * 64)]
  24. cfg = CONFIG_INFO(10, "somesh")
  25. result = Dll.set_global_config(byref(cfg))