1

I have installed JNA and I'm trying to replicate what's provided in the second answer here that's suggesting to use NAudio: Mute Windows Volume using C#

I have read some JNA tutorials and it seems it can call external dll library functions, can I use JNA to achieve what's described in the solution of the link? I'm trying to do the exact same thing but except in Java using JNA instead of C#.

If it can be done, can anyone be so kind to provide some hints? I only know how to call functions using JNA.

ErwinS
  • 11
  • 1
  • You can't [directly use C# code via JNA](https://stackoverflow.com/questions/18474398/how-to-use-c-sharp-function-in-java-using-jna-lib). You could adapt the first answer there using WinAPI C functions. Or you can create a wrapper class that makes the C# functions accessible via C. – Daniel Widdis May 12 '20 at 21:44
  • Thank you @DanielWiddis, are you suggesting I should write a C program that wraps the C# function and then call that C function through JNA? – ErwinS May 13 '20 at 08:59
  • Also, I think it wouldn't be possible to adapt the first answer because the SendMessageW function returns and takes params of type IntPtr and I don't think IntPtr exists in Java. – ErwinS May 13 '20 at 09:03
  • IntPtr is in JNA as IntByReference. And yes, you would have to write a C wrapper to call C# code if you want to go that route. – Daniel Widdis May 14 '20 at 03:26
  • Ok thanks, I really appreciate your help @DanielWiddis – ErwinS May 14 '20 at 07:00

0 Answers0