Download MSDK 9.1 Read_DISK

Transcript
Sample DLL Programs
The following three programs demonstrate complete source code for implementing a
moving average in C, Delphi Pascal, and PowerBASIC/DLL.
“C” Example
//==================================================================
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "MSXStruc.h"
// we don't want C++ name-mangling
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------------BOOL __stdcall MSXInfo (MSXDLLDef *a_psDLLDef)
{
// copy in your copyright information...
strncpy (a_psDLLDef->szCopyright, "Copyright (c) ColdFront Logic, Inc., 2000",
sizeof (a_psDLLDef->szCopyright)-1);
a_psDLLDef->iNFuncs = 1; // One calculation function;
a_psDLLDef->iVersion = MSX_VERSION;
return MSX_SUCCESS;
}
//--------------------------------------------------------------------------BOOL __stdcall MSXNthFunction (int a_iNthFunc, MSXFuncDef *a_psFuncDef)
{
BOOL l_bRtrn = MSX_SUCCESS;
switch (a_iNthFunc)
{
case 0: // a_iNthFunc is zero-based
strcpy (a_psFuncDef->szFunctionName, "MyMov");
strcpy (a_psFuncDef->szFunctionDescription, "My Moving Average");
a_psFuncDef->iNArguments = 3; // 3 arguments: data array, periods, method
break;
default:
l_bRtrn = MSX_ERROR;
break;
}
return l_bRtrn;
}
//--------------------------------------------------------------------------BOOL __stdcall MSXNthArg (int a_iNthFunc, int a_iNthArg,
MSXFuncArgDef *a_psFuncArgDef)
{
BOOL l_bRtrn = MSX_SUCCESS;
a_psFuncArgDef->iNCustomStrings = 0;
switch (a_iNthFunc)
{
case 0:
switch (a_iNthArg)
{
MetaStock ®
Sample DLL Programs • 63