Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Transfer component through DCOM?

Posted on 2000-04-16
7
Medium Priority
?
181 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
[X]
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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 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