【发布时间】:2020-12-31 23:36:33
【问题描述】:
我正在尝试使用 ccall 与 Windows 函数交互(具体为 FindWindowA),但我遇到了一个奇怪的行为
julia> ccall((:FindWindowA, :user32), Int32, (Ptr{Cvoid},), C_NULL)
855386
julia> foo() = ccall((:FindWindowA, :user32), Int32, (Ptr{Cvoid},), C_NULL)
foo (generic function with 1 method)
julia> foo()
0
julia> @ccall :user32.FindWindowA(C_NULL::Ptr{Cvoid})::Int32
65920
julia> foo() = @ccall :user32.FindWindowA(C_NULL::Ptr{Cvoid})::Int32
foo (generic function with 1 method)
julia> foo()
0
有没有办法从 ccall 获得一致的结果?
【问题讨论】: