Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Accessing dll

Reply
Thread Tools

Accessing dll

 
 
Tim Williams
Guest
Posts: n/a
 
      09-06-2012
On Thursday, September 6, 2012 11:07:07 AM UTC-4, Helpful person wrote:
> I am a complete novice to Python. I wish to access a dll that has
>
> been written to be compatible with C and VB6. I have been told that
>
> after running Python I should enter "from ctypes import *" which
>
> allows Python to recognize the dll structure. I have placed the dll
>
> into my active directory (if that's the correct word, one on my path)
>
> for simplification.
>
>
>
> I tried: "import name.dll" but this just gave me an error telling me
>
> that there was no such module.
>
>
>
> Can someone please help?
>
>
>
> Richard


I'm new to using the ctypes module also, but what I did to find the library was I appended the location of the dll to my PATH like so: (this is Windows)

pth = os.environ['path'].split(';')
pth.append(os.path.join(os.environ['userprofile'],'My Documents','DLLs'))
os.environ['path'] = ';'.join(pth)
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      09-06-2012
On Thursday, September 6, 2012 4:21:56 PM UTC-4, Tim Williams wrote:
> On Thursday, September 6, 2012 11:07:07 AM UTC-4, Helpful person wrote:
>
> > I am a complete novice to Python. I wish to access a dll that has

>
> >

>
> > been written to be compatible with C and VB6. I have been told that

>
> >

>
> > after running Python I should enter "from ctypes import *" which

>
> >

>
> > allows Python to recognize the dll structure. I have placed the dll

>
> >

>
> > into my active directory (if that's the correct word, one on my path)

>
> >

>
> > for simplification.

>
> >

>
> >

>
> >

>
> > I tried: "import name.dll" but this just gave me an error telling me

>
> >

>
> > that there was no such module.

>
> >

>
> >

>
> >

>
> > Can someone please help?

>
> >

>
> >

>
> >

>
> > Richard

>
>
>
> I'm new to using the ctypes module also, but what I did to find the library was I appended the location of the dll to my PATH like so: (this is Windows)
>
>
>
> pth = os.environ['path'].split(';')
>
> pth.append(os.path.join(os.environ['userprofile'],'My Documents','DLLs'))
>
> os.environ['path'] = ';'.join(pth)


I should have also mentioned to look at LoadLibrary in the ctypes module. e.g.

mylib=cdll.LoadLibrary('mylib.dll')
 
Reply With Quote
 
 
 
 
Chris Angelico
Guest
Posts: n/a
 
      09-07-2012
On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <(E-Mail Removed)> wrote:
> FYI
>
> My Python version is 2.5.4


You may wish to upgrade, that's quite an old version. Unless
something's binding you to version 2.x, I would strongly recommend
migrating to 3.2 or 3.3.

ChrisA
 
Reply With Quote
 
Helpful person
Guest
Posts: n/a
 
      09-07-2012
On Sep 7, 5:16*am, Chris Angelico <(E-Mail Removed)> wrote:
> On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <(E-Mail Removed)> wrote:
> > FYI

>
> > My Python version is 2.5.4

>
> You may wish to upgrade, that's quite an old version. Unless
> something's binding you to version 2.x, I would strongly recommend
> migrating to 3.2 or 3.3.
>
> ChrisA


Upgrading is not possible due to the large number of programs using
the early version.
 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      09-08-2012
On Sat, Sep 8, 2012 at 3:27 AM, Helpful person <(E-Mail Removed)> wrote:
> On Sep 7, 5:16 am, Chris Angelico <(E-Mail Removed)> wrote:
>> On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <(E-Mail Removed)> wrote:
>> > FYI

>>
>> > My Python version is 2.5.4

>>
>> You may wish to upgrade, that's quite an old version. Unless
>> something's binding you to version 2.x, I would strongly recommend
>> migrating to 3.2 or 3.3.
>>
>> ChrisA

>
> Upgrading is not possible due to the large number of programs using
> the early version.


Sure. At least you've considered it. Do look into moving up to 2.7,
at least, though. And of course, you can have multiple Pythons
installed simultaneously, allowing you to migrate only when you're
ready.

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory Allication (Managed VC++ DLL to Unmanaged DLL) [Second Try] Weston Fryatt ASP .Net 2 01-01-2005 11:31 AM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Why does Ruby use both tcl83.dll and tk83.dll (instead of just tk83.dll)? H. Simpson Ruby 4 08-03-2004 04:45 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments