L脚本语言同意被其他编程语言调用。如C++,非常easy。仅仅要在宿主语言中载入L脚本引擎的动态库
直接调用这两个函数就能够了
extern "C" int __stdcall ScriptEngineDoString(wchar_t * ScriptString);
extern "C" int __stdcall ScriptEngineDoScriptFile(wchar_t * ScriptFileName);
C语言调用L脚本引擎的样例:
#include <windows.h>
#include "../ScriptEngineDll/ScriptEngineDll.h"
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hDLL = LoadLibraryW(L"ScriptEngineDll.dll");
if(hDLL)
{
FUNC_ScriptEngineDoString ScriptEngineDoString =(FUNC_ScriptEngineDoString)GetProcAddress(hDLL,"ScriptEngineDoString");
if(ScriptEngineDoString)
{
ScriptEngineDoString(L"重新启动:计算机");
}
}
return 0;
}
时间: 2024-10-28 18:59:02