Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:howto:develop_com_components_and_automation [2009/10/06 11:20] smayr |
swdev:howto:develop_com_components_and_automation [2009/11/05 11:12] (current) smayr |
||
---|---|---|---|
Line 78: | Line 78: | ||
procedure TfrmClientMain.btnLaunchSvrClick(Sender: | procedure TfrmClientMain.btnLaunchSvrClick(Sender: | ||
begin | begin | ||
- | svr := CoMySvr.Create(); | + | |
+ | svr := CoMySvr.Create(); | ||
+ | end; | ||
if Assigned(svr) then begin | if Assigned(svr) then begin | ||
btnGetSvrVersion.Enabled := True; | btnGetSvrVersion.Enabled := True; | ||
Line 91: | Line 93: | ||
== Wrapping an Existing Application Functionality in an Automation Object == | == Wrapping an Existing Application Functionality in an Automation Object == | ||
+ | Especially use this method for Out-of-process automation servers: | ||
* Open an existing Delphi application project. | * Open an existing Delphi application project. | ||
* Select New > ActiveX > Automation Object. | * Select New > ActiveX > Automation Object. | ||
Line 98: | Line 101: | ||
* Select '' | * Select '' | ||
* Register the COM Server. | * Register the COM Server. | ||
- | * Select Run > Register ActiveX Server. | + | |
- | * Setup project to auto register server, to avoid littering the Windows Registry while developing. | + | |
- | * Select Project > Options > Linker > Auto register type library. | + | * Setup project to auto register server, to avoid littering the Windows Registry while developing. |
+ | * Select Project > Options > Linker > Auto register type library. | ||
+ | * Register from command line: < | ||
+ | * Out-of-process (EXE) automation server: | ||
+ | * To register, run this from command line: < | ||
+ | * To unregister, run this from command line: < | ||
== Linking Multiple Clients to a Single Instance of a COM Object == | == Linking Multiple Clients to a Single Instance of a COM Object == | ||
Line 204: | Line 212: | ||
for i := LBound to UBound do begin | for i := LBound to UBound do begin | ||
ElemData := TIntegerArray(sfArrData)[i]; | ElemData := TIntegerArray(sfArrData)[i]; | ||
- | str := str + format(' | + | str := str + format(' |
end; | end; | ||
end; | end; | ||
Line 232: | Line 240: | ||
for i := LBound to UBound do begin | for i := LBound to UBound do begin | ||
SafearrayGetElement(sfArr, | SafearrayGetElement(sfArr, | ||
- | str := str + format(' | + | str := str + format(' |
end; | end; | ||
ShowMessage(str); | ShowMessage(str); | ||
Line 247: | Line 255: | ||
function SafeArrayToIntArr(sfArr: | function SafeArrayToIntArr(sfArr: | ||
var | var | ||
- | ArrayBounds: | ||
- | ArrayData: pointer; | ||
- | i: integer; | ||
LBound, UBound: integer; | LBound, UBound: integer; | ||
+ | sfArrData: pointer; | ||
+ | i: integer; | ||
Arr: TIntegerArray; | Arr: TIntegerArray; | ||
begin | begin | ||
Line 261: | Line 268: | ||
// copy data from safearray to integer array | // copy data from safearray to integer array | ||
- | if SafeArrayAccessData( sfArr, | + | if SafeArrayAccessData( sfArr, |
for i:= LBound to UBound do begin | for i:= LBound to UBound do begin | ||
- | | + | |
end; | end; | ||
SafeArrayUnAccessData(sfArr); | SafeArrayUnAccessData(sfArr); | ||
Line 281: | Line 288: | ||
procedure InitSafearrayTo99(var sfArr: PSafeArray); | procedure InitSafearrayTo99(var sfArr: PSafeArray); | ||
var | var | ||
- | LBound, | + | LBound, |
+ | sfArrData: pointer; | ||
begin | begin | ||
// get PSafeArray boundaries | // get PSafeArray boundaries | ||
SafeArrayGetLBound(sfArr, | SafeArrayGetLBound(sfArr, | ||
- | SafeArrayGetUBound(sfArr, | + | SafeArrayGetUBound(sfArr, |
// copy data to safearray | // copy data to safearray | ||
Line 355: | Line 363: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// |