以下是rust代码
use std::mem;
use std::ptr;
use winapi::um::minwinbase::SECURITY_ATTRIBUTES;
use winapi::um::namedpipeapi::CreatePipe;
use winapi::um::winnt::PHANDLE;
use winapi::um::errhandlingapi::GetLastError;
use std::mem::size_of_val;
use winapi::shared::minwindef::LPVOID;
use winapi::um::libloaderapi::GetModuleHandleW;
fn main() {
unsafe {
let (inputReadSide, outputWriteSide) = (mem::zeroed::<PHANDLE>(), mem::zeroed::<PHANDLE>());
let (outputReadSide, inputWriteSide) = (mem::zeroed::<PHANDLE>(), mem::zeroed::<PHANDLE>());
let (mut one_security_attributes,_security_attributes) = (mem::zeroed::<SECURITY_ATTRIBUTES>(),mem::zeroed::<SECURITY_ATTRIBUTES>());
one_security_attributes.bInheritHandle = 0;
one_security_attributes.lpSecurityDescriptor = mem::zeroed::<LPVOID>();
one_security_attributes.nLength = size_of_val(&one_security_attributes) as u32;
let r = CreatePipe(inputReadSide, inputWriteSide, &mut one_security_attributes as *mut SECURITY_ATTRIBUTES, 0);
if r == 0 {
println!("{:?},{:?}", r,GetLastError());
}
}
}
以上示例会报一个段错误,请问我该如何才能正确的调用?
1
共 0 条评论, 1 页
评论区
写评论还没有评论