全局脚本支持调用第三方库。可调用非托管库,也可直接引用C#库。
由于全局脚本为标准的C#程序,所以全局脚本无法直接调用C/C++动态库,而是需要通过导出C接口的方式让C#调用。以下为调用C++动态库时的声明示例,声明中需引用System.Runtime.InteropServices程序集)。
using System.Runtime.InteropServices; class UserScript:ScriptMethods,IProcessMethods { [DllImport("ShellRTestAPI.dll", EntryPoint = "fnShellRTestAPI_GetValue")] public static extern int fnShellRTestAPI_GetValue(); [DllImport("ShellRTestAPI.dll", EntryPoint = "fnShellRTestAPI_Add")] public static extern int fnShellRTestAPI_Add(int nValueFirst, int nValueSecond); public void Init() { processCount = 0;} public bool Process() { int nTemp = fnShellRTestAPI_Add(111, 888); SetIntValue("var1_Output", nTemp); return true;} }
第三方C#库可在全局脚本中直接引用,具体操作步骤参见程序集添加。