Hello, I am creating a .dll that I load in python with ctypes. The .dll calls Windows Installer API functions (like MsiEnumProducts). I am having trouble calling these functions from python. When I import the msilib (or _msi) that comes with python, the function calls work. But when I do not import them, the call does not work and I get the following error message:<br>
<br>WindowsError: [Error 182] The operatingsystem can not run %1 <br><br>(Original message is in norwegian: WindowsError: [Error 182] Operativsystemet kan ikke kjøre %1)<br><br>I am wondering why the function calls are not working when I do not import the msi module, and why they work when I do import the module.<br>
<br><br>I am running Windows Vista and python 2.5.1. I am compiling the source code with cl (from the windows SDK) like this:<br><br>cl /LD msi.c msi.def&nbsp; &quot;C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\Msi.lib&quot;<br>
<br><br>My python file looks like this:<br><br>from ctypes import *<br># import msilib (everything works when I uncomment this)<br>print cdll.LoadLibrary(&quot;C:\Users\Erik\Documents\INF5660\Msi.dll&quot;).test(2)<br><br>
<br><br>The test function is defined like this in msi.c<br><br>int test(int inn) {<br>&nbsp;&nbsp;&nbsp; char product[100]; int i = 0;<br>&nbsp;&nbsp;&nbsp; while (!MsiEnumProducts(i++, product)) { // Calling the api function (defined in msi.h)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;%s&quot;, product);<br>
&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return inn*2;<br>}<br><br>I have looked through the _msi.c source code for python 2.5.1, but I can not find any clues to what it does to make my functions work, and I have no idea what I am doing wrong with the creation of my wrappers. Anyone knows?<br>
<br>Have a nice day,<br>- Erik<br>