"JustSomeGu y" <nope@nottellin g.com> schrieb im Newsbeitrag
news:5n4if.6272 00$1i.183531@pd 7tw2no...[color=blue]
> Hi I have a commercial OCX that I want to use in
> my python application. How do I call OCXs from
> python?
> TIA[/color]
"Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
news:3usl5aF12j a39U1@individua l.net...[color=blue]
> "JustSomeGu y" <nope@nottellin g.com> schrieb im Newsbeitrag
> news:5n4if.6272 00$1i.183531@pd 7tw2no...[color=green]
> > Hi I have a commercial OCX that I want to use in
> > my python application. How do I call OCXs from
> > python?
> > TIA[/color]
>
> import win32com.client
> axOCX =
>[/color]
win32com.client .Dispatch("Regi stryEntryForThi sOCXin[VersionIndepend entProgID[color=blue]
> ]section")
> retVal = axOCX.methodOfT hisOCX(param1, param2)
> value = axOCX.attribute OfThisOCX
>
> Claudio
>
>[/color]
Thank you Claudio...
Can you explain the RegistryEntryFo rThisOcxin[VersionIndepend entProgID]
I don't know what I should use here..
"JustSomeGu y" <nope@nottellin g.com> schrieb im Newsbeitrag
news:VJMif.6466 22$tl2.454656@p d7tw3no...[color=blue]
>
> "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
> news:3usl5aF12j a39U1@individua l.net...[color=green]
> > "JustSomeGu y" <nope@nottellin g.com> schrieb im Newsbeitrag
> > news:5n4if.6272 00$1i.183531@pd 7tw2no...[color=darkred]
> > > Hi I have a commercial OCX that I want to use in
> > > my python application. How do I call OCXs from
> > > python?
> > > TIA[/color]
> >
> > import win32com.client
> > axOCX =
> >[/color]
>[/color]
win32com.client .Dispatch("Regi stryEntryForThi sOCXin[VersionIndepend entProgID[color=blue][color=green]
> > ]section")
> > retVal = axOCX.methodOfT hisOCX(param1, param2)
> > value = axOCX.attribute OfThisOCX
> >
> > Claudio
> >
> >[/color]
>
> Thank you Claudio...
> Can you explain the RegistryEntryFo rThisOcxin[VersionIndepend entProgID]
> I don't know what I should use here..[/color]
An ActiveX component (e.g. an OCX) requires to be registered before it can
be used. Usually this is done when the component is installed. If you know
the file name of the OCX start the registry editor running the command:
regedit ([Start] -> Execute -> regedit). Then search for the file name of
the OCX in the registry. One of the hits should lead you to a registry key
where you find on same hierarchy level the [VersionIndepend entProgID] entry.
The name there is what you should use in the win32com.client .Dispatch() as
parameter.
To give an example let's assume you want to use the WSHOM.OCX which is
usually on any Windows system. Looking in the registry for WSHOM.OCX leads
you (probably the second hit) to the key [InProcServer32] in the
{72C24DD5-D70A-438B-8A42-98424B88AFB8} entry. Here you find also the key
[VersionIndepend entProgID] with the standard value of WScript.Shell. You
should exactly know the methods and their parameter to be able to use the
OCX, see the code below :
# Raise a Yes/No/Abort dialog box provided by WSHOM.OCX:
Claudio
P.S. if you face problems with return values or parameter values, one of
reasons can be, that OCXses work always with Unicode strings and you haven't
taken it into consideration.
Comment