Click here to Skip to main content
13,250,043 members (69,921 online)
Rate this:
Please Sign up or sign in to vote.
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
Updated 9-Sep-11 2:55am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Rate this: bad
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[^]
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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 9 Sep 2011
Copyright © CodeProject, 1999-2017
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