 |
vangosh
初級會員
註冊日期: Apr 2009
來 自:
文章數量: 2 |
[求救]如何实现在dll中调用2个以上的自定义公用函数?
版主,各位大大:
您们好!
小弟我在尝试学习用DLL编写自己的公式。
当我尝试 在dll中调用2个以上的自定义公用函数 时,
我编的dll不能通过编译。
我以举例子方式,
作一个dll来计算输出( ma(c,n) + ema(c,n) ),
现把代码发上来,期待能得到您们的指导,它要如何修正呢?
有劳版主和各位大大了!
原碼:
// FoxFunc.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "FoxFunc.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int fma(float* result, const float* cl, int n, int nStart, int nLast)//
{
int i, j;
float sum;
if ( nLast >= nStart+n-1 ) //
{
for ( i = nStart+n-1; i <= nLast; i++ )
{
sum= 0.0f;
for ( j = i; j > i-n; j-- )
sum += cl[j];
result[i] = sum/n; //计算cl[]的平均值
}
return nStart+n-1;//
}
return -1;
}//自定义公用函数fma;
int fema(float* result, const float* cl, int n, int nStart, int nLast)//
{
int i;
if ( nLast >= nStart ) //
{
result[0] = cl[0] ;
for ( i=1; i <= nLast; i++ )
{
result[i] = ( 2*cl[i]+(n-1)*result[i-1] )/( n+1 );
}
return 0;//
}
return -1;
}//自定义公用函数fema;
__declspec(dllexport) int WINAPI MAEMA(CALCINFO* pData)
{
if( pData->m_pfParam1 && //参数1有效
pData->m_nParam1Start>=0 && //参数1为序列数
pData->m_pfParam3==NULL)//有2个参数
{
const float* pValue = pData->m_pfParam1;//参数1,序列
int nN=(int) *pData->m_pfParam2; //参数2,常数
int nFirst = pData->m_nParam1Start; //起始周期
int nLast =pData->m_nNumData-1; //最大下标
int nFirst1 = fma( float* Result1, pValue, nN, nFirst, nLast); //调用自定义函数fma进行计算,并将结果送入Result1
int nFirst2 = fema( float* Result2, pValue, nN, nFirst, nLast); //调用自定义函数fema进行计算,并将结果送入Result2
return nFirst1+nFirst2;
}
return -1;
}
|
最後由 vangosh 在 2009-04-29 10:10 編輯 |
向版主報告此篇 |  |
|
2009-04-29 10:00 |
|
|
|  |
本站所有內容未經作者授權禁止轉貼節錄, 發表言論僅供參考勿作為投資決策依據。瀏覽本站請使用 IE 5.5 以上版本, 最佳瀏覽解析度 1024 x 768 全彩。
|
Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.
簡愛洋行 製作 Copyright 2003-. All Rights Reserved. 聯絡我們
|