Newsgroup: it.comp.lang.delphi
Titolo: prima volta che utilizzo COM ... [lungo; contiene codice]

ho importato in delphi un OCX
ed il bravo e fidato delphi mi ha messo a
disposizione la seguente unità
8<-----------------------------------------------------------------
unit RDataMatrixX_TLB;
// 
************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// 
************************************************************************ //
// PASTLWTR : $Revision:   1.88.1.0.1.0  $
// File generated on 11/18/2004 4:54:29 PM from Type Library described 
below.
// 
************************************************************************ //
// Type Lib: C:\OCX_VB\rdmx_full\RDMX.ocx (1)
// IID\LCID: {C57B3586-D4B6-11D6-AB8C-006008BAAE59}\0
// Helpfile:
// DepndLst:
//   (1) v2.0 stdole, (C:\WINNT\system32\stdole2.tlb)
//   (2) v4.0 StdVCL, (C:\WINNT\system32\STDVCL40.DLL)
// 
************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
interface
uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL, 
DbOleCtl;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
//   Type Libraries     : LIBID_xxxx
//   CoClasses          : CLASS_xxxx
//   DISPInterfaces     : DIID_xxxx
//   Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
   // TypeLibrary Major and minor versions
   RDataMatrixXMajorVersion = 32;
   RDataMatrixXMinorVersion = 0;
   LIBID_RDataMatrixX: TGUID = '{C57B3586-D4B6-11D6-AB8C-006008BAAE59}';
   IID__RDMx: TGUID = '{A97C2036-DB98-11D6-ABAE-006008BAAE59}';
   DIID___RDMx: TGUID = '{A97C203B-DB98-11D6-ABAE-006008BAAE59}';
   CLASS_RDMx: TGUID = '{C57B3588-D4B6-11D6-AB8C-006008BAAE59}';
// *********************************************************************//
// Declaration of Enumerations defined in Type Library
// *********************************************************************//
// Constants for enum tConf
type
   tConf = TOleEnum;
const
   CONF_ROW = $00000000;
   CONF_COL = $00000001;
   CONF_ROWDATA = $00000002;
   CONF_COLDATA = $00000003;
   CONF_REGIONS = $00000004;
   CONF_ROWMAP = $00000005;
   CONF_COLMAP = $00000006;
   CONF_TOTALDATA = $00000007;
   CONF_TOTALERR = $00000008;
   CONF_REEDDATA = $00000009;
   CONF_REEDERR = $0000000A;
   CONF_REEDBLOCKS = $0000000B;
// Constants for enum tChars
type
   tChars = TOleEnum;
const
   C40_PAD = $00000000;
   PAD = $00000081;
   LATCH_C40 = $000000E6;
   LATCH_BASE256 = $000000E7;
   FNC1 = $000000E8;
   STRUCTURED_APPEND = $000000E9;
   READER_PROGRAMMING = $000000EA;
   Shift = $000000EB;
   MACRO5 = $000000EC;
   MACRO6 = $000000ED;
   LATCH_TEXT = $000000EF;
   ECI_CHAR = $000000F1;
   UNLATCH = $000000FE;
// Constants for enum tDSize
type
   tDSize = TOleEnum;
const
   C10X10 = $00000000;
   C12X12 = $00000001;
   C14X14 = $00000002;
   C16X16 = $00000003;
   C18X18 = $00000004;
   C20X20 = $00000005;
   C22X22 = $00000006;
   C24X24 = $00000007;
   C26X26 = $00000008;
   C32X32 = $00000009;
   C36X36 = $0000000A;
   C40X40 = $0000000B;
   C44X44 = $0000000C;
   C48X48 = $0000000D;
   C52X52 = $0000000E;
   C64X64 = $0000000F;
   C72X72 = $00000010;
   C80X80 = $00000011;
   C88X88 = $00000012;
   C96X96 = $00000013;
   C104X104 = $00000014;
   C120X120 = $00000015;
   C132X132 = $00000016;
   C144X144 = $00000017;
   C8X18 = $00000018;
   C8X32 = $00000019;
   C12X26 = $0000001A;
   C12X36 = $0000001B;
   C16X36 = $0000001C;
   C16X48 = $0000001D;
// Constants for enum tEncoding
type
   tEncoding = TOleEnum;
const
   E_ASCII = $00000000;
   E_C40 = $00000001;
   E_TEXT = $00000002;
   E_BASE256 = $00000003;
   E_NONE = $00000004;
   E_AUTO = $00000005;
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
   _RDMx = interface;
   _RDMxDisp = dispinterface;
   __RDMx = dispinterface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
   RDMx = _RDMx;
