...write an Outlook AddIn?
Author: Andreas Rumsch
{
1. Schritt / 1. Step
Erzeuge eine ActiveX-Library
Speichere das Projekt unter z.B. "OLAddIn.dpr"
Create an ActiveX-Library
Save the project as e.g. "OLAddIn.dpr"
2. Schritt / 2. Step
Erzeuge ein Automatisierungs-Objekt
Benenne die CoClass z.B. mit "AddIn"
Speichere die Unit als z.B. "AddIn.pas"
Create an automation object
Call the CoClass e.g. "AddIn"
Save the Unit as "AddIn.pas"
3. Schritt / 3. Step
Ergänze die uses-Anweisung um
Add to the uses clause
- AddInDesignerObjects_TLB
- Outlook_TLB
Ergänze die Interface-Liste von TAddIn um
add to the interface list of TAddIn
- IDTExtensibility2
Ergänze die Deklaration um folgende Methoden
Add the following methods to TAddIn
}
- procedure OnConnection(const Application: IDispatch; ConnectMode: ext_ConnectMode;
const AddInInst: IDispatch; var custom: PSafeArray); safecall;
- procedure OnDisconnection(RemoveMode: ext_DisconnectMode; var custom: PSafeArray); safecall;
- procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
- procedure OnStartupComplete(var custom: PSafeArray); safecall;
- procedure OnBeginShutdown(var custom: PSafeArray); safecall;
{
und vervollständige die Unit mit der Implementation dieser Methoden (Ctrl-Shft-C)
and complete the class by pressing Ctrl-Shft-C
4. Schritt / 4. Step
Registriere das COM-Objekt des Addins mit "Run / Register ActiveX Server"
Registriere das AddIn, so dass Outlook dieses als AddIn erkennt
- Erzeuge den Schlüssel: HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\OLAddIn.AddIn
- Trage dort den DWORD-Wert "LoadBehavior" mit dem Wert 03 ein
Register the COM-object with "run / register ActiveX Server"
Register the AddIn, so that the Addin will be recognized by Outlook
- Create a new key: HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\OLAddIn.AddIn
- create a DWOrd "LoadBehavior" with the value 3
5. Schritt / 5. Step
Kompiliere das Addin
Starte Outlook
Compile the AddIn
Start Outllok
Sourcecode
*********************************************************************************
}
library OLAddIn;
uses
ComServ,
OLAddIn_TLB in 'OLAddIn_TLB.pas',
AddIn in 'AddIn.pas' {AddIn: CoClass};
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
{$R *.TLB}
{$R *.RES}
begin
end.
{
*********************************************************************************
*********************************************************************************
}
unit AddIn;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, OLAddIn_TLB, StdVcl, AddinDesignerObjects_TLB, Outlook_TLB;
type
TAddIn = class(TAutoObject, IAddIn, IDTExtensibility2)
protected
{ Protected declarations }
procedure OnConnection(const Application: IDispatch; ConnectMode: ext_ConnectMode;
const AddInInst: IDispatch; var custom: PSafeArray); safecall;
procedure OnDisconnection(RemoveMode: ext_DisconnectMode; var custom: PSafeArray); safecall;
procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
procedure OnStartupComplete(var custom: PSafeArray); safecall;
procedure OnBeginShutdown(var custom: PSafeArray); safecall;
end;
implementation
uses ComServ, Dialogs;
{ TAddIn }
procedure TAddIn.OnAddInsUpdate(var custom: PSafeArray);
begin
end;
procedure TAddIn.OnBeginShutdown(var custom: PSafeArray);
begin
end;
procedure TAddIn.OnConnection(const Application: IDispatch;
ConnectMode: ext_ConnectMode; const AddInInst: IDispatch;
var custom: PSafeArray);
begin
// To show, that the AddIn has started just say anything
ShowMessage('Das AddIn wurde gestartet');
end;
procedure TAddIn.OnDisconnection(RemoveMode: ext_DisconnectMode;
var custom: PSafeArray);
begin
end;
procedure TAddIn.OnStartupComplete(var custom: PSafeArray);
begin
end;
initialization
TAutoObjectFactory.Create(ComServer, TAddIn, Class_AddIn,
ciMultiInstance, tmApartment);
end.
printed from
www.swissdelphicenter.ch
developers knowledge base