Page 1 of 1

PrototypeFromInterface

Posted: Mon Apr 21, 2008 1:09 pm
by Leonhard
I look for a compiler-function to get a property from a interface.

Example:

Code: Select all

Interface IADsPropertyList
  QueryInterface(a, b)
  AddRef()
  Release()
  GetTypeInfoCount(a)
  GetTypeInfo(a, b, c)
  GetIDsOfNames(a, b, c, d, e)
  Invoke(a, b, c, d, e, f, g, h)
  get_PropertyCount(a)
  Next(a)
  Skip(a)
  Reset()
  Item(a.p-variant, b)
  GetPropertyItem(a.p-bstr, b, c)
  PutPropertyItem(a.p-variant)
  ResetPropertyItem(a.p-variant)
  PurgePropertyList()
EndInterface

Define Invoke.PrototypeFromInterface(IADsPropertyList, Invoke)
It would be very nice.

Posted: Mon Apr 21, 2008 1:39 pm
by srod
But wouldn't you have to tie the resulting prototype to an instance of the object in question rather than leave it as a generic 'class' prototype? The first (unseen) parameter to interface methods is always a pointer to the object itself (*self or *this etc.) and so I cannot see how a 'method prototype' can exist outside of an instance of the class. In which case, such a thing would seem rather pointless.

You can try something like the following, although I am far from convinced that it will work :) :

Code: Select all

Interface IADsPropertyList
  QueryInterface(a, b) 
  AddRef() 
  Release() 
  GetTypeInfoCount(a) 
  GetTypeInfo(a, b, c) 
  GetIDsOfNames(a, b, c, d, e) 
  Invoke(a, b, c, d, e, f, g, h) 
  get_PropertyCount(a) 
  Next(a) 
  Skip(a) 
  Reset() 
  Item(a.p-variant, b) 
  GetPropertyItem(a.p-bstr, b, c) 
  PutPropertyItem(a.p-variant) 
  ResetPropertyItem(a.p-variant) 
  PurgePropertyList() 
EndInterface 

Prototype _invoke(*self.IADsPropertyList, a, b, c, d, e, f, g, h)

test.IADsPropertyList
CoCreateInstance_(...blah blah..., @test)

Define Invoke._invoke = PeekL(PeekL(test)+OffsetOf(IADsPropertyList\Invoke()))

Invoke(test, a, b, ... blah blah)

Posted: Mon Apr 21, 2008 2:11 pm
by Leonhard
A little bit big as my way but ok.

Posted: Mon Apr 21, 2008 2:15 pm
by srod
I've tested it as far as obtaining the correct function address - and that is fine. Whether it will execute the method correctly though... that is a different matter! :)