我用ATL写的一个简单的测试程序,先用向导加ATL object,又向接口加了方法,与属性,在相应的类里加了short m_port 的保护成员,我想在
STDMETHODIMP CLdap::put_port(double newVal)
{
m_port = newVal; return S_OK;
}
在
STDMETHODIMP CLdap::get_port(short * pVal)
{
// TODO: Add your implementation code here
pVal = &m_port; return S_OK;
}
编译后注册,我要在asp中调用,结果无法为m_port付值,返回值总是0
还有,我还写了method,就是把m_port的值加上100,结果不管怎样,总是0。
STDMETHODIMP CLdap::put_port(double newVal)
{
m_port = newVal; return S_OK;
}
在
STDMETHODIMP CLdap::get_port(short * pVal)
{
// TODO: Add your implementation code here
pVal = &m_port; return S_OK;
}
编译后注册,我要在asp中调用,结果无法为m_port付值,返回值总是0
还有,我还写了method,就是把m_port的值加上100,结果不管怎样,总是0。
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(050EE40C-9504-426A-ABB5-F59738A08BAE),
dual,
helpstring("ILdap Interface"),
pointer_default(unique)
]
interface ILdap : IDispatch
{
[propget, id(1), helpstring("property port")] HRESULT port([out, retval] double *pVal);
[propput, id(1), helpstring("property port")] HRESULT port([in] double newVal);
[id(2), helpstring("method MethodTest")] HRESULT MethodTest(long CoID,BSTR resault);
};[
uuid(5304E0DA-0B95-44F8-BF51-B053B01C18D7),
version(1.0),
helpstring("ldaptest 1.0 Type Library")
]
library LDAPTESTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb"); [
uuid(877C8AA3-372A-4352-B507-1BD71F8BBD04),
helpstring("Ldap Class")
]
coclass Ldap
{
[default] interface ILdap;
};
};
{
// TODO: Add your implementation code here
pVal = &m_port;/// *pVal = m_port 应该是这样的吧!
return S_OK;
}
{
// TODO: Add your implementation code here
*pVal = m_port;
return S_OK;
}
明显问题:修改传进的实参数指针,没任何意义。