百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

winsafe

> 编程语言
开源

在安全、规范的 Rust 中使用 Windows API 和 GUI。

670 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在安全、规范的 Rust 中使用 Windows API 和 GUI。

WinSafe

Windows API and GUI in safe, idiomatic Rust.

Handwritten since 2019.

WinSafe has:

  • low-level Win32 API constants, functions and structs;
  • high-level structs to build native Win32 GUI applications.

WinSafe documentation:

Branch Docs
Stable docs.rs/winsafe
Nightly (master) rodrigocfd.github.io/winsafe/winsafe

Current status

Native FFI items implemented

Native FFI item Count
Functions 914
Structs 264
Constants 12,307
Window messages 684
Handles 54
COM interfaces 99
COM methods 645

Although WinSafe already has a lot of Win32 APIs, it doesn't have everything, simply because Win32 API is gigantic. So if you're looking for a comprehensive Win32 coverage, take a look at winapi or windows crates, which are unsafe, but have everything.

High-level GUI controls implemented

  • User custom window/dialog – main, modal, modeless, control, message-only.
  • Native controls – button, check box, combo box, date and time picker, edit, header, label, list box, list view, month calendar, progress bar, radio button, status bar, tab, track bar, tree view, up down.

Usage

Add the dependency in your Cargo.toml:

[dependencies]
winsafe = { version = "0.0.29", features = [] }

Then you must enable the Cargo features you want to be included – these modules are named after native Windows DLL and library names, mostly.

Cargo features

The APIs in WinSafe are split into Cargo features to speed up compilation time. Only the features you include will be compiled.

The following Cargo features are available so far:

Feature Description
advapi Advapi32.dll and Ktmw32.dll, advanced kernel functions
comctl ComCtl32.dll, the Common Controls
dshow DirectShow
dwm Desktop Window Manager
dxgi DirectX Graphics Infrastructure
gdi Gdi32.dll, the Windows GDI
gui The WinSafe high-level GUI abstractions
htmlhelp HTML Help
kernel Kernel32.dll, basic kernel functions
mf Media Foundation
ole Basic OLE/COM support
oleaut OLE Automation
psapi Process Status API
raw-dylib Enables raw-dylib linking
shell Shell32.dll, Shlwapi.dll, and Userenv.dll, the COM-based Windows Shell
taskschd Task Scheduler
user User32.dll and ComDlg32.dll, the basic Windows GUI support
uxtheme UxTheme.dll, extended window theming
version Version.dll, to manipulate *.exe version info
winmm Windows Multimedia
wininet Windows Internet
winspool Print Spooler API

Don't worry about including dependency features. Once you use a feature, Cargo will add and resolve all dependencies automatically.

You can visualize the complete dependency graph here.

Example

Note: You can find several examples in the dedicated repo: github.com/rodrigocfd/winsafe-examples

WinSafe allows you to create windows in two ways:

  • programmatically defining parameters; or
  • loading dialogs from a .res file created with a WYSIWYG resource editor.

The example below creates a window with a button programmatically. Note how the click event is handled with a closure:

[dependencies]
winsafe = { version = "0.0.29", features = ["gui"] }
…

License

Licensed under MIT license, see LICENSE.md for details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustbindingsffiguinative

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言