给你个例子
用ipersistpropertybag接口
tactiveformx=class(tactiveformx,iactiveformx,persistpropertybag)
在protected中,实现ipersistPropertyBag接口的方法如下:
function IPersistPropertyBag.Load=persistpopertybagLoad;
function IPersistPropertyBag.save=persistpopertybagsave;
function IPersistPropertyBag.InitNew=persistpopertybagInitNew;
function IPersistPropertyBag.GetClassId=persistpopertybaggetClassId;
function persistpopertybagLoad(const pPropbag:ipropertyBag;const pErrorLog:iErrorLog):hresult;stdcall;
function persistpopertybagsave(const pPropbag:ipropertyBag;fcleardirty:bool;fsaveallproperties:bool):hresult;stdcall;
function persistpopertybagInitNew:hresult;stdcall;
function persistpopertybaggetClassId(out classid:tclsid):hresult;stdcall;
具体实现如下:
function persistpopertybagLoad(const pPropbag:ipropertyBag;const pErrorLog:iErrorLog):hresult;stdcall;
var
v
levariant;
begin
if ppropbag.read('paramName',v,pErrorlog)=s_ok then begin
//v是读出的值
end;
result:=s_ok;
end;
function persistpopertybagsave(const pPropbag:ipropertyBag;fcleardirty:bool;fsaveallproperties:bool):hresult;stdcall;
begin
result:=s_ok;
end;
function persistpopertybagInitNew:hresult;stdcall;
begin
result:=s_ok;
end;
function persistpopertybaggetClassId(out classid:tclsid):hresult;stdcall;
begin
result:=s_ok;
end;
写的太匆忙,难免有错,自己看看把