How can I make use of this two functions on Windows API?
Well, I tried to get hold of a list of a list of removable drives by using the two functions on Windows API as above, but was confused as

pub unsafe extern "system" fn GetDriveTypeW(lpRootPathName: LPCWSTR])->UINT//requires a *const u16 

and the other requires a *const i8. I simply do not know how to creat a *const u16 or *const i8 in Rust. What parameter shall I provide?
Thank you for any thoughts.

You can get pointer from *const u8 and convert it easily to i8

The problem is that for W version of function you need to re-encode your text from UTF-8 to shitty WTF-16.
Use this function and collect it into vec. Then use Vec::as_ptr to get pointer and cast it to i16

In case of A version encoding depends on your system code page.
You should set it to UTF-8 for simplicty sake, but in general you should prefer to use W version of function as it is independent of environment, albeit sub-par performance wise due to a need for conversion.

Many thanks for your fast reply! I am trying it out.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.