Essential COM

, , / - . IDL , , . :

 [ object, uuid(0BB3DAE1-11F4-11d1-8C84-0080C73925BA) ]  interface ICollie : IDog {        // Age is a read-only property        // Age ( ) -                [propget] HRESULT Age([out, retval] long *pVal);        // HairCount is a read/write property        // HairCount (   ) -      /       [propget] HRESULT HairCount([out, retval] long *pVal);      [propput] HRESULT HairCount([in] long val);        // CurrentThought is a write-only property        // CurrentThought (   )                [propput] HRESULT CurrentThought([in] BSTR val);  }  

[propget] [propput] IDL, , , (property mutators) , . Visual Basic , Age, HairCount CurrentThought , , :

 Sub UseCollie(fido as ICollie)    fido.HairCount = fido.HairCount - (fido.Age * 1000)    fido.CurrentThought = "I wish I had a bone" End Sub  

++- put_ get_, , :

 void UseCollie(ICollie *pFido)  {     long n1, n2;      HRESULT hr = pFido->get_HairCount(&n1);     assert(SUCCEEDED(hr));      hr = pFido->get_Age(&n2);     assert(SUCCEEDED(hr));      hr = pFido->put_HairCount(n1 - (n2 * 1000)):      assert(SUCCEEDED(hr));      BSTR bstr = SysAllocString(OLESTR("I wish I had a bone"));      hr = pFido->put_CurrentThought(bstr);      assert(SUCCEEDED(hr));      SysFreeString(bstr);  } 

, , 1.


1 Direct-to-COM Microsoft .



Suschnost' tehnologii SOM
Essential COM
ISBN: 0201634465
EAN: 2147483647
Year: N/A
Pages: 103
Authors: Don Box

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net