[fpc-pascal] support for using an activex

Roberto Padovani padovani.r at gmail.com
Mon May 23 15:06:51 CEST 2011


Wow, this sound like good news!

The activex I have is not visual; it is "simply" a class that creates
a thread in which a physical device is controlled through a serial
port, with a particular protocol. The class then has methods like
"Open channel", "Read Mesaure", and so on.

Is there any documentation I can read? I think I have to translate
some header files to understand the exchanged data...or shall I use
only variant ?
I suppose I have to change   MSWord :=
CreateOleObject('Word.Application');   into something related to my
class; where do I discover the "name.surname" ?

Thanks all!


2011/5/23 Ludo Brands <ludo.brands at free.fr>:
> If the activex is not a visual control that you want to put on a LCL form
> you can use CreateOleObject. Note that you don't load ActiveX dll's
> directly. ActiveX objects are registered in Windows by the installer or
> manually with Regsvr32.exe. Windows loads the ddl for you when you call
> CreateOleObject. Ole components are reference counted and released when not
> used anymore.
>
> Here is a simple sample program when you have MS Word installed.
>
>
> program Project1;
>
> {$mode objfpc}{$H+}
>
> uses
>  {$IFDEF UNIX}{$IFDEF UseCThreads}
>  cthreads,
>  {$ENDIF}{$ENDIF}
>  Classes
>  { you can add units after this }
>  ,sysutils,ComObj;
>
> {$R *.res}
>
> var
>  MSWord,WordDoc,WordPara: Variant;
> begin
>  MSWord := CreateOleObject('Word.Application');
>  MSWord.Visible:=true;
>  WordDoc := MSWord.Documents.Add;
>  WordDoc.Activate;
>  WordPara := WordDoc.Content.Paragraphs.Add;
>  WordPara.Range.Text := 'Hello World!';
>  WordDoc.SaveAs('C:\Test.Doc');
>  Sleep(10000);
>  WordDoc.Close(False);
>  MSWord.Quit;
>  MSWord := Unassigned;
>  WordDoc := Unassigned;
>  WordPara := Unassigned;
> end.
>
>
>
> -----Message d'origine-----
> De : fpc-pascal-bounces at lists.freepascal.org
> [mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Roberto
> Padovani
> Envoyé : lundi 23 mai 2011 12:24
> À : FPC-Pascal users discussions
> Objet : [fpc-pascal] support for using an activex
>
>
> Hi List!
>
> I looked around the archives and forum, but I didn't come up with a clear
> answer. Besides, I'm not expert of the win32 and COM world.
>
> If I am given an ActiveX, with source code included, is it possible to using
> from a freepascal / lazarus app like any other dll? I mean loading the dll,
> instantiating the object and calling some methods.
>
> If so, can anyone point me to some documentation or example?
>
> Thanks a lot,
>
>  Roberto
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list