Skip to content

获取最后一次错误ID - GetLastError

函数简介

获取插件内部记录的最后一次错误ID,通常在某个接口调用失败后调用,用于诊断问题类型。

接口名称

GetLastError

DLL调用

c
int GetLastError();

参数说明

此函数无参数。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

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

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

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

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

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

原生 DLL 调用

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

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

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

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

返回值

返回值说明
0(SUCCESS): 操作成功/无错误。
1001(PERMISSION_DENIED): 权限不足或未登录。
1002(INVALID_ARGUMENT): 传入参数无效。
2001(CAPTURE_ERROR): 截图失败。
2002(LOAD_IMAGE_ERROR): 加载图片失败。
2003(HWND_NOT_VALID): 窗口句柄无效。
9999(UNKNOWN_ERROR): 未知错误。

注意事项

项目说明
一般在接口调用失败后立即调用一般在接口调用失败后立即调用,中间再次调用其他接口可能覆盖错误状态。
配合使用可配合 GetLastErrorString 使用,获取对应的错误描述字符串。