win32ole enum

J

James French

Hi Rubyists,

If someone could help me with this I'd be very grateful...

I'm trying to use WIN32OLE to call a method that takes an enum called EUser=
DefinedTree. I want to set it to kAbsoluteFilePath. I have a handle to the =
method and ole_type_detail reports the param as type USERDEFINED.

Trouble is I have no idea how to pass in kAbsoluteFilePath as the value.

Can anyone point me in the right direction? I've already had a good google =
but nothing turned up.

Cheers,
James
 
J

James French

-----Original Message-----
From: James French [mailto:[email protected]]=20
Sent: 08 November 2010 11:36
To: ruby-talk ML
Subject: win32ole enum

Hi Rubyists,

If someone could help me with this I'd be very grateful...

I'm trying to use WIN32OLE to call a method that takes an enum called EUser=
DefinedTree. I want to set it to kAbsoluteFilePath. I have a handle to the =
method and ole_type_detail reports the param as type USERDEFINED.

Trouble is I have no idea how to pass in kAbsoluteFilePath as the value.

Can anyone point me in the right direction? I've already had a good google =
but nothing turned up.

Cheers,
James



Bit of progress:

module CW_CONST
end

#--------------------------------------------------------------------------=
----------------
def initCodeWarrior
cwApp =3D WIN32OLE.new('CodeWarrior.CodeWarriorApp')
=20
WIN32OLE.const_load(cwApp, CW_CONST)
=20
puts CW_CONST::KAbsoluteFilePath # =3D> 0
puts CW_CONST::KEnvironment # =3D> 1
puts CW_CONST::KRegistry # =3D> 2

cwApp.CreateUserTree("displayname", "value", CW_CONST::KAbsoluteFilePath,=
"keyname")
end

I can now *access* the enum values I want, but I can't pass one as the thir=
d param to CreateUserTree - the method is failing with an uninformative mes=
sage at any rate. Do I need to convert it into some kind of object?
 
J

James French

-----Original Message-----
From: James French [mailto:[email protected]]=20
Sent: 08 November 2010 11:36
To: ruby-talk ML
Subject: win32ole enum

Hi Rubyists,

If someone could help me with this I'd be very grateful...

I'm trying to use WIN32OLE to call a method that takes an enum called EUser=
DefinedTree. I want to set it to kAbsoluteFilePath. I have a handle to the =
method and ole_type_detail reports the param as type USERDEFINED.

Trouble is I have no idea how to pass in kAbsoluteFilePath as the value.

Can anyone point me in the right direction? I've already had a good google =
but nothing turned up.

Cheers,
James



Bit of progress:

module CW_CONST
end

#--------------------------------------------------------------------------=
----------------
def initCodeWarrior
cwApp =3D WIN32OLE.new('CodeWarrior.CodeWarriorApp')
=20
WIN32OLE.const_load(cwApp, CW_CONST)
=20
puts CW_CONST::KAbsoluteFilePath # =3D> 0
puts CW_CONST::KEnvironment # =3D> 1
puts CW_CONST::KRegistry # =3D> 2

cwApp.CreateUserTree("displayname", "value", CW_CONST::KAbsoluteFilePath,=
"keyname")
end

I can now *access* the enum values I want, but I can't pass one as the thir=
d param to CreateUserTree - the method is failing with an uninformative mes=
sage at any rate. Do I need to convert it into some kind of object?



Finally answering own question: Upgrade to ruby 1.9.1-p430 or ruby 1.9.2-p0=
and then do:

cwApp.CreateUserTree("displayname ", "value", WIN32OLE_VARIANT.new(CW_CONST=
::KAbsoluteFilePath), "keyname")

Repeat: this does not work with 1.8.7.
 

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


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top