Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Transfer component through DCOM?

Posted on 2000-04-16
7
175 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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