Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28608 > unrolled thread
| Started by | Helpful person <rrllff@yahoo.com> |
|---|---|
| First post | 2012-09-06 08:07 -0700 |
| Last post | 2012-09-06 13:27 -0700 |
| Articles | 14 — 6 participants |
Back to article view | Back to comp.lang.python
Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-06 08:07 -0700
Re: Accessing dll Jerry Hill <malaclypse2@gmail.com> - 2012-09-06 11:30 -0400
Re: Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-06 08:41 -0700
Re: Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-06 08:44 -0700
Re: Accessing dll Chris Angelico <rosuav@gmail.com> - 2012-09-07 22:15 +1000
Re: Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-07 10:27 -0700
Re: Accessing dll Chris Angelico <rosuav@gmail.com> - 2012-09-08 21:21 +1000
Re: Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-06 09:46 -0700
Re: Accessing dll Jerry Hill <malaclypse2@gmail.com> - 2012-09-06 12:58 -0400
Re: Accessing dll Helpful person <rrllff@yahoo.com> - 2012-09-06 10:10 -0700
Re: Accessing dll MRAB <python@mrabarnett.plus.com> - 2012-09-06 18:17 +0100
Re: Accessing dll Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-09-06 17:28 +0200
Re: Accessing dll Tim Williams <tjandacw@cox.net> - 2012-09-06 13:21 -0700
Re: Accessing dll Tim Williams <tjandacw@cox.net> - 2012-09-06 13:27 -0700
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-06 08:07 -0700 |
| Subject | Accessing dll |
| Message-ID | <0e642403-36e9-4945-9efb-4d074d7d0eb2@s5g2000vbj.googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Jerry Hill <malaclypse2@gmail.com> |
|---|---|
| Date | 2012-09-06 11:30 -0400 |
| Message-ID | <mailman.311.1346945430.27098.python-list@python.org> |
| In reply to | #28608 |
On Thu, Sep 6, 2012 at 11:07 AM, Helpful person <rrllff@yahoo.com> 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? You should start by reading the ctypes documentation, here: http://docs.python.org/library/ctypes.html . It has a lot of examples that ought to get you started. When you run into more specific problems, you're going to have to provide a lot more information before we can help you, including the specific documentation of the DLL you're trying to wrap, your platform, and python version. If you are not permitted to share those things, we may not be able to give you much help. Ctypes is very specific to the actual library you are accessing, and requires that you understand the requirements of the underlying DLL. -- Jerry
[toc] | [prev] | [next] | [standalone]
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-06 08:41 -0700 |
| Message-ID | <e5a4caaf-ce00-4af1-b62f-e7ac89801c5b@k20g2000vbk.googlegroups.com> |
| In reply to | #28610 |
On Sep 6, 8:30 am, Jerry Hill <malaclyp...@gmail.com> wrote: > You should start by reading the ctypes documentation, here:http://docs.python.org/library/ctypes.html. It has a lot of examples > that ought to get you started. > > When you run into more specific problems, you're going to have to > provide a lot more information before we can help you, including the > specific documentation of the DLL you're trying to wrap, your > platform, and python version. If you are not permitted to share those > things, we may not be able to give you much help. Ctypes is very > specific to the actual library you are accessing, and requires that > you understand the requirements of the underlying DLL. > > -- > Jerry Thanks Jerry, I'll read the reference you posted. Unfortunately I know almost nothing about the dll and Python is loaded in some strange framework. I'll post back after a thorough read about Ctypes.
[toc] | [prev] | [next] | [standalone]
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-06 08:44 -0700 |
| Message-ID | <02c28de7-e672-4850-b684-d2cb4e3128b6@fm12g2000vbb.googlegroups.com> |
| In reply to | #28610 |
FYI My Python version is 2.5.4
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-09-07 22:15 +1000 |
| Message-ID | <mailman.352.1347020146.27098.python-list@python.org> |
| In reply to | #28614 |
On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <rrllff@yahoo.com> 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
[toc] | [prev] | [next] | [standalone]
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-07 10:27 -0700 |
| Message-ID | <5b2b86a1-7fb5-4db9-be6a-4b720af936f2@d7g2000vbv.googlegroups.com> |
| In reply to | #28683 |
On Sep 7, 5:16 am, Chris Angelico <ros...@gmail.com> wrote: > On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <rrl...@yahoo.com> 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.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-09-08 21:21 +1000 |
| Message-ID | <mailman.379.1347103267.27098.python-list@python.org> |
| In reply to | #28698 |
On Sat, Sep 8, 2012 at 3:27 AM, Helpful person <rrllff@yahoo.com> wrote: > On Sep 7, 5:16 am, Chris Angelico <ros...@gmail.com> wrote: >> On Fri, Sep 7, 2012 at 1:44 AM, Helpful person <rrl...@yahoo.com> 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
[toc] | [prev] | [next] | [standalone]
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-06 09:46 -0700 |
| Message-ID | <83536b03-64a5-4394-9d31-378b56f4fa27@x3g2000vbn.googlegroups.com> |
| In reply to | #28610 |
On Sep 6, 8:30 am, Jerry Hill <malaclyp...@gmail.com> wrote: > > You should start by reading the ctypes documentation, here:http://docs.python.org/library/ctypes.html. It has a lot of examples > that ought to get you started. > The reference might help if I could get Python to recognize the dll as a module.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Hill <malaclypse2@gmail.com> |
|---|---|
| Date | 2012-09-06 12:58 -0400 |
| Message-ID | <mailman.314.1346950727.27098.python-list@python.org> |
| In reply to | #28617 |
On Thu, Sep 6, 2012 at 12:46 PM, Helpful person <rrllff@yahoo.com> wrote: > The reference might help if I could get Python to recognize the dll as > a module. That's never going to happen. It's a DLL, not a python module. I think the documentation lays that out pretty explicitly. Have you experimented with the very first bit of example code in the documentation? What do you get if you do the following at the interactive interpreter? >>> from ctypes import * >>> print windll.<insert your dll name here, without the .dll extension> -- Jerry
[toc] | [prev] | [next] | [standalone]
| From | Helpful person <rrllff@yahoo.com> |
|---|---|
| Date | 2012-09-06 10:10 -0700 |
| Message-ID | <088a3ea3-c9b6-47f0-a72c-2939174907a1@d7g2000vbv.googlegroups.com> |
| In reply to | #28618 |
On Sep 6, 9:58 am, Jerry Hill <malaclyp...@gmail.com> wrote: What do you get if you do the following at the > interactive interpreter? > > >>> from ctypes import * > >>> print windll.<insert your dll name here, without the .dll extension> > > -- > Jerry I get: <WinDLL '<my dll name without the dll extension> , handle 410000 at 2ace070>
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2012-09-06 18:17 +0100 |
| Message-ID | <mailman.315.1346951874.27098.python-list@python.org> |
| In reply to | #28617 |
On 06/09/2012 17:58, Jerry Hill wrote: > On Thu, Sep 6, 2012 at 12:46 PM, Helpful person <rrllff@yahoo.com> wrote: >> The reference might help if I could get Python to recognize the dll as >> a module. > > That's never going to happen. It's a DLL, not a python module. I > think the documentation lays that out pretty explicitly. Have you > experimented with the very first bit of example code in the > documentation? What do you get if you do the following at the > interactive interpreter? > >>>> from ctypes import * >>>> print windll.<insert your dll name here, without the .dll extension> > Or this: >>> import ctypes >>> dll_path = ... >>> libc = ctypes.CDLL(dll_path) >>> dir(libc)
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Date | 2012-09-06 17:28 +0200 |
| Message-ID | <91smh9-duc.ln1@satorlaser.homedns.org> |
| In reply to | #28608 |
Am 06.09.2012 17:07, schrieb Helpful person: > I am a complete novice to Python. Welcome! > 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. Using ctypes, you can indeed load DLLs. Take a look at http://docs.python.org, which includes the documentation for the ctypes module but also general documentation and tutorials, which should be a starting point for you. > I tried: "import name.dll" but this just gave me an error telling me > that there was no such module. Like in VB or C, things are not that easy. You will always have to write some code that informs Python about the names and parameters of the functions in that DLL. Good luck! Uli
[toc] | [prev] | [next] | [standalone]
| From | Tim Williams <tjandacw@cox.net> |
|---|---|
| Date | 2012-09-06 13:21 -0700 |
| Message-ID | <e9c1576d-e3ed-49cd-bc30-8e0d5d18405c@googlegroups.com> |
| In reply to | #28608 |
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)
[toc] | [prev] | [next] | [standalone]
| From | Tim Williams <tjandacw@cox.net> |
|---|---|
| Date | 2012-09-06 13:27 -0700 |
| Message-ID | <f59d0c4f-5302-469f-b927-fa58661e4a32@googlegroups.com> |
| In reply to | #28635 |
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')
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web