// *********************************************************************//
// Interface: _RDMx
// Flags:     (4560) Hidden Dual NonExtensible OleAutomation Dispatchable
// GUID:      {A97C2036-DB98-11D6-ABAE-006008BAAE59}
// *********************************************************************//
   _RDMx = interface(IDispatch)
     ['{A97C2036-DB98-11D6-ABAE-006008BAAE59}']
     function  Get_m_encoding: Smallint; safecall;
     procedure Set_m_encoding(m_encoding: Smallint); safecall;
     function  Get_m_preferredFormat: Smallint; safecall;
     procedure Set_m_preferredFormat(m_preferredFormat: Smallint); safecall;
     function  isDigit(c: Smallint): WordBool; safecall;
     procedure setSize(var w: Smallint; var h: Smallint); safecall;
     function  Get_paintedHeight: Smallint; safecall;
     function  Get_paintedWidth: Smallint; safecall;
     function  encodeAscii(var longi: Smallint; var ina: PSafeArray; var 
outa: PSafeArray;
                           var specialSymbols: PSafeArray): Smallint; 
safecall;
     procedure utah(row: Smallint; col: Smallint; chr: Smallint); safecall;
     procedure corner1(var chr: Smallint); safecall;
     procedure corner2(var chr: Smallint); safecall;
     procedure corner3(var chr: Smallint); safecall;
     procedure corner4(var chr: Smallint); safecall;
     procedure module(r: Smallint; c: Smallint; chr: Smallint; bit: 
Smallint); safecall;
     procedure make; safecall;
     procedure drawBorders(var map: OleVariant; var x: Smallint; var y: 
Smallint; var w: Smallint;
                           var h: Smallint); safecall;
     procedure copyArray(var src: PSafeArray; var dest: PSafeArray; var 
initSrc: Smallint;
                         var initDest: Smallint; var longi: Smallint); 
safecall;
     function  random255(var code: Smallint; var pos: Smallint): 
Smallint; safecall;
     procedure debugMatrix(var m: OleVariant; var c: Smallint; var r: 
Smallint); safecall;
     function  createBitmap(var codeStr: PSafeArray): OleVariant; safecall;
     procedure calcRS(var Data: OleVariant; var block: Smallint; var k: 
Smallint; var t2: Smallint); safecall;
     function  gfadd(var add1: Smallint; var add2: Smallint): Smallint; 
safecall;
     procedure setpolynomial(var t2: Smallint); safecall;
     function  mult(a: Smallint; b: Smallint): Smallint; safecall;
     procedure paintBarcode; safecall;
     function  Get_barBackColor: OLE_COLOR; safecall;
     procedure Set_barBackColor(Param1: OLE_COLOR); safecall;
     function  Get_barForeColor: OLE_COLOR; safecall;
     procedure Set_barForeColor(Param1: OLE_COLOR); safecall;
     function  Get_encoding: Smallint; safecall;
     procedure Set_encoding(Param1: Smallint); safecall;
     function  Get_preferredFormat: Smallint; safecall;
     procedure Set_preferredFormat(Param1: Smallint); safecall;
     function  Get_dotsPixel: Smallint; safecall;
     procedure Set_dotsPixel(Param1: Smallint); safecall;
     function  Get_applyTilde: WordBool; safecall;
     procedure Set_applyTilde(Param1: WordBool); safecall;
     function  Get_bartopMargin: Smallint; safecall;
     procedure Set_bartopMargin(Param1: Smallint); safecall;
     function  Get_barleftMargin: Smallint; safecall;
     procedure Set_barleftMargin(Param1: Smallint); safecall;
     function  saveToBMP(var f: WideString): Smallint; safecall;
     function  Get_barcode: WideString; safecall;
     procedure Set_barcode(const Param1: WideString); safecall;
     procedure Set_standAlone(Param1: WordBool); safecall;
     function  Get_standAlone: WordBool; safecall;
     function  arraySize(var a: OleVariant): Smallint; safecall;
     function  lookAheadTest(var Data: PSafeArray; currentEnc: Smallint; 
pos: Smallint;
                             var specialSymbols: PSafeArray): 
OleVariant; safecall;
     function  encodeAuto(longi: Smallint; var ina: PSafeArray; var 
outa: PSafeArray;
                          var specialSymbols: PSafeArray): Smallint; 
safecall;
     function  encodeBase256(var longi: Smallint; var initial: 
PSafeArray; var ina: PSafeArray;
                             var outInit: PSafeArray; var outa: PSafeArray;
                             var makeLookAhead: WordBool; var 
specialSymbols: PSafeArray): OleVariant; safecall;
     procedure paintBasis; safecall;
     procedure paintDot(var x: Smallint; var y: Smallint; var w: 
Smallint; var c: OLE_COLOR); safecall;
     function  random253(var code: Smallint; var pos: Smallint): 
