Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: ActiveX/СОМ/CORBA > Проблема с add-in для MS Outlook


Автор: jenya7 25.9.2007, 21:30
Создал add-in для MS Outlook. При регистрации получаю ошибку:
file not found Outlook_TLB.dcu
Заранее спасибо.

Автор: jenya7 26.9.2007, 10:37
вот мой код

{
   1. Step
   Create an ActiveX-Library
   Save the project as e.g. "OLAddIn.dpr"

   2. Step
   Create an automation object
  Call the CoClass e.g. "AddIn"
  Save the Unit as "AddIn.pas"

  3. Step
   Add to the uses clause
  - AddInDesignerObjects_TLB
  - Outlook_TLB

   add to the interface list of TAddIn
  - IDTExtensibility2

    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;

{
  
  and complete the class by pressing Ctrl-Shft-C

   4. Step
   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. Step
   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.




M
Alexeis
Модератор: используйте подсветку кода  http://forum.vingrad.ru/index.php?show_typ...howtopic=126445

Автор: 2fank 22.10.2007, 13:22
Project -> Import Type Library -> Microsoft Outlook xx.x Object Library -> Create Unit

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)