yeow
asked on
Transfer component through DCOM?
Hi, All
I want transfer the server's directory structure to the client, how to do that?
I want transfer the server's directory structure to the client, how to do that?
ASKER
Hi, Xsoft
yes. But how to translate it from variant to component?
yes. But how to translate it from variant to component?
Hi yeow,
to translate the resulting variant to component you could use:
function Var2Component(OleVar:OleVa riant):TCo mponent;
var P:Pointer;MStream:TMemoryS tream;
begin
MStream:=TMemoryStream.Cre ate;
try
P:=VarArrayLock(OleVar);
try
MStream.WriteBuffer(P^,Var ArrayHighB ound(OleVa r,1)+1);
finally
VarArrayUnlock(OleVar);
end;
MStream.Seek(0,soFromBegin ning);
Result:=MStream.ReadCompon ent(nil);
finally
MStream.Free;
end;
end;
HTH,
Thomas
to translate the resulting variant to component you could use:
function Var2Component(OleVar:OleVa
var P:Pointer;MStream:TMemoryS
begin
MStream:=TMemoryStream.Cre
try
P:=VarArrayLock(OleVar);
try
MStream.WriteBuffer(P^,Var
finally
VarArrayUnlock(OleVar);
end;
MStream.Seek(0,soFromBegin
Result:=MStream.ReadCompon
finally
MStream.Free;
end;
end;
HTH,
Thomas
ASKER
Hi Xsoft,
It works. But When I assign it to a component, such as TButton, I got a error: "Class TButton Not Found" ?! My Code is:
MyButton := MStream.ReadComponent(nil) ;
What's wrong in it?
It works. But When I assign it to a component, such as TButton, I got a error: "Class TButton Not Found" ?! My Code is:
MyButton := MStream.ReadComponent(nil)
What's wrong in it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
u r really expert! THANK U! THANK U!! THANK U!!!
Nice to hear that everything is fine.
Thanks for your enthusiasm,
Thomas
Thanks for your enthusiasm,
Thomas
I don't know what you mean by the server's directory structure but if the question is, how to transfer a component through DCOM, the answer would be:
function Component2Var(Component:TC
var P:Pointer;MStream:TMemoryS
begin
MStream:=TMemoryStream.Cre
try
MStream.WriteComponent(Com
Result:=VarArrayCreate([0,
P:=VarArrayLock(Result);
try
Move(MStream.Memory^,P^,MS
finally
VarArrayUnlock(Result);
end;
finally
MStream.Free;
end;
end;
HTH,
Thomas