Hello, I’m not exactly sure what your code should achieve and what desired output is, but I can help your from Julia side.
The code you provided isn’t self contained so I modified it a bit:
const HANDLE = Ptr{Cvoid}
const LPSTR = Vector{UInt8}
function RegisterWindowMessage(message::String)
msg = Vector{UInt8}(message)
return ccall((:RegisterWindowMessageA, "user32"), stdcall, Cint, (Ptr{Vector{UInt8}},), Ref(msg) )
end
function SendWindowMessage(handle::HANDLE, msg::Cint)
buffer = LPSTR(undef, 512)
retval = ccall((:SendMessageA, "user32"), stdcall, Cint, (HANDLE, Cint, Cint, Ptr{UInt8}), handle, msg, sizeof(buffer), buffer)
if retval == 0
return "NA"
else
buffer[end] = 0
return String(unsafe_string(pointer(buffer),retval))
end
end
function main()
hwnd = Ptr{Int32}(Int64(0xffff))
msg = RegisterWindowMessage("WM_GETCONTROLNAME")
@show msg
SendWindowMessage(HANDLE(hwnd), msg)
end
This is the output I get:
julia> main()
msg = 49822
"\0"
I can give you working example with SendMessageA, but I haven’t used RegisterWindowMessageA before, so I don’t know about that.