我们公司有一个提供给客户使用的NetM0.dll是用delphi写的。里面有7个导出函数,是这样的。
function Read_Para(Mode: Word; P1: pchar; P2, Address0: LongInt; Para_len: word; Para_array: pchar): LongInt; stdcall;
External 'netm0.dll';
{读取参数时,返回参数Para_len是Para_array的长度;Para_array内按格式存放着终端设备的各项参数}{发送参数}
function Send_Para(Mode: Word; P1: pchar; P2, Address0: LongInt; Para_len: word; Para_array: pchar): LongInt; stdcall;
External 'netm0.dll';
{设置参数时,参数Para_len是Para_array的长度;Para_array内按格式存放着终端设备的各项参数}{发送图片包}
function Send_PicturePack(Mode: Word; P1: pchar; P2, Address0: LongInt; RevertImage, Picture_width, Picture_height: Word; Picture_NO, Picture_Type: Word; Picture_Path: string): LongInt; stdcall;
External 'netm0.dll';
{图片的宽度Picture_width, 高度Picture_height; 图片序号Picture_NO, 类型Picture_Type=0(保留); 图片名称Picture_Path}{发送字库文本包}
function Send_TextPack(Mode: Word; P1: pchar; P2, Address0: LongInt; ANO: Word; txtpath: string): LongInt; stdcall;
External 'netm0.dll';
{文本序号ANO,
文本文件名称txtpath}{发送时间设置包}
//FormatNo=0 代表'%d-%02d-%02d %02d:%02d:%02d'
//FormatNo=1 代表'%d年%02d月%02d日 %02d时%02d分%02d秒'function Send_TimePack(Mode: Word; P1: pchar; P2, Address0: LongInt; ANO, AColorNo: Word; FormatNo: word): LongInt; stdcall;
External 'netm0.dll';{发送节目包}
function Send_Program(Mode: Word; P1: pchar; P2, Address0: LongInt; ANO, BNO, PlayMode, PlaySpeed, DisplayMode, DisplaySpeed: word): LongInt; stdcall;
External 'netm0.dll';
{节目序号ANO,文件序号BNO(即:根据要显示的内容来确定是图片序号或文本序号),
引入模式PlayMode,
引入速度PlaySpeed,
显示模式DisplayMode,
显示时间DisplaySpeed}{发送动作}
function Send_Action(Mode: Word; P1: pchar; P2, Address0: LongInt; BeginNO, EndNO: word): LongInt; stdcall;
External 'netm0.dll';
{起始节目序号BeginNO,
结束节目序号 EndNO}
{完}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////现在人家要我把这个东西以ActiveXDll来封装它,人家在vc6.0里面调用。
之后我还是用delphi创建了activeX.dll项目。
然后就创建了COM组件什么的。
然后直接调用原来DLL里的函数。例如:
function TNetM0.Read_Para(Mode: Word; P1: PChar; P2, Address0: Integer;
  Para_len: Word; Para_array: PChar): Integer;
begin
      //showmessage('hello');
       Result := UFunctionDLL.Read_Para(Mode,
                                        P1,
                                        P2,
                                        Address0,
                                        Para_len,
                                        Para_array);
end;
////////////////////////////////////////////////////////////////////////////////
function TNetM0.Send_Para(Mode: Word; P1: PChar; P2, Address0: Integer;
  Para_len: Word; Para_array: PChar): Integer;
begin
    result:= UFunctionDLL.Send_Para(Mode,
                                    P1,
                                    P2,
                                    Address0,
                                    Para_len,
                                    Para_array);
end;
////////////////////////////////////////////////////////////////////////////////然后编译通过了。接着就要写vc测试程序了。然后在vc的class wizard里面 from a type library什么的。
结果发生这个现象class INetM0 : public COleDispatchDriver
{
public:
INetM0() {} // Calls COleDispatchDriver default constructor
INetM0(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
INetM0(const INetM0& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}// Attributes
public:// Operations
public:
// method 'Read_Para' not emitted because of invalid return type or parameter type
// method 'Send_Para' not emitted because of invalid return type or parameter type
// method 'Send_PicturePack' not emitted because of invalid return type or parameter type
// method 'Send_TextPack' not emitted because of invalid return type or parameter type
// method 'Send_TimePack' not emitted because of invalid return type or parameter type
// method 'Send_Program' not emitted because of invalid return type or parameter type
// method 'Send_Action' not emitted because of invalid return type or parameter type
};
/////////////////////////////////////////////////////////////////////////////
// INetM0 wrapper class
说我参数不对什么的。我一时不知怎么办请高手帮帮忙!
敬礼!