Bugs item #3566266, was opened at 2012-09-10 03:41
Message generated for change (Comment added) made by omega_weapon
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3566266&group_id=78018
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Omega Weapon (omega_weapon)
Assigned to: Nobody/Anonymous (nobody)
Summary: Python Object Browser - Unable to view ActiveX CoClass
Initial Comment:
Full title: Python Object Browser - Unable to view ActiveX CoClass type library information
I am currently looking into the possiblity of using Python to control some VB6 ActiveX objects used at work. In order to see what COM objects were accessible, I used the combrowse script - however any attempts to browse the CoClass directory of the objects (as compared to the Dispatch directory) fail with the following error:
========================================================
(null)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\Pythonwin\pywin\tools\hierlist.py", line
39, in OnTreeItemExpanding
self.AddSubList(itemHandle, self.GetSubList(item))
File "C:\Python27\lib\site-packages\Pythonwin\pywin\tools\hierlist.py", line
86, in GetSubList
return self.DelegateCall(item.GetSubList)
File "C:\Python27\lib\site-packages\Pythonwin\pywin\tools\hierlist.py", line
73, in DelegateCall
return fn()
File "C:\Python27\Lib\site-packages\win32com\client\combrowse.py", line 239,
n GetSubList
refType = typeinfo.GetRefTypeInfo(typeinfo.GetRefTypeOfImplType(j))
pywintypes.com_error: (-2147312566, 'Error loading type library/DLL.', None, No
e)
========================================================
This is after running the makepy script for the object.
The objects are usable from Microsoft Visual basic 6 Studio (etc) - are there further steps needed to get them useable here? Unfortunately I have no experience with this detail as it basically Just Works with normal VB6 development.
Thanks
----------------------------------------------------------------------
>Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-14 04:54
Message:
Got a chance to look some more at this. Changing c from Collection to
Object gives a much better error:
====================
Run-time error '451':
Property let procedure not defined and property get procedure did not
return an object
====================
Tester.CollectionProperty has Set and Get - presumably VB6 is messing
around with Tester.CollectionProperty rather than the underlying Collection
object that is returned?
----------------------------------------------------------------------
Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-14 03:52
Message:
I have had a play around with the VB6 test project (this doesnt seem to be
included with the source zip). I had to recreate the PyCOMVBTest project as
Visual Studio failed to find any of the class files (even though they were
in the same directory...), and when I tried to test it with the VBTest
project, I get the 'Object required' error 424 on the attempt to set the
value of an item of c in Sub Main, so it isnt going too well.
I'll have another try on Monday, hopefully testing the Interface code as
well. I can't comment on why the IDispatch interface is empty, beyond what
Ive already said about the objects.
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2012-09-13 16:39
Message:
The IDL seems to be the same as the generated file - eg,
spManagerTEvent.idl has just:
interface _TEventManager : IDispatch {
};
ie, an "empty" interface. pycomvbtest can be found in the source tree for
pywin32 -
http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/file/977f4f21ae8b/com/TestSources/PyCOMVBTest
----------------------------------------------------------------------
Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-13 05:55
Message:
I have attached the relevant IDL files (would be nice if OLEView allowed
you just to save one file that then allowed you to browse the hierarchy
like I can on this machine...).
The test suite looks to be PyCOMVBTest, but I cant find that anywhere?
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2012-09-12 19:47
Message:
It hasn't picked up much at all, but I can't even speculate as to why that
would be. If you can use the Microsoft OLE viewer and dump the source of
the typelib and attach it here I might get more clues. Note however that
if VB6 is set to create IDispatch objects it generally works fine - there
is one vb6 created binary used in the test suite. Sadly I haven't used VB6
for so long that the details escape me.
----------------------------------------------------------------------
Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-11 05:04
Message:
The OleView error about being unable to load dlls is rubbish - this was
simply a case of some of the type libraries not being registered on the
system... the COM browser can now cope with browsing too.
However, I'm still not able to call the Start method (from IManager) on the
'spManagerTEvent.TEventManager' object - apparently it doesnt exist.
I ran makepy on the object and got the attached generated code - this is my
first time reading such a file, but it doesnt look like its picked up any
VB6 interfaces?
----------------------------------------------------------------------
Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-11 02:55
Message:
Right, I have found a colleague with COM/ActiveX experience - this dll
implements two interfaces, IManager and ITEventStatus. Every method on the
actual class is marked Private, even those implementing the interfaces. So
presumably the interface methods are the only public methods available on
the object.
The two interfaces are registered via type libraries (have both the tlb and
the idl), but importantly I don't have the source code to the original VB6
projects that implemented the interfaces.
In the idl header, the source library for IManager is quoted as spIManager,
and a UUID is given that does not exist in the registry of any of our
machines. So presumably the failure happens when the missing dll is looked
up?
Here is the idl of one of the interfaces as an example:
======================================================
// TypeLib : IManager.idl
// TargetFile : IManager.TLB
//
// Version 1.0
// Author :
// UUID Usage:
// ae40bf60-dd04-11d6-a558-000347d25793 : library spIManager
// bc185b30-dd04-11d6-a558-000347d25793 : interface IManager
[
uuid(ae40bf60-dd04-11d6-a558-000347d25793),
version(1.0),
helpstring("sp Manager Interface")
]
library tsIManager
{
// TLib : // TLib : OLE Automation :
{00020430-0000-0000-C000-000000000046}
importlib("Stdole2.tlb");
// Forward declare all types defined in this typelib
interface IManager;
[
uuid(bc185b30-dd04-11d6-a558-000347d25793),
version(1.0),
nonextensible,
oleautomation
]
interface IManager : IUnKnown {
[id(0x60030000)]
HRESULT Start([out, retval] VARIANT_BOOL* );
[id(0x60030001)]
HRESULT Halt(
[in, optional, defaultvalue(0)] VARIANT_BOOL
vbSoftStop,
[out, retval] VARIANT_BOOL* );
};
};
======================================================
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2012-09-10 16:41
Message:
I doubt there is much pywin32 can do to resolve this, especially without
more details about the objects in question.
----------------------------------------------------------------------
Comment By: Omega Weapon (omega_weapon)
Date: 2012-09-10 09:25
Message:
Some more detail - using OleView to view the relevant type library, when I
try to look at the CoClass, I get the following error:
---------------------------
OLEViewer 2.0 Interface Viewers
---------------------------
Could not decompile selected item
Error loading type library/DLL.
TYPE_E_CANTLOADLIBRARY ($80029C4A)
---------------------------
OK
---------------------------
So presumably VB6 is doing something bad, but I dont know what or why it
isnt an issue for VB6 :/
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3566266&group_id=78018
|