Skip to content

测试驱动 - DriverTest

函数简介

测试驱动是否正常加载和工作。

接口名称

DriverTest

DLL调用

c
int32_t DriverTest(int64_t instance);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.DriverTest();
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.DriverTest();
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.DriverTest()
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.DriverTest();
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
ret := ola.DriverTest()
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let ret = ola.driver_test();
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.DriverTest()
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.DriverTest()
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.DriverTest()
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.DriverTest();
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.DriverTest()
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.DriverTest();

原生 DLL 调用

cpp
DriverTest(instance);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int DriverTest(long ola);

DriverTest(instance);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.DriverTest(instance)

返回值

成功返回 1;失败时返回值即为错误码(已启用 VT 时走 IsVTEnabled,否则走普通驱动 TestDriver),可配合 GetLastError() / GetLastErrorString() 查询。

完整错误码表见 驱动错误码说明 - DriverErrorCodes

十进制(int32)十六进制说明
1成功,驱动通讯正常。
0权限不足,或与驱动通讯失败(未拿到 Status)。
-3普通欧拉驱动版本不支持(亦可对照 3001)。
其他负数见码表驱动 Status,例如 -10737417900xC0000022 权限不足)。

TIP

接口返回值即为十进制错误码,可在 驱动错误码说明Ctrl+F 搜索该数字快速定位。

注意事项

项目说明
驱动内置欧拉驱动会自动加载;可在调用任意驱动接口后使用本接口验证通信状态。
VT若已调用 EnableVtDriver 启用 VT,本接口会测试 VT 驱动通讯并返回相同风格的错误码。