【问题标题】:js-ctypes: Pointer to intptr_tjs-ctypes:指向 intptr_t 的指针
【发布时间】:2014-06-18 08:25:02
【问题描述】:

在我的 ctypes 中

TBButton.ptr(ctypes.UInt64("0x1e677e60")

这相当于这里这行代码中的aButton.address()

var rez = SendMessage(hToolbar, 0x417 /** TB_GETBUTTON **/, 1, aButton.address());

当我运行这段代码时,我得到了错误:

异常:预期类型 intptr_t,得到 TBButton.ptr(ctypes.UInt64("0xaa4eb20"))

所以这是因为在我的SendMessage 定义中我有这个:

var SendMessage = user32.declare('SendMessageW', ctypes.winapi_abi, ctypes.intptr_t,
    ctypes.voidptr_t, // HWND
    ctypes.uint32_t, // MSG
    ctypes.uintptr_t, // WPARAM
    ctypes.intptr_t // LPARAM
);

所以我的问题是:TBButton.ptr(ctypes.UInt64("0x1e677e60") 的类型是什么,所以我可以将 SendMessage 定义中的 LPARAM 更改为这种类型。

或者:是否可以将其设为intptr_tctypes.intptr_t(aButton.address()) 之类的东西,我试过了,它不起作用。

【问题讨论】:

    标签: javascript firefox-addon jsctypes


    【解决方案1】:

    它是一个指向TBButton 的指针,不管TBButton 是什么,而intptr_t 实际上是一个大到足以容纳指针地址的整数。

    您需要将指针转换为intptr_t

    var lparam = ctypes.cast(tbbuttonptr, ctypes.intptr_t);
    

    【讨论】:

    • 我试过这个但我得到错误:var aButton = ctypes.cast(new struct_TBButton(), ctypes.intptr_t); var rez = SendMessage(hToolbar, 0x417 /** TB_GETBUTTON **/, 1, aButton.address()); 错误返回是 = Exception: expected type intptr_t, got ctypes.intptr_t.ptr(ctypes.UInt64("0x11d87c00"))
    • 如果我再做aButton.address(),它就会挂在drwatsn32.exe上:var aButton = ctypes.cast(new struct_TBButton(), ctypes.intptr_t); var rez = SendMessage(hToolbar, 0x417 /** TB_GETBUTTON **/, 1, aButton);
    • 我的代码在这里:gist.github.com/Noitidart/f691ab9a750f24be346f(它在 winxp 上)请帮助我长期苦苦挣扎:(
    • 试过了,它在 drwatsn32.exe 上崩溃/挂起:(var aButton = new struct_TBButton(); var rez = SendMessage(hToolbar, 0x417 /** TB_GETBUTTON **/, 1, ctypes.cast(aButton.address(), ctypes.intptr_t));我杀死 drwatsn32.exe 进程后 rez 的值为 0
    • 这与问题无关,问题是关于如何投射东西。您已经在其他情况下多次问过您的“崩溃”问题...您可能应该等待有人回答,而不是向各个评论部分发送垃圾邮件相同的问题...
    猜你喜欢
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多