Reputation:
I need to know a way to call a function defined in the exe from a python script. I know how to call entire exe from py file.
Upvotes: 5
Views: 3294
Reputation: 347566
Unless your EXE is a COM object, or specifically exports certain functions like a dll does, then this is not possible.
For the COM method take a look at these resources:
For the exported functions like a dll method, please use python's win32 module along with the Win32 API LoadLibrary and related functions.
If you have access to the EXE's source code:
If you have access to the source code of this EXE though, you should define command line arguments and tie that into calling the function you want to call. In this case you can use the python os.system call to start your application or subprocess.call().
Upvotes: 7
Reputation: 53476
Not sure if it is for windows. But you can treat an exe like a dll (if functions are exported). And they can be used by other programs.
Upvotes: 1