Code Monkey home page Code Monkey logo

Comments (17)

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024 1

This is good. Thank you. I'll let you know how it goes

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024 1

Thank you very much.

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

What exactly are you asking? That function does exist: https://docs.rs/winapi/latest/winapi/um/propsys/struct.IPropertyStore.html#method.SetValue

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

What exactly are you asking? That function does exist: https://docs.rs/winapi/latest/winapi/um/propsys/struct.IPropertyStore.html#method.SetValue

@sollyucko Thank you for the quick response :) I'm asking how to make a shell extension that will register this function and allow me to call it. I think I have to make a dll and then register it. What I want to know is how to make that dll in Rust. Do I need to write a DllMain? Where do I go from there?

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

I will try to explain better. I want to create a shell extension, with just Rust, that will let me modify how Windows Explorer deals with reading details from a certain file type. But the issue is I don't know how to make something like that.

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

You can use crate-type=cdylib to generate a C-compatible DLL: https://doc.rust-lang.org/reference/linkage.html

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

Awesome :) now what functions do I add here to make it work with the shell? DllMain perhaps? And how do I implement the interface

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

Yeah, I guess so. I'm not very familiar with this, but I think these resources should help you get started:

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

@sollyucko How to implement IClassFactory? https://www.tecgraf.puc-rio.br/iup/examples/shell_extensions/ClassFactory.cpp They did it here. I have to implement https://docs.rs/winapi/latest/winapi/um/unknwnbase/struct.IClassFactory.html somehow

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

I'm not sure. Maybe use RIDL! somehow?

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

I'm gonna use https://raw.githubusercontent.com/GabrielMajeri/com-impl-rs for now. So I have to Rewrite-it-in-Rust for everything in that example you sent?

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

I've started to remake all of it. I'm not sure it'll work because the macro doesn't tell me whether I'm using the correct function signatures or not. I may miss a *mut or a * or a ** somewhere.

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

I will post my progress at https://github.com/duckfromdiscord/midi-windows-ext periodically.

for RegCreateKeyExW, if phkResult is an out, why does it ask me to initialize it?

error[E0381]: used binding `hKey` isn't initialized
  --> src\reg.rs:28:47
   |
20 |     let mut hKey: *mut HKEY;
   |         -------- binding declared here but left uninitialized
...
28 |          KEY_WRITE, &mut security_attributes, hKey, 0 as *mut u32).try_into().unwrap());
   |                                               ^^^^ `hKey` used here but it isn't initialized
   |
help: consider assigning a value
   |
20 |     let mut hKey: *mut HKEY = todo!();
   |    

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

So I have to Rewrite-it-in-Rust for everything in that example you sent?

Yeah, probably, unless you want to deal with C++ FFI.

I may miss a *mut or a * or a ** somewhere.

Just keep in mind that P or LP means *mut and PC or LPC means *const, and you should be fine, I think.

for RegCreateKeyExW, if phkResult is an out, why does it ask me to initialize it?

You're trying to directly read the value of an uninitialized variable. Assuming you're trying to have the handle end up directly in hKey, not in what in points to, do one of the following:

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

We don't have StringCchPrintf

from winapi-rs.

sollyucko avatar sollyucko commented on September 27, 2024

winapi does have w(v)sprintf(A/W); can you use that instead? The buffer has a fixed length of 1024 bytes though...

libc::snprintf is probably a much better option.

format!/write! is another option, but that has different format string syntax and output semantics.

I think the String... functions are only defined in strsafe.h, not in any built-in object files, but you could write a bit of C code to generate an object file with them, then write custom bindings to link it to your Rust code.

from winapi-rs.

duckfromdiscord avatar duckfromdiscord commented on September 27, 2024

Yeah, I guess so. I'm not very familiar with this, but I think these resources should help you get started:

* Well-commented example C++ source code: https://www.tecgraf.puc-rio.br/iup/examples/shell_extensions/ (start with dllmain.cpp)

* "Initializing Shell Extension Handlers": https://learn.microsoft.com/en-us/windows/win32/shell/int-shell-exts

Looks like somehow, between the last time I was looking at this code 3 weeks ago, and today, they privated all the code.

from winapi-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.