在.NET中转换VB6 PropertyBag [英] Converting VB6 PropertyBag in .NET

查看:53
本文介绍了在.NET中转换VB6 PropertyBag的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些文件操作,我们使用VB6的PropertyBag对象通过Content属性将各种项目转换为字节数组.然后,我们将字节数组保存为二进制文件的一部分.稍后,当我们加载文件时,我们读回文件,读入字节数组,并使用propertybag的readproperty重新构造该项.我们经常使用它来存储诸如客户徽标之类的图像.

For certain file operations we use VB6's PropertyBag object to convert various items to a bytearray via the Content property. We then save the bytearray as part of a binary file. Later when we load the file we read back the file, read in the bytearray and reconstitute the item by using the propertybag's readproperty. We use this a lot to store images like the customer logo.

.NET框架对使用PropertyBags有什么支持?比编写COM帮助程序DLL更好.Property Bag是仅VB6的构造,还是属于常规OLE/COM自动化框架的一部分?

What support does .NET framework have for working with PropertyBags? Othan than writing a COM helper DLL. Are Property Bags a VB6 only construct or they are part of the general OLE/COM automation framework?

我希望避免编写VB6帮助程序DLL,而直接(通过声明)访问所需的COM函数.我不是要复制功能,而是要将存储在字节数组中的对象转换为它们的.NET等效项.

What I am hoping for is avoiding writing a VB6 helper DLL and accessing directly (via declares) the needed COM functions. I am not looking to replicate the functionality but rather converting the object stored in the bytearray into their .NET equivalent.

注意::我对在.NET中实现属性包的功能不感兴趣.只有能够读取已保存的VB6属性包的字节.

NOTE: I am not interested in implementing the functionality of a property bag in .NET. Only in being able to read the bytes of a saved VB6 Property Bag.

推荐答案

您可以在Edanmo的加载图片并将其保存到字节数组示例.mvps.org/emorcillo/zh-CN/code/vb6/index.shtml"rel =" nofollow noreferrer>旧的VB6示例页面.它非常简单,可用于序列化"任何实现IPersistStream接口的对象,例如ADODB.Recordset.VB6的PropertyBag将IPersistStream用于对象,并且可能实现了自定义" VT_Xxx变量类型序列化.

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.

顺便说一句,Edanmo的代码段使您可以读取通过复制/粘贴存储到Access网格的图像列中的图像.

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

这篇关于在.NET中转换VB6 PropertyBag的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