delphi调用c++ 写的一个ocx控件 其中有个方法是 中的参数类型是olevariant类型,编译通过,运行时怎么传都报错'类型不匹配'.C++中该接口是这样定义的:
showImage(long framelenght,int codecType,unsigned long frameType,unsigned long width,unsigned long height,char * frame_in)C++中我测试了,是这么调用的:
m_DrawerCtrl1.showImage(framelenght,decode_type,frame_type,width,height,(signed char*)&frame[0]);在delphi中我将socket收到的char数组转换成olevariant类型:
FrameBuff:=VarArrayCreate([0, Flen+1],varbyte);
for i := Low(filemem[displayindex]) to Flen do
begin
FrameBuff[i] := filemem[displayindex][i];
end;
将FrameBuff作为参数传入 编译是通过了 但 运行出现"类型不匹配错误":
showImage(Flen,Ctype,Ftype,Fweight,Fheight,FrameBuff);
showImage(long framelenght,int codecType,unsigned long frameType,unsigned long width,unsigned long height,char * frame_in)C++中我测试了,是这么调用的:
m_DrawerCtrl1.showImage(framelenght,decode_type,frame_type,width,height,(signed char*)&frame[0]);在delphi中我将socket收到的char数组转换成olevariant类型:
FrameBuff:=VarArrayCreate([0, Flen+1],varbyte);
for i := Low(filemem[displayindex]) to Flen do
begin
FrameBuff[i] := filemem[displayindex][i];
end;
将FrameBuff作为参数传入 编译是通过了 但 运行出现"类型不匹配错误":
showImage(Flen,Ctype,Ftype,Fweight,Fheight,FrameBuff);
解决方案 »
- 请教一个记录方面的问题(问题简单,请各位赐教)
- 这句话怎么理解
- 请问如何实现报表中隔开各列的竖线的打印?以及为什么我在QReport中,为什么控件老是会乱跑,修改一下就会跑到页面外的地方?
- 有关三层的问题,出现com server warning这个错误
- 不知怎么办?
- 各位大侠 请教 在线急等!!
- 100元解决这问题,真是气死我了,我就不相信csdn没有一个高手
- 怎么搞的??!!我搜索时怎么老是出错!!!!这网站也做得太差了吧。
- 失望!失望!我都贴了N次帖子,还是没人能回答!“NT Service型的MIDAS应用”
- 一个关于RichEdit不是问题的问题
- 同时激活窗口标题栏
- 高分求线段对象或者是控件
unit DrawerLib_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 : 1.2
// File generated on 2009-4-29 15:08:11 from Type Library described below.// ************************************************************************ //
// Type Lib: D:\drawtest2\Drawer.ocx (1)
// LIBID: {6A665779-7D68-4FE5-BC03-541CD8312A58}
// LCID: 0
// Helpfile: D:\drawtest2\Drawer.hlp
// HelpString: Drawer ActiveX 控件模块
// DepndLst:
// (1) v2.0 stdole, (F:\WINDOWS\system32\stdole2.tlb)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, OleCtrls, OleServer, StdVCL, Variants;
// *********************************************************************//
// 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
DrawerLibMajorVersion = 1;
DrawerLibMinorVersion = 0; LIBID_DrawerLib: TGUID = '{6A665779-7D68-4FE5-BC03-541CD8312A58}'; DIID__DDrawer: TGUID = '{C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}';
DIID__DDrawerEvents: TGUID = '{97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}';
CLASS_Drawer: TGUID = '{83521820-CEE7-41B5-9539-DE89C3BDFCF3}';
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
_DDrawer = dispinterface;
_DDrawerEvents = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
Drawer = _DDrawer;
// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
PShortint1 = ^Shortint; {*}
// *********************************************************************//
// DispIntf: _DDrawer
// Flags: (4096) Dispatchable
// GUID: {C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}
// *********************************************************************//
_DDrawer = dispinterface
['{C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}']
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant); dispid 1;
procedure Hello; dispid 2;
end;// *********************************************************************//
// DispIntf: _DDrawerEvents
// Flags: (4096) Dispatchable
// GUID: {97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}
// *********************************************************************//
_DDrawerEvents = dispinterface
['{97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}']
end;
// *********************************************************************//
// OLE Control Proxy class declaration
// Control Name : TDrawer
// Help String : Drawer Control
// Default Interface: _DDrawer
// Def. Intf. DISP? : Yes
// Event Interface: _DDrawerEvents
// TypeFlags : (34) CanCreate Control
// *********************************************************************//
TDrawer = class(TOleControl)
private
FIntf: _DDrawer;
function GetControlInterface: _DDrawer;
protected
procedure CreateControl;
procedure InitControlData; override;
public
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant);
procedure Hello;
property ControlInterface: _DDrawer read GetControlInterface;
property DefaultInterface: _DDrawer read GetControlInterface;
published
property Anchors;
property TabStop;
property Align;
property DragCursor;
property DragMode;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnStartDrag;
end;procedure Register;resourcestring
dtlServerPage = 'ActiveX'; dtlOcxPage = 'ActiveX';implementationuses ComObj;procedure TDrawer.InitControlData;
const
CControlData: TControlData2 = (
ClassID: '{83521820-CEE7-41B5-9539-DE89C3BDFCF3}';
EventIID: '';
EventCount: 0;
EventDispIDs: nil;
LicenseKey: nil (*HR:$80004005*);
Flags: $00000000;
Version: 401);
begin
ControlData := @CControlData;
end;procedure TDrawer.CreateControl; procedure DoCreate;
begin
FIntf := IUnknown(OleObject) as _DDrawer;
end;begin
if FIntf = nil then DoCreate;
end;function TDrawer.GetControlInterface: _DDrawer;
begin
CreateControl;
Result := FIntf;
end;procedure TDrawer.showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant);
begin
DefaultInterface.showImage(framelenght, codecType, frameType, width, height, frame_in);
end;procedure TDrawer.Hello;
begin
DefaultInterface.Hello;
end;procedure Register;
begin
RegisterComponents(dtlOcxPage, [TDrawer]);
end;end.
我也曾经试图将这个接口中的var frame_in: {??Shortint}OleVariant 改为 frame_in:pchar 但编译错误;位置是
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant); dispid 1;
我在delphi中试过传入 pchar作为frame_in的参数.但编译错位
这个函数是ocx带的方法,我将到如的TLB文件贴出来
unit DrawerLib_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 : 1.2
// File generated on 2009-4-29 15:08:11 from Type Library described below.// ************************************************************************ //
// Type Lib: D:\drawtest2\Drawer.ocx (1)
// LIBID: {6A665779-7D68-4FE5-BC03-541CD8312A58}
// LCID: 0
// Helpfile: D:\drawtest2\Drawer.hlp
// HelpString: Drawer ActiveX 控件模块
// DepndLst:
// (1) v2.0 stdole, (F:\WINDOWS\system32\stdole2.tlb)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, OleCtrls, OleServer, StdVCL, Variants;
// *********************************************************************//
// 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
DrawerLibMajorVersion = 1;
DrawerLibMinorVersion = 0; LIBID_DrawerLib: TGUID = '{6A665779-7D68-4FE5-BC03-541CD8312A58}'; DIID__DDrawer: TGUID = '{C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}';
DIID__DDrawerEvents: TGUID = '{97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}';
CLASS_Drawer: TGUID = '{83521820-CEE7-41B5-9539-DE89C3BDFCF3}';
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
_DDrawer = dispinterface;
_DDrawerEvents = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
Drawer = _DDrawer;
// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
PShortint1 = ^Shortint; {*}
// *********************************************************************//
// DispIntf: _DDrawer
// Flags: (4096) Dispatchable
// GUID: {C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}
// *********************************************************************//
_DDrawer = dispinterface
['{C57B2E4D-CF37-4B6D-A53C-A3F3A25C9524}']
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant); dispid 1;
procedure Hello; dispid 2;
end;// *********************************************************************//
// DispIntf: _DDrawerEvents
// Flags: (4096) Dispatchable
// GUID: {97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}
// *********************************************************************//
_DDrawerEvents = dispinterface
['{97CBBC3A-B5A3-4A31-AB68-24CD7CB4A38F}']
end;
// *********************************************************************//
// OLE Control Proxy class declaration
// Control Name : TDrawer
// Help String : Drawer Control
// Default Interface: _DDrawer
// Def. Intf. DISP? : Yes
// Event Interface: _DDrawerEvents
// TypeFlags : (34) CanCreate Control
// *********************************************************************//
TDrawer = class(TOleControl)
private
FIntf: _DDrawer;
function GetControlInterface: _DDrawer;
protected
procedure CreateControl;
procedure InitControlData; override;
public
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant);
procedure Hello;
property ControlInterface: _DDrawer read GetControlInterface;
property DefaultInterface: _DDrawer read GetControlInterface;
published
property Anchors;
property TabStop;
property Align;
property DragCursor;
property DragMode;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnStartDrag;
end;procedure Register;resourcestring
dtlServerPage = 'ActiveX'; dtlOcxPage = 'ActiveX';implementationuses ComObj;procedure TDrawer.InitControlData;
const
CControlData: TControlData2 = (
ClassID: '{83521820-CEE7-41B5-9539-DE89C3BDFCF3}';
EventIID: '';
EventCount: 0;
EventDispIDs: nil;
LicenseKey: nil (*HR:$80004005*);
Flags: $00000000;
Version: 401);
begin
ControlData := @CControlData;
end;procedure TDrawer.CreateControl; procedure DoCreate;
begin
FIntf := IUnknown(OleObject) as _DDrawer;
end;begin
if FIntf = nil then DoCreate;
end;function TDrawer.GetControlInterface: _DDrawer;
begin
CreateControl;
Result := FIntf;
end;procedure TDrawer.showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant); //var frame_in: {??Shortint}OleVariant);
begin
DefaultInterface.showImage(framelenght, codecType, frameType, width, height, frame_in);
end;procedure TDrawer.Hello;
begin
DefaultInterface.Hello;
end;procedure Register;
begin
RegisterComponents(dtlOcxPage, [TDrawer]);
end;
end.
我曾经试图改过 这几个接口 var frame_in: {??Shortint}OleVariant 改为 frame_in:pchar 但编译时在
procedure showImage(framelenght: Integer; codecType: SYSINT; frameType: LongWord;
width: LongWord; height: LongWord; var frame_in: {??Shortint}OleVariant); dispid 1; 报错
[Error] DrawerLib_TLB.pas(82): Illegal type in OLE automation section: 'Array'