embed python dynamically

N

naveen

How do you embed the python dll file distributed with the automatic
installable python distribution on windows?
Is it possible to dynamically load the python dll from running c
program and start up a python interpreter ?
Do you have to compile python from source to be able to embed python?
 
N

naveen

ok, it was almost intuitive.
just made a simple visual c express dll project
included python26\include and python26\libs in the project settings
the debug version has issues, but the release compiles without a
problem.
here is the source:
http://github.com/tinku99/embedpython
 
N

naveen

ok, its even easier than that.
With autohotkey:

pythondll := DllCall("LoadLibrary", "str", "c:\windows
\system32\python26.dll")
init := DllCall("c:\windows\system32\python26.dll\Py_Initialize"
, "Cdecl")
msgbox python initalized
call := DllCall("c:\windows\system32\python26.dll\PyRun_SimpleString"
, "str", "import sys", "Cdecl")
msgbox will exit using python code
call := DllCall("c:\windows\system32\python26.dll\PyRun_SimpleString"
, "str", "sys.exit(0)", "Cdecl")
init := DllCall("c:\windows\system32\python26.dll\Py_Finalize"
, "Cdecl")
msgbox % never called
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top