Как написать DLL для советника на MQL4 |
/---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) int test(int x, int y)
{
return (x*y); //вернем из нашей функции произведение переменных X и Y
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport)
//+------------------------------------------------------------------+
//| TestDLL.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#import "Project2.dll" // подключаем нашу DLL
int _test(int x,int y); //функция из нашей DLL
#import
extern int x=5;
extern int y=7;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
Comment("\n",x," * ",y," = ",_test(x,y));
}
//+------------------------------------------------------------------+
test(int x,int y)
_test(int x,int y)
16 августа 2015
|
06 сентября 2015
|
Комментарии (1)
Когда убираем галочки с «Use Dinamic RTL» и «Build with runtime packages», то после компиляции файл будет весить больше, но запускаться будет на любой машине, т.к. в него будут включены все исполняемые компоненты. Редактирован: 24 августа 2021, 20:56
24 ShamanHand Сообщений: 1092 - Наношу добро, причиняю пользу.
Зарегистрируйтесь или авторизуйтесь, чтобы оставить комментарий