Erik Fløisbonn wrote:
> 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:
>
> WindowsError: [Error 182] The operatingsystem can not run %1
>
> (Original message is in norwegian: WindowsError: [Error 182] 
> Operativsystemet kan ikke kjøre %1)
>
> 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.
>
> I am running Windows Vista and python 2.5.1. I am compiling the source 
> code with cl (from the windows SDK) like this:
>
> cl /LD msi.c msi.def  "C:\Program Files\Microsoft 
> SDKs\Windows\v6.0\Lib\Msi.lib"
>
> My python file looks like this:
>
> from ctypes import *
> # import msilib (everything works when I uncomment this)
> print cdll.LoadLibrary("C:\Users\Erik\Documents\INF5660\Msi.dll").test(2)

You can't write normal strings with single backslashes!  You happened to 
get lucky here, because 'u', 'e', 'd', 'i', and 'm' aren't recognized 
escape codes, but if your name had been "Tom", this would not work.

You can write this in one of three ways:
   print 
cdll.LoadLibrary("C:\\Users\\Erik\\Documents\\INF5660\\Msi.dll").test(2)
   print 
cdll.LoadLibrary(r"C:\Users\Erik\Documents\INF5660\Msi.dll").test(2)
   print cdll.LoadLibrary("C:/Users/Erik/Documents/INF5660/Msi.dll").test(2)

However, this is not causing your immediate problem.

You might try dumping the imports for your DLL, to see if it needs a DLL 
that it's not finding.  You can use the "depends" tool for that, or just 
"link /dump /exports msi.dll".

-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to