Прочитать PropertyBag в PB

Раздел посвящен программированию с использованием Power Basic.
jangle
Википедик
Википедик
Аватара пользователя
 
Сообщения: 3013
Зарегистрирован: 03.06.2005 (Пт) 12:02
Откуда: Нидерланды

Прочитать PropertyBag в PB

Сообщение jangle » 08.02.2019 (Пт) 20:46

Есть PropertyBag сохраненный в виде файла. Как его прочитать PB кодом?

jangle
Википедик
Википедик
Аватара пользователя
 
Сообщения: 3013
Зарегистрирован: 03.06.2005 (Пт) 12:02
Откуда: Нидерланды

Re: Прочитать PropertyBag в PB

Сообщение jangle » 09.02.2019 (Сб) 12:39

Скомпилировал TLB со следующим кодом:

Код: Выделить всё
[
  uuid(EA544A21-C82D-11D1-A3E4-00A0C90ABCDE),
  version(1.0),
  helpstring("VBA PropertyBag"),
  helpfile("VB98.CHM"),
  helpcontext(0x000df908)
]

library VBRUN
{
    // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");
   
    // Forward declare all types defined in this typelib
    interface _PropertyBag;
    [
      odl,
      uuid(4495AD01-C993-11D1-A3E4-00A0C90AEA82),
      helpstring("A PropertyBag object holds information that is to be persisted across invocations of a control."),
      helpcontext(0x000df639),
      hidden,
      dual,
      nonextensible,
      oleautomation
    ]
    interface _PropertyBag : IDispatch {
        [id(0x00000001), helpstring("Returns a persisted value from a PropertyBag class object."), helpcontext(0x000df63a)]
        HRESULT ReadProperty(
                        [in] BSTR Name,
                        [in, optional] VARIANT DefaultValue,
                        [out, retval] VARIANT* Value);
        [id(0x00000002), helpstring("Writes a value to be persisted to a PropertyBag class object."), helpcontext(0x000df63b)]
        HRESULT WriteProperty(
                        [in] BSTR Name,
                        [in] VARIANT Value,
                        [in, optional] VARIANT DefaultValue);
        [id(0x00000003), propget, helpstring("A byte array representing the contents of the PropertyBag"), helpcontext(0x000df973)]
        HRESULT Contents([out, retval] VARIANT* retval);
        [id(0x00000003), propput, helpstring("A byte array representing the contents of the PropertyBag"), helpcontext(0x000df973)]
        HRESULT Contents([in] VARIANT retval);
    };

    [
      uuid(D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731),
      helpstring("A PropertyBag object holds information that is to be persisted across invocations of a control."),
      helpcontext(0x000df639)
    ]
    coclass PropertyBag {
        [default] interface _PropertyBag;
    };
};


С помощью PowerBasic COM браузера создал обертку


Код: Выделить всё
#Compile Exe
#Dim All
' Class Identifiers
$CLSID_VBRUN_PropertyBag = Guid$("{D5DE8D20-5BB8-11D1-A1E3-00A0C90F2731}")

' Interface Identifiers
$IID_VBRUN_Int__PropertyBag = Guid$("{4495AD01-C993-11D1-A3E4-00A0C90AEA82}")

Interface Int__PropertyBag $IID_VBRUN_Int__PropertyBag
    Inherit IDispatch

    Method ReadProperty   <1>  (ByVal PB_Name As WString, Opt ByVal DefaultValue As Variant) As Variant
    Method WriteProperty  <2>  (ByVal PB_Name As WString, ByVal Value As Variant, Opt ByVal DefaultValue As Variant)
    Property Get Contents <3>  () As Variant
    Property Set Contents <3>  (ByVal retval As Variant)
End Interface


Function PBMain () As Long

   Local PropertyBag As  Int__PropertyBag
         PropertyBag = NewCom $IID_VBRUN_Int__PropertyBag

         PropertyBag.WriteProperty "1", "2"

End Function
                           


Программа крашится на PropertyBag.WriteProperty "1", "2" :(


Вернуться в Power Basic

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4

    TopList