Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC Python DLL scripting , +
I am currently planning to access my MFC Dialog based application's .dll file using Python. I am new to Python and have the latest version of Python installed i.e. 3.2. I have installed PythonWin as well, but not really sure if it would be useful or not. I have understood like the basics of using python with the help of ctypes. In my dll file, I have two functions:
 
double BoxArea(double L, double H, double W);
 
double BoxVolume(double L, double H, double W);
and I have used the extern dllimport command to access these in my mfc dialog application.
 
extern "C" __declspec(dllexport)void BoxProperties(double Length, double Height,
                                    double Width, double& Area, double& Volume);
 
All that works fine when trying to access with another mfc program. Now, I am trying to access those two functions using Python. Could anyone suggest me how should I go about and what commands would directly let me access it?
 
Many thanks in advance.
Posted 9-Sep-11 2:31am
Edited 9-Sep-11 2:55am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Google reveals all.
 
A skinned dialog in Python and MFC[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Haven't used Python myself, yet my famous Google skills yielded some results.
Googling "python call dll"[^] and reading the first couple of hits seems to indicate ctypes is what you need.
15.17. ctypes - A foreign function library for Python[^]
  Permalink  
v2
Comments
Mobile.Instinct at 9-Sep-11 8:43am
   
I am aware of the fact that I would be required to use ctypes, but somehow I am unable to understand the way I am supposed to go about it. I have a sample program and I want to try using ctypes to access the "BoxProperties" function but no luck so far.
   
The link I gave you to the codeproject article shows EXACTLY how to do it. You just have to read the article to find the name of the source file in which the code is actually located.
Simon Bang Terkildsen at 9-Sep-11 9:16am
   
Yeah like John says read his answer, he points you to a concrete example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 398
1 DamithSL 255
2 OriginalGriff 230
3 Zoltán Zörgő 149
4 Dave Kreskowiak 120
0 OriginalGriff 7,575
1 DamithSL 5,529
2 Sergey Alexandrovich Kryukov 5,279
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 9 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100