WIN32OLE Question on Accessing an Enum

B

Bryan Richardson

Hello all,

I'm trying to interact with the Google Earth application through its COM
interface on a Windows machine. I'm able to start the application using
WIN32OLE.new 'GoogleEarth.ApplicationGE'. I'm now trying to set the
camera using the OLE method setCameraParams. One of the parameters for
this method is an AltitudeModeGE enumeration defined in the COM
interface (see below).

HRESULT IApplicationGE::SetCameraParams([in] double lat,
[in] double lon,
[in] double alt,
[in] AltitudeModeGE altMode,
[in] double range,
[in] double tilt,
[in] double azimuth,
[in] double speed )

How do I go about creating the AltitudeModeGE enum to pass into the
setCameraParams method?
 
M

Masaki Suketa

Hello,

Bryan said:
HRESULT IApplicationGE::SetCameraParams([in] double lat,
[in] double lon,
[in] double alt,
[in] AltitudeModeGE altMode,
[in] double range,
[in] double tilt,
[in] double azimuth,
[in] double speed )

How do I go about creating the AltitudeModeGE enum to pass into the
setCameraParams method?

If TypeLibrary information created when installing Google Earth
application, you could get some information from following Ruby script.

appge = WIN32OLE.new('GoogleEarth.ApplicationGE')
appge.ole_method('SetCameraParams').params.each do |param|
puts param.ole_type_detail.join(',') + ' ' + param.name
end

What is the result of above script?

Regards,
Masaki Suketa
 
A

Ar Vicco

OK, I'm in a similar fix with an OLE method that expects an enum...

I'm driving a proprietary COM object using WIN32OLE, and one of the
classes has a PROPERTYPUT method 'type' that expects enum of type
TRequestType, defined in the same typelib. In the documentation, this
method is described like this:

Property: type [in/out] enum TRequestType

When I run olegen script on this typelib, this is what comes out of it:

class DataStream
...
def type=(arg0)
@dispatch._setproperty(4, [arg0], [VT_DISPATCH])
end
...
end

module TRequestType
include WIN32OLE::VARIANT
attr_reader :lastargs

RT_LOCAL = 0
RT_COMBINED_SNAPSHOT = 1
RT_COMBINED_DYNAMIC = 2
RT_REMOTE_SNAPSHOT = 3
RT_REMOVE_DELETED = 4
RT_REMOTE_ONLINE = 8
end

OLE method stub seems to expect an OLE object, but I cannot instantiate
TRequestType enum... It has CLSID, but trying WIN32OLE.new with this
CLSID gives:
-----
WIN32OLERuntimeError: failed to create WIN32OLE object from
`{508266CF-A83D-46FE-95B3-E8F892950E61}'

When I try to give this method Fixnum (say 1) instead of enum, I get:
-----
TypeError: not valid value

WIN32OLE documentation does not mention how to work with OLE enums. I
tried to fiddle with WIN32OLE_VARIANT, but was unable to fugure out how
to use it properly... So, essentially I have no idea how to make this
enum and pass it into method that expects it. :(

Any help pushing me in the right direction is greatly appreciated... At
the very minimum, I need to understand in what direction to dig, and now
I'm at a total loss... Help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

win32ole enum 2
win32ole question 1
WIN32OLE Question 4
WIN32OLE Question 2
Ruby win32ole properties 2
win32ole confusion 2
WIN32OLE - failed to create WIN32OLE 1
Win32OLE trouble (custom ocx) 10

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top