473,373 Members | 1,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,373 software developers and data experts.

Active X DLL tips?


I want to use and Active X DLL in Python applications. I have the
win32all stuff installed and the "Excel.Application" example in the
Client QuickStart section of the manual works OK, so I guess it is
installed correctly.

Problem comes when I want to use the objects in the OPCDA library. In VB
I would include the library in the references and could then do
something like:

Dim foo as OPCServer
dim baa as OPCGroups
(lots of lower level objects omitted)

set foo=New OPCServer
foo.Connect <Server details>
set baa=foo <Call for getting a new OPCGroups object>
(code continues in a similar manner)

Leading on from the Excel example, I have tried using client.Dispatch
with "OPCServer", "OPCAutomation.OPCServer" and a few other
combinations, but I cannot get a valid object. Either I am told the
string is invalid, or I get no error but the variable which the object
was supposed to be assigned to is.....not assigned.

Maybe (as warned in the docs) the COM browser is not correctly reporting
the names I should use. It mentions the VC COM browser, but if you don't
have that are there other valid alternatives?

I have looked at the gencache functions for generating a Python module
from the type library, but I am not sure about the parameters, in
particular, what should the lcid be? Also, what is the correct way to
pass an IID, as a string complete with the hyphens?

I have looked around for examples but all I have found so far is either
accessing applications such as Excel, IE and outlook, or building
clients to test servers that have been created with Python.

I suspect that maybe I sould be doing things a bit differently to access
a vanilla Automation DLL.

Tips anyone?
Jul 18 '05 #1
1 2722
Got there in the end. For the benefit of other clueless souls who turn
up my post in searches, this is what I used:

import win32com.client
OPCDA=win32com.client.gencache.GetModuleForTypelib ('{28E68F91-8D75-11D1-8DC3-3C302A000000}',0,1,0) AnOPCServer=OPCDA.OPCServer.default_interface

This generates what I think is a 'Class Factory' in OPCDA, and this can
be used to generate an OPCServer object, as well as other OPC objects,
allthougth of course these are usually generated by calls to higher
level objects.

It would be nice to have a few tips and examples on this type of usage
in the Client QuickStart guide. Unfortunately I have little idea of what
I am doing so I am not the person to write it.

The GetModuleForTypeLib is documented in the win32com helpfile, the
parameters are:

IID,lcid,major,minor

IID - Get this using the COM browser. Look for OPC Automation 2.0, the
'filename' entry in the Type Library should point to opcdaauto.dll

lcid - this is a 'locale' ID. One of my mistakes was tring to set this
to a typical value for my (Italian) PC. Set to 0 and use the standard
conventions.

major & minor - Get the major and minor versions by looking at the
property of the DLL. In this case the type library is called OPC
Automation 2.0 but the DLL is version 1.0 . This may sound odd but the
2.0 refers to the OPC standard that is implemented, not the version
number of the DLL which implements it!
Roger wrote:
I want to use and Active X DLL in Python applications. I have the
win32all stuff installed and the "Excel.Application" example in the
Client QuickStart section of the manual works OK, so I guess it is
installed correctly.

Problem comes when I want to use the objects in the OPCDA library. In VB
I would include the library in the references and could then do
something like:

Dim foo as OPCServer
dim baa as OPCGroups
(lots of lower level objects omitted)

set foo=New OPCServer
foo.Connect <Server details>
set baa=foo <Call for getting a new OPCGroups object>
(code continues in a similar manner)

Leading on from the Excel example, I have tried using client.Dispatch
with "OPCServer", "OPCAutomation.OPCServer" and a few other
combinations, but I cannot get a valid object. Either I am told the
string is invalid, or I get no error but the variable which the object
was supposed to be assigned to is.....not assigned.

Maybe (as warned in the docs) the COM browser is not correctly reporting
the names I should use. It mentions the VC COM browser, but if you don't
have that are there other valid alternatives?

I have looked at the gencache functions for generating a Python module
from the type library, but I am not sure about the parameters, in
particular, what should the lcid be? Also, what is the correct way to
pass an IID, as a string complete with the hyphens?

I have looked around for examples but all I have found so far is either
accessing applications such as Excel, IE and outlook, or building
clients to test servers that have been created with Python.

I suspect that maybe I sould be doing things a bit differently to access
a vanilla Automation DLL.

Tips anyone?

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Johan | last post by:
Hi ya, we are in the process of switching over to Active Directory from the old NT. :zzz: Finally!! Anycase, Im battling with one error when I try to authenticate using AD. "Error obtaining group...
0
by: Rick | last post by:
Hi Group, I am trying to change a users password in Active Directory. I am getting an error that reads: "Configuration information could not be read from the domain controller, either because...
1
by: Stinky Pete | last post by:
Hi, I'm wanting to put a control button on a form that when clicked will bring up the Active X Calendar. Once the identified date is selcted, place this date into the required date field. ...
2
by: AndersBj | last post by:
I have a web application (asp.net) that uses Forms authentication to authenticate users against an Active Directory. The problem I have is that most of the time this works great, but every once in...
1
by: duraisridhar | last post by:
Hi All, My active connection created by my application from windows 2000 to Windows 2003 (or any linux machine) get closed as it receives WSAENOBUFS error . While I googled , I come to know that...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
1
by: Mike H | last post by:
I can't seem to figure out the right thing to search on, so I thought I'd just provide an example and see if someone can point me to some tips. What I have is an Automation Server that has a...
2
by: Max Vit | last post by:
I have been toying with the idea of having an Active Directory authentication / authorisation functionality in MS Access; but there is not much useful info around. I have built these...
3
by: prakashwadhwani | last post by:
I have a continuous form. When the user presses the Down-Arrow, I'd like to know if the active control was in the FormHeader, FormBody or FormFooter section. Is there any way to trap this ? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.