主题:[原创]请教用VC++给VFP编DLL函数的问题
我用VC++6.0编写了一个DLL函数,在VFP9中调用这个函数。
VFP 给数组tdx(1)赋值2008, tdx(2)赋值88,然后调用动态链接库函数readday( ),
把数组tdx( )的地址和两个整数变量m_date、m_open的地址传递给readday( ).
readday( ) 把tdx(1)的原始值赋值给m_date, tdx(2)的原始值赋值给m_open.并给tdx(1)和tdx(2)
赋值2001和20。
调用后的返回值应该是
i=20 m_date=2008 m_open=88
tdx(1)=2001 tdx(2)=20
但是程序返回的结果不正确:
i=20 m_date=2008 m_open=0
tdx(1)=2001 tdx(2)=2001
请问如何才能得到正确结果?
如果readday( ) 用一个结构代替数组tdx,又应如何写程序?(我试过,VFP提示数据类型不对)
请高手指教,不胜感激!
E_mail: wanghuihe163@163.com
//myfox.cpp
#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
int _stdcall readday(int *tdx,int *pdate,int *popen)
{
*pdate=*tdx;
*popen=*(tdx+1);
*tdx=2001;
*(tdx+1)=20;
return *(tdx+1);
}
//myfox.def
LIBRARY myfox
EXPORTS
readday @1
readday @2
**vfp test.prg
CLEAR
decla integer readday IN myfox.dll integer @tdx,inte @pdate,inte @popen
dime tdx(8)
tdx(1)=2008
tdx(2)=88
publi m_date as inter,m_open as inter
?"readdy go!"
WAIT
i=readday(@tdx,@m_date,@m_open)
?"returned value is"
?"i=",i,"m_date=",m_date,"m_open=",m_open
?"tdx(1)=",tdx(1),"tdx(2)=",tdx(2)
CLEAR DLLS
RETURN
VFP 给数组tdx(1)赋值2008, tdx(2)赋值88,然后调用动态链接库函数readday( ),
把数组tdx( )的地址和两个整数变量m_date、m_open的地址传递给readday( ).
readday( ) 把tdx(1)的原始值赋值给m_date, tdx(2)的原始值赋值给m_open.并给tdx(1)和tdx(2)
赋值2001和20。
调用后的返回值应该是
i=20 m_date=2008 m_open=88
tdx(1)=2001 tdx(2)=20
但是程序返回的结果不正确:
i=20 m_date=2008 m_open=0
tdx(1)=2001 tdx(2)=2001
请问如何才能得到正确结果?
如果readday( ) 用一个结构代替数组tdx,又应如何写程序?(我试过,VFP提示数据类型不对)
请高手指教,不胜感激!
E_mail: wanghuihe163@163.com
//myfox.cpp
#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
int _stdcall readday(int *tdx,int *pdate,int *popen)
{
*pdate=*tdx;
*popen=*(tdx+1);
*tdx=2001;
*(tdx+1)=20;
return *(tdx+1);
}
//myfox.def
LIBRARY myfox
EXPORTS
readday @1
readday @2
**vfp test.prg
CLEAR
decla integer readday IN myfox.dll integer @tdx,inte @pdate,inte @popen
dime tdx(8)
tdx(1)=2008
tdx(2)=88
publi m_date as inter,m_open as inter
?"readdy go!"
WAIT
i=readday(@tdx,@m_date,@m_open)
?"returned value is"
?"i=",i,"m_date=",m_date,"m_open=",m_open
?"tdx(1)=",tdx(1),"tdx(2)=",tdx(2)
CLEAR DLLS
RETURN