Converting VB6 PropertyBag in .NET

帅比萌擦擦* 提交于 2019-12-02 01:38:37

You can check out Edanmo's Load and save pictures to byte arrays sample on his old VB6 sample page. It's very simple and can be used to "serialize" any object that implements IPersistStream interface like ADODB.Recordset for example. VB6's PropertyBag is using IPersistStream for objects and probably implements "custom" VT_Xxx variant-types serialization.

Btw, Edanmo's code snippet allows you to read images stored via copy/paste to an image column of an Access grid.

Bigtoe

There is 0 support for PropertyBags in .NET. Serailisation of objects replaces the PropertyBag construct.

So as I see it you have 2 choices.

  1. Byte the bullet and write the 10 or 20 line Interop dll.
  2. Analyse the contents of the serialised property bag and see if you can decode it and figure out the offsets of the images and streams etc.

I know which one I'd be heading for.

It is worth pointing out that you can directly access the VB6 PropertyBag from .NET by referencing the VB6 runtime DLL in your project.

Add a reference to: C:\WINDOWS\SysWow64\MSVBVM60.DLL (or might by in System32 folder)

and you will then see PropertyBag in the object browser:

Note that this VB6 class does not have functionality for reading/writing to disk files, byte arrays, etc. It only manages the in-memory data (AFAIK). So this alone does not solve the issue of how to save/load data in whatever format the PropertyBag was stored in.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!