![]() |
在這個頁面顯示本主題全部的 4 個文章 |
奇狐社區論壇 (http://www.chiefox.com.tw/bbs/index.php)
- 問題交流 (http://www.chiefox.com.tw/bbs/forumdisplay.php?forumid=28)
-- [求救]如何实现在dll中调用2个以上的自定义公用函数? (http://www.chiefox.com.tw/bbs/showthread.php?threadid=11462)
[求救]如何实现在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; }
與 DLL 相關之技術使用問題
麻煩請直接到博庭討論區洽詢
http://www.patiosoft.com/community/index.php
謝謝!
引用:
最初由 cgjj 發表
與 DLL 相關之技術使用問題
麻煩請直接到博庭討論區洽詢
http://www.patiosoft.com/community/index.php
謝謝!
引用:
最初由 vangosh 發表
版主大大:
您好!
我是因急着编写出自己的DLL公式才来贵地求助,唉,
望版主大大见谅,希望能得到大大们的帮助了。
全部時間均為台灣時間, 現在時間為16:45 | 在這個頁面顯示本主題全部的 4 個文章 |
Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.
簡愛洋行 製作 Copyright 2003-. All Rights Reserved.