Smallint; safecall;
     function  processTilde(var code: WideString; var specialSymbol: 
PSafeArray): WideString; safecall;
     procedure doCode; safecall;
     function  drawBarcode(var codeStr: PSafeArray; var specialSymbols: 
PSafeArray): OleVariant; safecall;
     function  encodeC40(var longi: Smallint; var initial: PSafeArray; 
var ina: PSafeArray;
                         var outa: PSafeArray; var doTextEncoding: WordBool;
                         var inititaLatch: WordBool; var onlyOneWord: 
WordBool): Smallint; safecall;
     property m_encoding: Smallint read Get_m_encoding write Set_m_encoding;
     property m_preferredFormat: Smallint read Get_m_preferredFormat 
write Set_m_preferredFormat;
     property paintedHeight: Smallint read Get_paintedHeight;
     property paintedWidth: Smallint read Get_paintedWidth;
     property barBackColor: OLE_COLOR read Get_barBackColor write 
Set_barBackColor;
     property barForeColor: OLE_COLOR read Get_barForeColor write 
Set_barForeColor;
     property encoding: Smallint read Get_encoding write Set_encoding;
     property preferredFormat: Smallint read Get_preferredFormat write 
Set_preferredFormat;
     property dotsPixel: Smallint read Get_dotsPixel write Set_dotsPixel;
     property applyTilde: WordBool read Get_applyTilde write Set_applyTilde;
     property bartopMargin: Smallint read Get_bartopMargin write 
Set_bartopMargin;
     property barleftMargin: Smallint read Get_barleftMargin write 
Set_barleftMargin;
     property barcode: WideString read Get_barcode write Set_barcode;
     property standAlone: WordBool read Get_standAlone write Set_standAlone;
   end;
// *********************************************************************//
// DispIntf:  _RDMxDisp
// Flags:     (4560) Hidden Dual NonExtensible OleAutomation Dispatchable
// GUID:      {A97C2036-DB98-11D6-ABAE-006008BAAE59}
// *********************************************************************//
   _RDMxDisp = dispinterface
     ['{A97C2036-DB98-11D6-ABAE-006008BAAE59}']
     property m_encoding: Smallint dispid 1073938458;
     property m_preferredFormat: Smallint dispid 1073938459;
     function  isDigit(c: Smallint): WordBool; dispid 1610809356;
     procedure setSize(var w: Smallint; var h: Smallint); dispid 1610809357;
     property paintedHeight: Smallint readonly dispid 1745027083;
     property paintedWidth: Smallint readonly dispid 1745027082;
     function  encodeAscii(var longi: Smallint; var ina: {??PSafeArray} 
OleVariant;
                           var outa: {??PSafeArray} OleVariant;
                           var specialSymbols: {??PSafeArray} 
OleVariant): Smallint; dispid 1610809358;
     procedure utah(row: Smallint; col: Smallint; chr: Smallint); dispid 
1610809359;
     procedure corner1(var chr: Smallint); dispid 1610809360;
     procedure corner2(var chr: Smallint); dispid 1610809361;
     procedure corner3(var chr: Smallint); dispid 1610809362;
     procedure corner4(var chr: Smallint); dispid 1610809363;
     procedure module(r: Smallint; c: Smallint; chr: Smallint; bit: 
Smallint); dispid 1610809364;
     procedure make; dispid 1610809365;
     procedure drawBorders(var map: OleVariant; var x: Smallint; var y: 
Smallint; var w: Smallint;
                           var h: Smallint); dispid 1610809366;
     procedure copyArray(var src: {??PSafeArray} OleVariant; var dest: 
{??PSafeArray} OleVariant;
                         var initSrc: Smallint; var initDest: Smallint; 
var longi: Smallint); dispid 1610809367;
     function  random255(var code: Smallint; var pos: Smallint): 
Smallint; dispid 1610809368;
     procedure debugMatrix(var m: OleVariant; var c: Smallint; var r: 
Smallint); dispid 1610809369;
     function  createBitmap(var codeStr: {??PSafeArray} OleVariant): 
OleVariant; dispid 1610809370;
     procedure calcRS(var Data: OleVariant; var block: Smallint; var k: 
Smallint; var t2: Smallint); dispid 1610809371;
     function  gfadd(var add1: Smallint; var add2: Smallint): Smallint; 
