?
Solved

Transfer component through DCOM?

Posted on 2000-04-16
7
Medium Priority
?
180 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

741 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