直接上源代码:lib.rs
/// PowerBuilder 9 callable DLL example
/// Build with: cargo b --release --target i686-pc-windows-msvc
/// PB declare: public function ulong copy_str(string source,ref string destination) library "hello.dll" alias for "copy_str"
use std::{ffi::CStr, os::raw::c_char, ptr::copy_nonoverlapping};
#[no_mangle]
pub unsafe extern "system" fn copy_str(src: *const c_char, dst: *mut c_char) -> u32 {
let len = CStr::from_ptr(src).to_bytes().len();
copy_nonoverlapping(src, dst, len + 1);
len as u32
}
配置文件cargo.toml
[package]
name = "hello"
version = "0.1.0"
[lib]
crate-type = ["dylib"]
PowerBuilder调用声明:
public function ulong copy_str(string source,ref string destination) library "hello.dll" alias for "copy_str"
1
共 2 条评论, 1 页
评论区
写评论PB9是32位的,ULong=u32
ulong, 最少不得是u64?