VC中IDispatch派生接口方法的原型为:
HRESULT Start(BSTR p_Unit, BSTR p_Method, BSTR p_Parameter);
返回值为HRESULT类型。可是用VC生成的*.tlb文件,转变为Delphi的*_TLB.pas文件时,函数原型变为:
procedure Start(const p_Unit: WideString; const p_Method: WideString;
const p_Parameter: WideString); safecall;
没有返回值。我该怎么得到VC中函数的返回值?谢!
HRESULT Start(BSTR p_Unit, BSTR p_Method, BSTR p_Parameter);
返回值为HRESULT类型。可是用VC生成的*.tlb文件,转变为Delphi的*_TLB.pas文件时,函数原型变为:
procedure Start(const p_Unit: WideString; const p_Method: WideString;
const p_Parameter: WideString); safecall;
没有返回值。我该怎么得到VC中函数的返回值?谢!
Calling conventions
Directive Parameter order Clean-up Passes parameters in registers?
register Left-to-right Routine Yes
pascal Left-to-right Routine No
cdecl Right-to-left Caller No
stdcall Right-to-left Routine No
safecall Right-to-left Routine NoVC的safecall 好像没见过。procedure Start(const p_Unit: WideString; const p_Method: WideString;
const p_Parameter: WideString); safecall;
还都用const??没搞错 那这个函数有什么意义起码要用个var引用吧。。
const p_Parameter: WideString); safecall;
上面这个函数是delphi自动生成的!VC当然没有safecall,可是VC的IDispatch接口方法,转变为delphi的方法时,就变为safecall的了。
HRESULT -> LONGIN COM:
HRESULT
An opaque result handle defined to be zero for a successful return from a function and nonzero if error or status information is returned. To convert an HRESULT into the more detailed SCODE, applications call GetScode(). See also SCODE.
HRESULT Start(BSTR p_Unit, BSTR p_Method, BSTR p_Parameter,long ReturnValue);
把返回的S_OK或者S_FALSE赋给ReturnValue,然后在转化到Delphi中或VB中就会是一个函数而不是过程。
在内部处理上HRESULT就是一个LONG型的长整数
你的转换工具错误了吧 DELPHI中有LRESULT类型的直接用就是 其实也就是一个LONG<在DELPHI中是一个LongInt>