Writing [custom actions] for [Windows Installer] can be difficult enough already, but using Rust can help mitigate some potential issues concerning memory and handle leaks.
These APIs roughly mimic the Windows Installer [automation interface] for those APIs that can be called in immediate and deferred custom actions.
You can define custom actions in Rust using its foreign function interface like:
```rust use msica::*;
const ERRORSUCCESS: u32 = 0; const ERRORINSTALL_FAILURE: u32 = 1603;
pub extern "C" fn MyCustomAction(session: Session) -> u32 { match Record::withfields( Some("this is [1] [2]"), vec![ Field::IntegerData(1), Field::StringData("example".toowned()), ], ) { Ok(record) => { session.message(MessageType::User, &record); ERRORSUCCESS } _ => ERRORINSTALL_FAILURE, } } ```
If you enable the nightly
feature, you can use the question mark operator (?
) to propagate errors:
```rust use msica::*;
pub extern "C" fn MyCustomAction(session: Session) -> CustomActionResult { let record = Record::withfields( Some("this is [1] [2]"), vec![Field::IntegerData(1), Field::StringData("example".toowned())], )?; session.message(MessageType::User, &record); CustomActionResult::Succeed } ```
This project is licensed under the MIT license.