远程数据模块中添加的接口方法应当用 safecall 还是 stdcall 调用方式?
Win2000+D6, MIDAS
在远程数据模块的接口中添加了一个 Login 方法,默认为 safecall 调用方式。
客户端用 SocketConnection1.AppServer.Login( ) 调用时,抛出“无效的方法调用”异常。
后来在 XXX_TLB.pas 中把 safecall 改为 stdcall,就可以正常调用了。
为什么 safecall 不行呢?按帮助应当是用 safecall 的啊!
The safecall convention must be used for declaring dual-interface methods
A dual interface is an interface that supports both compile-time binding and runtime binding through Automation. Dual interfaces must descend from IDispatch.
All methods of a dual interface (except from those inherited from IInterface and IDispatch) must use the safecall convention, and all method parameter and result types must be automatable. (The automatable types are Byte, Currency, Real, Double, Real48, Integer, Single, Smallint, AnsiString, ShortString, TDateTime, Variant, OleVariant, and WordBool.)