dispid 1610809372;
     procedure setpolynomial(var t2: Smallint); dispid 1610809373;
     function  mult(a: Smallint; b: Smallint): Smallint; dispid 1610809374;
     procedure paintBarcode; dispid 1610809375;
     property barBackColor: OLE_COLOR dispid 1745027081;
     property barForeColor: OLE_COLOR dispid 1745027080;
     property encoding: Smallint dispid 1745027079;
     property preferredFormat: Smallint dispid 1745027078;
     property dotsPixel: Smallint dispid 1745027077;
     property applyTilde: WordBool dispid 1745027076;
     property bartopMargin: Smallint dispid 1745027075;
     property barleftMargin: Smallint dispid 1745027074;
     function  saveToBMP(var f: WideString): Smallint; dispid 1610809376;
     property barcode: WideString dispid 1745027073;
     property standAlone: WordBool dispid 1745027072;
     function  arraySize(var a: OleVariant): Smallint; dispid 1610809381;
     function  lookAheadTest(var Data: {??PSafeArray} OleVariant; 
currentEnc: Smallint;
                             pos: Smallint; var specialSymbols: 
{??PSafeArray} OleVariant): OleVariant; dispid 1610809384;
     function  encodeAuto(longi: Smallint; var ina: {??PSafeArray} 
OleVariant;
                          var outa: {??PSafeArray} OleVariant;
                          var specialSymbols: {??PSafeArray} 
OleVariant): Smallint; dispid 1610809385;
     function  encodeBase256(var longi: Smallint; var initial: 
{??PSafeArray} OleVariant;
                             var ina: {??PSafeArray} OleVariant;
                             var outInit: {??PSafeArray} OleVariant;
                             var outa: {??PSafeArray} OleVariant; var 
makeLookAhead: WordBool;
                             var specialSymbols: {??PSafeArray} 
OleVariant): OleVariant; dispid 1610809386;
     procedure paintBasis; dispid 1610809387;
     procedure paintDot(var x: Smallint; var y: Smallint; var w: 
Smallint; var c: OLE_COLOR); dispid 1610809388;
     function  random253(var code: Smallint; var pos: Smallint): 
Smallint; dispid 1610809389;
     function  processTilde(var code: WideString; var specialSymbol: 
{??PSafeArray} OleVariant): WideString; dispid 1610809390;
     procedure doCode; dispid 1610809391;
     function  drawBarcode(var codeStr: {??PSafeArray} OleVariant;
                           var specialSymbols: {??PSafeArray} 
OleVariant): OleVariant; dispid 1610809392;
     function  encodeC40(var longi: Smallint; var initial: 
{??PSafeArray} OleVariant;
                         var ina: {??PSafeArray} OleVariant; var outa: 
{??PSafeArray} OleVariant;
                         var doTextEncoding: WordBool; var inititaLatch: 
WordBool;
                         var onlyOneWord: WordBool): Smallint; dispid 
1610809393;
   end;
// *********************************************************************//
// DispIntf:  __RDMx
// Flags:     (4240) Hidden NonExtensible Dispatchable
// GUID:      {A97C203B-DB98-11D6-ABAE-006008BAAE59}
// *********************************************************************//
   __RDMx = dispinterface
     ['{A97C203B-DB98-11D6-ABAE-006008BAAE59}']
   end;
implementation
uses ComObj;
end.
8<-----------------------------------------------------------------
ora dal mio codice provo ad eseguire
queste cose
8<-----------------------------------------------------------------
procedure TForm1.btnCreateClick(Sender: TObject);
var
   ADataMatrix : _RDMxDisp;
   ABitmapOLE : OleVariant;
   sCodice : OleVariant;
   ABitmap : TBitmap;
   SClassName : String;
begin
    sClassName := 'RDataMatrixX.RDMx';
    ADataMatrix :=  _RDMxDisp(CreateOLEObject(SClassName));
    ABitmap := TBitmap.Create;
    sCodice := 'AG212BE-1';
    ADataMatrix.m_encoding := 1;
    ABitmapOLE := ADataMatrix.createBitmap(sCodice);
    VarToBMP(ABitmapOLE, ABitmap);
end;
8<-----------------------------------------------------------------
quando viene eseguito
ABitmapOLE := ADataMatrix.createBitmap(sCodice);
viene sollevata una eccezione del tipo
raised exception class EOleSysError with message 'Type mismatch'
dove sto sbagliando
ringrazio anticipatamente per i Vs. preziosi suggerimenti
Cordialmennte,
Stefano

 disposizione la seguente unità
[CUT]
per curiosità utilizzi delphi 6?...
perchè D6 ha un bug nell'import degli OCX in particola modo nella creazione
della unit.
( 
http://tinyurl.com/6qtmj
 )
Io ho risolto importando il componente con Delphi 5.
ciao
  gabriele

 per curiosità utilizzi delphi 6?...
no
utilizzo D5
magari provando a re-importare può servire ?!?!