📄 matenginedll.cpp
字号:
// matenginedll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "matenginedll.h"
#include "engine.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CMatenginedllApp, CWinApp)
//{{AFX_MSG_MAP(CMatenginedllApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMatenginedllApp construction
CMatenginedllApp::CMatenginedllApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMatenginedllApp object
CMatenginedllApp theApp;
Engine *ep=NULL;
mxArray *T = NULL;
extern "C" __declspec(dllexport) int MatOpenEng(char *StartCmd)
{
if(ep) return 0;//如果已打开则退出
if(!(ep=engOpen(StartCmd))) return -1;
else return 1;
return 1;
}
extern "C" __declspec(dllexport) int MatCloseEng(void)
{
int Result=engClose(ep);
if (Result==0) //Success
ep=NULL;
return Result;
}
extern "C" __declspec(dllexport) int MatEvalString(char *string)
{
return (engEvalString(ep, string));
}
extern "C" __declspec(dllexport) int MatGetVisible(bool* value)
{
return (engGetVisible(ep, value));
}
extern "C" __declspec(dllexport) int MatSetVisible(bool value)
{
return (engSetVisible(ep, value));
}
extern "C" __declspec(dllexport) int MatPutVariable(char *cc,int num,double dd[])
{
if(!ep) return 0;
if(num<1) return -1;
T=mxCreateDoubleMatrix(1,num,mxREAL);
memcpy((char *)mxGetPr(T),(char *)dd,num * sizeof(double));
engPutVariable(ep,cc,T);
return 1;
}
extern "C" __declspec(dllexport) int MatGetVariable(char *cc,int num,double dd[])
{
mxArray *result;
if(!ep)return 0;
if(num<1)return-1;
result=engGetVariable(ep,cc);
memcpy((char *)dd,(char *)mxGetPr(result),num * sizeof(double));
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -