内容纲要

C++ DLL

#include <Windows.h>
#include <atltypes.h>

typedef BOOL(CALLBACK* ahk_callback_proc)(const char*, const char*);

extern "C" _declspec(dllexport) BOOL WINAPI ahk_call_cpp(ahk_callback_proc lpFunc)
{

    lpFunc("中文字符串", "world!");
    return TRUE;
}

AHK

    #SingleInstance force
    #Noenv
    #persistent
    #Warn, LocalSameAsGlobal, Off
    SetBatchLines, -1
    ;DetectHiddenWindows, On
    SetWorkingDir, "%A_ScriptDir%"

    if not ahk_callback_address
        ahk_callback_address := RegisterCallback("ahk_callback_proc", "Fast", 2)

    DllCall("opencv-wrapper.dll\ahk_call_cpp", "Ptr", ahk_callback_address, "UInt")

    ahk_callback_proc(test1, test2)
    {
        ; CP0 默认本机编码
        ; CP936 中文编码
        MsgBox, % StrGet(test1, "CP0")        
        MsgBox, % StrGet(test2, "CP0")
    }

发表评论

电子邮件地址不会被公开。 必填项已用*标注