I'm completely new to free-pascal and I try to implement a simple dll that should register a COM class. Unfortunately I could only find little information about COM Programming for freepascal. Thus I hope that someone here can give me some hints or even a link to some examples.
So here is what I did:
- my operating system is Windows 7 64 bit
 - downloaded and installed Lazarus 32bit version
- Version #: 1.2.6
 - Date: 2014-10-11
 - FPC: Version 2.6.4
 - SVN Revision: 46529
 - i386-win32-win32/win64
 
 - installed the ActiveX package in Lazarus
 - made a new project - type 
Librarywith a simpleTAutoObjectand a defaultTAutoObjectFactoryfor the COM registration: source code included after this description - build the dll
 - use 
regsvr32.exeto register my dll --> this fails with"make sure the binary is stored at the specified path ..."
Invalid access to memory location. - then I tried to change the default project options:
under Compiler Options - Config and Target, I set- Target OS: Win32
 - Target CPU family: i386
 
 - still the same error occurs
 
library LazarusSimpleComRegTest;
{$mode objfpc}{$H+}
uses
  Classes,
  { you can add units after this }
  ComServ, MyComObj;
exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,
  DllUnregisterServer;
end.           
MyComObj Unit:
unit MyComObj;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, ComObj;
const
  CLASS_Plugin: TGUID = '{5E020FB0-B593-4ADF-9288-801C2FD432CF}';
type
  TPlugin = class(TAutoObject)
  end;
implementation
uses ComServ;
initialization
  TAutoObjectFactory.Create(ComServer, TPlugin, CLASS_Plugin,
    ciMultiInstance, tmApartment);
end.
				
                        
I think the main problem was, that I did not include the type library as a resource in my dll file: Now it works fine.
I've made a very basic and simple working example on git-hub with some basic documentation: lazarus-com-example