📄 dcom.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>UDDF - COM/DCOM</TITLE>
</HEAD>
<BODY>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">
<IMG SRC="../images/uddf.jpg">
<P><HR></P>
<FONT FACE="Arial Black" SIZE=7 COLOR="#ff0000"><P ALIGN="CENTER">Com/DCom</FONT> </P>
<P><H1><A NAME="dcom0">DCOM</P></A></H1>
<i>Chris Lichti <chlichti+@CS.CMU.EDU></i><p>
Now, on to DCOM. I've written a 3-tier distributed RDBMS app.
using D3's new Remote Data Modules. I had to add some of my own
interfaces and methods to my remote data module in order to
support custom SQL queries from the client. (Was that
necessary?) Thus far, it all works well, and the best part: My
entire client application can be distributed as 2 files! No BDE!
No RDBMS client! No configuration! Cool, huh? The two files
are my .exe, and 'dbclient.dll'.<p>
My initial tests show this sytem to be somewhat slower than the
2-tier method, but I've only been coding DCOM for 2 days, so I'm
hoping to find some ways to speed things up. The slowdown may
also be that my ORB is running on my heavily over-loaded
development machine.<p>
Has anyone else been developing DCOM objects? I'd like to start
a thread here about using Delphi for distributed app
development. I'll be developing several enterprise-level
distributed applications in the coming months. Would anyone
here object to my posting occasional notes about what
tricks/nuances I discover on the way?<p>
<i>Here's a sample:</i><p>
<b>Exporting DB components from Remote Data Modules</b><p>
After you've created an app. and used New->Remote Data Module to
create a data module for your application server, you need to
export whatever TDataSet-derived components or the TProviders
you created for them. To do this, just right-click on them, and
there will be a menu option for exporting from your data module. <p>
<b>Adding your own methods to Remote Data Modules</b><p>
There are two ways to do this. If you right-click on the source
window while viewing the remote data module's source, there will
be an option called Add to Interface. This is a mini-wizard
that lets you type in a procedure, function, or property
declaration. It helps you along by prompting you with helpful
hints. Don't forget that you can't use just any data types for
your parameters. OLE/COM/DCOM/ActiveX/Whatever only supports a
subset of the data types in Delphi. (eg. Use WideString instead
of String) Check in Help under 'types:type libraries' for a
complete list.<p>
Once you've gone through the wizard, Delphi puts your cursor in
the right spot to fill in code for your new method.<p>
The second way of doing this involves using the Type Library
Editor (on the menu under View->Type Library). I suggest using
this if you have lots of methods to add. You can add them all
here, then insert the code later. Unlike Delphi-create
Event-handling headers, these method headers won't go away if
you leave them blank and save your code.<p>
<b>To access your own methods from a Remote Data Module (or other
COM object)</b><p>
The only way I've discovered so far is to use the TRemoteServer
(Data Access page) component. Set the computer name and the
server name. Then call your methods like this: <p>
<hr><pre> MyDataModule.MyRemoteServer.AppServer.MyCustomMethod( myParam,
myParam2 );</pre><hr>
This uses the AppServer property of TRemoteServer. This
property is of type Variant, and in my case it refers to the
Remote Data Module I created.
Note that Delphi won't know if whatever method you call even
exists until
it tries to make the call, so don't be relieved at compile time.
See if it works at run-time. <p>
<b>Problem with Adding your own methods with interfaces in a type
library </b>
Every method I've added to my Remote Data Module via new
interfaces has had a strange problem. After creating my new
interfaces, coding, saving, closing the project, and coming
back, Delphi will sometimes add the 'const' keyword to the
parameter lists of my afformentioned new interfaces. But Delphi
-doesn't- update the parameter lists in my remote data module
code, so when I compile this previously-accepted project, the
compiler complains about conflicting method declarations. I
have to manually add the 'const' keyword to the data module's
method declarations and definitions. Then it will work fine.
Once the 'const' keyword is in there, Delphi seems to leave it
alone. At least, it hasn't pulled that trick on my since I
added 'const' to all my method's parameter lists. <p>
This is going to be a problem for methods that need to be able
to modify their parameters. Does DCOM not support that? Any
ideas?<p>
<HR SIZE="6" COLOR="LIME">
<FONT SIZE="2">
<a href="mailto:rdb@ktibv">Please email me</a> and tell me if you liked this page.<BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("Last modified " + document.lastModified);
// -->
</SCRIPT><P>
<TABLE BORDER=0 ALIGN="CENTER">
<TR>
<TD>This page has been created with </TD>
<TD> <A HREF="http://www.dexnet.com./homesite.html"><IMG SRC="../images/hs25ani.gif" WIDTH=88 HEIGHT=31 BORDER=0 ALT="HomeSite 2.5b">
</A></TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -