{"id":13440014,"url":"https://github.com/retep998/winapi-rs","last_synced_at":"2025-04-27T05:30:28.212Z","repository":{"id":20573070,"uuid":"23853482","full_name":"retep998/winapi-rs","owner":"retep998","description":"Rust bindings to Windows API","archived":false,"fork":false,"pushed_at":"2024-04-27T20:28:44.000Z","size":25489,"stargazers_count":1874,"open_issues_count":276,"forks_count":392,"subscribers_count":37,"default_branch":"0.3","last_synced_at":"2025-04-25T22:42:30.233Z","etag":null,"topics":["ffi","rust","winapi","windows"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/winapi","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"datastax/cpp-driver","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/retep998.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"retep998"}},"created_at":"2014-09-09T23:18:24.000Z","updated_at":"2025-04-23T02:02:44.000Z","dependencies_parsed_at":"2022-07-14T04:00:43.807Z","dependency_job_id":"9f69e258-a5e9-41c1-8e5e-b83e8daea07c","html_url":"https://github.com/retep998/winapi-rs","commit_stats":{"total_commits":903,"total_committers":166,"mean_commits":"5.4397590361445785","dds":0.5249169435215947,"last_synced_commit":"5b1829956ef645f3c2f8236ba18bb198ca4c2468"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retep998%2Fwinapi-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retep998%2Fwinapi-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retep998%2Fwinapi-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retep998%2Fwinapi-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retep998","download_url":"https://codeload.github.com/retep998/winapi-rs/tar.gz/refs/heads/0.3","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250907663,"owners_count":21506068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffi","rust","winapi","windows"],"created_at":"2024-07-31T03:01:19.003Z","updated_at":"2025-04-27T05:30:28.154Z","avatar_url":"https://github.com/retep998.png","language":"Rust","funding_links":["https://patreon.com/retep998","https://www.patreon.com/retep998"],"categories":["Libraries","库 Libraries","Rust","库"],"sub_categories":["Platform specific","特定于平台的 Platform specific","平台特定","平台标准 Platform specific"],"readme":"# winapi-rs\n[![Build status](https://github.com/retep998/winapi-rs/workflows/Rust/badge.svg)](https://github.com/retep998/winapi-rs/actions)\n[![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/0.3?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/0.3)\n[![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=0.3)](https://travis-ci.org/retep998/winapi-rs)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs)\n[![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi)\n![Lines of Code](https://tokei.rs/b1/github/retep998/winapi-rs)\n![100% unsafe](https://img.shields.io/badge/unsafe-100%25-blue.svg)\n[![Open issues](https://img.shields.io/github/issues-raw/retep998/winapi-rs.svg)](https://github.com/retep998/winapi-rs/issues)\n[![License](https://img.shields.io/crates/l/winapi.svg)](https://github.com/retep998/winapi-rs)\n\n\n[Documentation](https://docs.rs/winapi/)\n\nOfficial communication channel: #windows-dev on the [Rust Community Discord](https://discord.gg/aVESxV8)\n\nThis crate provides raw FFI bindings to all of Windows API. They are gathered by hand using the Windows 10 SDK from Microsoft. I aim to replace all existing Windows FFI in other crates with this crate through the \"[Embrace, extend, and extinguish](https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguish)\" technique.\n\nIf this crate is missing something you need, feel free to create an issue, open a pull request, or contact me via [other means](https://www.rustaceans.org/retep998).\n\nThis crate depends on Rust 1.6 or newer on Windows. On other platforms this crate is a no-op and should compile with Rust 1.2 or newer.\n\n## Frequently asked questions ##\n\n### How do I create an instance of a union?\n\nUse `std::mem::zeroed()` to create an instance of the union, and then assign the value you want using one of the variant methods.\n\n### Why am I getting errors about unresolved imports?\n\nEach module is gated on a feature flag, so you must enable the appropriate feature to gain access to those items. For example, if you want to use something from `winapi::um::winuser` you must enable the `winuser` feature.\n\n### How do I know which module an item is defined in?\n\nYou can use the search functionality in the [documentation](https://docs.rs/winapi/) to find where items are defined.\n\n### Why is there no documentation on how to use anything?\n\nThis crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on [MSDN](https://docs.microsoft.com/en-us/windows/win32/desktop-app-technologies) which is full of detailed documentation.\n\n### Can I use this library in `no_std` projects?\n\nYes, absolutely! By default the `std` feature of `winapi` is disabled, allowing you to write Windows applications using nothing but `core` and `winapi`.\n\n### Why is `winapi`'s `HANDLE` incompatible with `std`'s `HANDLE`?\n\nBecause `winapi` does not depend on `std` by default, it has to define `c_void` itself instead of using `std::os::raw::c_void`. However, if you enable the `std` feature of `winapi` then it will re-export `c_void` from `std` and cause `winapi`'s `HANDLE` to be the same type as `std`'s `HANDLE`.\n\n### Should I still use those `-sys` crates such as `kernel32-sys`?\n\nNo. Those crates are a legacy of how `winapi` 0.2 was organized. Starting with `winapi` 0.3 all definitions are directly in `winapi` itself, and so there is no longer any need to use those `-sys` crates.\n\n## Example ##\n\nCargo.toml:\n```toml\n[target.'cfg(windows)'.dependencies]\nwinapi = { version = \"0.3\", features = [\"winuser\"] }\n```\nmain.rs:\n```Rust\n#[cfg(windows)] extern crate winapi;\nuse std::io::Error;\n\n#[cfg(windows)]\nfn print_message(msg: \u0026str) -\u003e Result\u003ci32, Error\u003e {\n    use std::ffi::OsStr;\n    use std::iter::once;\n    use std::os::windows::ffi::OsStrExt;\n    use std::ptr::null_mut;\n    use winapi::um::winuser::{MB_OK, MessageBoxW};\n    let wide: Vec\u003cu16\u003e = OsStr::new(msg).encode_wide().chain(once(0)).collect();\n    let ret = unsafe {\n        MessageBoxW(null_mut(), wide.as_ptr(), wide.as_ptr(), MB_OK)\n    };\n    if ret == 0 { Err(Error::last_os_error()) }\n    else { Ok(ret) }\n}\n#[cfg(not(windows))]\nfn print_message(msg: \u0026str) -\u003e Result\u003c(), Error\u003e {\n    println!(\"{}\", msg);\n    Ok(())\n}\nfn main() {\n    print_message(\"Hello, world!\").unwrap();\n}\n```\n\n## Financial Support\nDo you use `winapi` in your projects? If so, you may be interested in financially supporting me on [Patreon](https://www.patreon.com/retep998). Companies in particular are especially encouraged to donate (I'm looking at you [Microsoft](https://github.com/Azure/iotedge/tree/master/edgelet)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretep998%2Fwinapi-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretep998%2Fwinapi-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretep998%2Fwinapi-rs/lists"}