Click here to Skip to main content
15,037,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Updated 9-Sep-11 1:55am

Google reveals all.

A skinned dialog in Python and MFC[^]
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[^]
Mobile.Instinct 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.
#realJSOP 9-Sep-11 9:04am
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 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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900