I was doing some "stuff" and wondered how "simple" a dll could get. I came up with this to return the CLOSE price, which I think is about as simple as things could get:
|
#include <windows.h> #include "MSXStruc.h"
#define DLL_EXPORT extern "C" __declspec(dllexport)
DLL_EXPORT BOOL __stdcall MSXInfo (MSXDLLDef *a_psDLLDef) { strncpy (a_psDLLDef->szCopyright, "http:\\\\www.wabbit.com.au", sizeof(a_psDLLDef->szCopyright)-1); a_psDLLDef->iNFuncs = 1; a_psDLLDef->iVersion = MSX_VERSION; return MSX_SUCCESS; }
DLL_EXPORT BOOL __stdcall MSXNthFunction (int a_iNthFunc, MSXFuncDef *a_psFuncDef) { strncpy (a_psFuncDef->szFunctionName, "rClose", sizeof(a_psFuncDef->szFunctionName)-1); strncpy (a_psFuncDef->szFunctionDescription, "Returns the CLOSE price.", sizeof(a_psFuncDef->szFunctionDescription)-1); a_psFuncDef->iNArguments = 0; return MSX_SUCCESS; }
DLL_EXPORT BOOL __stdcall rClose (const MSXDataRec *a_psDataRec, const MSXDataInfoRecArgsArray *a_psDataInfoArgs, const MSXNumericArgsArray *a_psNumericArgs, const MSXStringArgsArray *a_psStringArgs, const MSXCustomArgsArray *a_psCustomArgs, MSXResultRec *a_psResultRec) { for (int i=a_psDataRec->sClose.iFirstValid; i<=a_psDataRec->sClose.iLastValid; i++) a_psResultRec->psResultArray->pfValue[ i ] = a_psDataRec->sClose.pfValue[ i ]; a_psResultRec->psResultArray->iFirstValid = a_psDataRec->sClose.iFirstValid; a_psResultRec->psResultArray->iLastValid = a_psDataRec->sClose.iLastValid; return MSX_SUCCESS; }
|
Compiles without a .def under VC++2008, but not under VC6 ?? (I must have a compiler switch set wrong?)
This example is of VERY limited use and is NOT a good example to use as a basis for learning to create MSX libraries or as a template for your own libraries.
Hope this helps.
wabbit
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
Edsgar W. Dijkstra
MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
For custom MetaStock programming : http://www.wabbit.com.au
My SkyPE status : 
My SkyPE account : wabbit.com.au