https://125.confly.eu.org/thread-14787937-1-1.html
#[no_mangle]
pub extern "stdcall" fn rustforin() {
let mut sum = String::new();
for i in 1..=99 {
for j in 1..=99 {
for k in 1..99 {
if i == j || i == k || j == k {
} else {
sum += &format!("{:02} {:02} {:02}\r\n", i, j, k);
}
}
}
}
let mut file = std::fs::File::create("三位数.txt").expect("创建失败");
file.write_all(sum.as_bytes()).expect("创建失败");
}
https://125.confly.eu.org/forum.php?mod=viewthread&tid=14787065
cargo new testdll --lib
[lib]
name = "TestDLL"
crate-type = ["cdylib"]
use std::io::Write;
#[no_mangle]
pub extern "stdcall" fn rustforin() {
let mut sum = String::new();
let mut a;
let mut b;
let mut c;
for i in 1..=99 {
for j in 1..=99 {
for k in 1..99 {
if i == j || i == k || j == k {
} else {
if i < 10 {
a = String::from("0") + &i.to_string();
} else {
a = i.to_string();
}
if j < 10 {
b = String::from("0") + &j.to_string();
} else {
b = j.to_string();
}
if k < 10 {
c = String::from("0") + &k.to_string();
} else {
c = k.to_string();
}
sum = sum + &a + &String::from(" ") + &b + &String::from(" ") + &c + "\r\n";
}
}
}
}
let mut file = std::fs::File::create("三位数.txt").expect("创建失败");
file.write_all(sum.as_bytes()).expect("创建失败");
}
pub extern "stdcall"
cargo build --release --target i686-pc-windows-msvc
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
linker = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86\link.exe"
DLL命令名 | 返回值类型 | 公开 | 备 注 | |
rustforin | ||||
DLL库文件名: | ||||
TestDLL.dll | ||||
在DLL库中对应命令名: | ||||
rustforin | ||||
参数名 | 类 型 | 传址 | 数组 | 备 注 |
子程序名 | 返回值类型 | 公开 | 备 注 | ||
_按钮2_被单击 |
变量名 | 类 型 | 静态 | 数组 | 备 注 | ||
时间 | 整数型 |
i支持库列表 | 支持库注释 |
spec | 特殊功能支持库 |
3.76 KB, 下载次数: 1, 下载积分: 精币 -2 枚
快速文本对象
00.png (148.23 KB, 下载次数: 0)
菜鸟菜鸡秋水 发表于 2023-8-19 19:58
想用rust 和易语言交互的兄弟们 , 这是一个编码库 ,省的大家找 , 本人没有测试 , 是大公司搞的 https://gi ...
fn getpid_from_name(pname: &str, wordscase: bool, call_back_arry: &mut Vec<u32>) -> i32 {
let handle: HANDLE;
let mut pe32 = &mut PROCESSENTRY32W {
dwSize: 0,
cntUsage: 0,
th32ProcessID: 0,
th32DefaultHeapID: 0,
th32ModuleID: 0,
cntThreads: 0,
th32ParentProcessID: 0,
pcPriClassBase: 0,
dwFlags: 0,
szExeFile: [0; 260],
};
unsafe {
handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0).unwrap();
}
pe32.dwSize = size_of::<PROCESSENTRY32W>() as u32;
unsafe {
if Process32FirstW(handle, pe32) == false {
CloseHandle(handle);
println!("获取进程快照句柄失败");
return -1;
}
while Process32NextW(handle, pe32) != false {
//println!("进程名为{:?}",pe32.szExeFile);
let text_wide = String::from_utf16(&pe32.szExeFile).unwrap();
let process_name = text_wide.trim_end_matches("\0");
//println!("进程名为{:?}",process_name);
if wordscase != true {
let cpname = pname.to_lowercase();
if cpname == process_name.to_lowercase() {
call_back_arry.push(pe32.th32ProcessID as u32);
}
} else {
let cpname = pname.to_string();
if cpname == process_name.to_string() {
call_back_arry.push(pe32.th32ProcessID as u32);
}
}
}
if CloseHandle(handle) == true {
println!("关闭成功");
}
if call_back_arry.get(0) == None {
return 0;
} else {
return call_back_arry[0] as i32;
}
}
}
美稀宗 发表于 2023-8-19 23:53
这个库在rust上可以显示汉字a码,u码rust可以直接使用
比如,进程名取pid
[mw_shl_code=cpp,true]fn getp ...
菜鸟菜鸡秋水 发表于 2023-8-21 17:07
厉害 , 我都没试过 ,我只是看到了, 这rust 很复杂 ,挺难学 ,
有没有和易语言交互的 dll 案例啊 ? ...
美稀宗 发表于 2023-8-21 21:47
正在写读写内存
欢迎光临 精易论坛 (https://125.confly.eu.org/) | Powered by Discuz! X3.4 |