Solved

Transfer component through DCOM?

Posted on 2000-04-16
7
172 Views
Last Modified: 2010-04-04
Hi, All
I want transfer the server's directory structure to the client, how to do that?
0
Comment
Question by:yeow
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:xsoft
ID: 2724127
Hi yeow,

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:TComponent):OleVariant;
var P:Pointer;MStream:TMemoryStream;Size:integer;
begin
  MStream:=TMemoryStream.Create;
  try
    MStream.WriteComponent(Component);
    Result:=VarArrayCreate([0,MStream.Size-1],varByte);
    P:=VarArrayLock(Result);
    try
      Move(MStream.Memory^,P^,MStream.Size);
    finally
      VarArrayUnlock(Result);
    end;
  finally
    MStream.Free;
  end;
end;

HTH,

Thomas
0
 

Author Comment

by:yeow
ID: 2726080
Hi, Xsoft
yes. But how to translate it from variant to component?
0
 
LVL 1

Expert Comment

by:xsoft
ID: 2727006
Hi yeow,

to translate the resulting variant to component you could use:

function Var2Component(OleVar:OleVariant):TComponent;
var P:Pointer;MStream:TMemoryStream;
begin
  MStream:=TMemoryStream.Create;
  try
    P:=VarArrayLock(OleVar);
    try
      MStream.WriteBuffer(P^,VarArrayHighBound(OleVar,1)+1);
    finally
      VarArrayUnlock(OleVar);
    end;
    MStream.Seek(0,soFromBeginning);
    Result:=MStream.ReadComponent(nil);
  finally
    MStream.Free;
  end;
end;

HTH,

Thomas

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:yeow
ID: 2729212
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?  
0
 
LVL 1

Accepted Solution

by:
xsoft earned 50 total points
ID: 2730332
Hi yeow,

take a look at:
procedure RegisterClass(AClass: TPersistentClass);
or
procedure RegisterClasses(AClasses: array of TPersistentClass);
0
 

Author Comment

by:yeow
ID: 2733022
u r really expert! THANK U! THANK U!! THANK U!!!
0
 
LVL 1

Expert Comment

by:xsoft
ID: 2733606
Nice to hear that everything is fine.

Thanks for your enthusiasm,

Thomas
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now