大网数据广告活动
Windows 系统接口

Persistence

· 52CE 我爱测

A control implements one or more of several persistence interfaces to support persistence of its state. For example, the IPersistStreamInit interface supports stream-based persistence of the control's state. IPersistStreamInit is a replacement for IPersistStream and adds an initialization method, InitNew. The other methods are the same in both interfaces.…

A control implements one or more of several persistence interfaces to support persistence of its state. For example, the IPersistStreamInit interface supports stream-based persistence of the control's state. IPersistStreamInit is a replacement for IPersistStream and adds an initialization method, InitNew. The other methods are the same in both interfaces. IPersistStreamInit is not derived from IPersistStream; an object supports only one of the two interfaces based on whether it requires the ability to initialize new instances of itself.

Other persistence interfaces that a control can offer include: IPersistStorage, IPersistMemory, IPersistPropertyBag, IPersistMoniker. The control implementer must decide what kinds of persistence are most important and implement the appropriate persistence interfaces. The control implementer also decides what to save. For example, a control can save the current values of its properties or its location and size within its container. The client decides which interface it prefers to use.

Before loading a control from its persistent state, a client can check the OLEMISC_SETCLIENTSITEFIRST flag to determine if the control supports getting its client site and ambient properties before loading its persistent state. This optimization can save time when instantiating a control since the control is then free to ignore its persistent values rather than loading them only to have them overridden by ambient properties supplied by the client.

A control can also support saving and restoring its state in an OLE property set, a set of identifiers and values in a specified format. This feature can be useful with containers such as Visual Basic, which saves its programs in a textual form. A control that wants to support this feature implements IDataObject::GetData and IDataObject::SetData to pass its property values to and from the container, respectively. It is the container's job to convert this information to text and save it. The identifiers used by the control correspond to the control's property names and the values. See the OLE CDK for the definition of this property set.

Related topics

ActiveX Controls

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。