Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

calling a WIN 32 API function from System dlls using JDK 6.0  RSS feed

 
vp pan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to call a function sndPlaySound() from winmm.dll
WINMM.DLL is present in WINDOWS\SYSTEM32 folder
or tell me how to call

i want a solution which works with JDK 6.0 (please do not give a solution which works only in J++ or J#)

how can i do it ???
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this to learn why I just deleted the other copies of your question.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need JNI.

- You first create a Java class with one or more native methods.
- You will run javah on the class (using class name, not class file), and it will create a C/C++ header file
- You will then need to create a C/C++ implementation for that file, and compile it all into a DLL.

Check this out, and also check the links at the bottom.
 
vp pan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isnt there any way to DIRECTLY call the API from JAVA programming

( its possible in J++ and J#)]


in this case its not JAVA rather its C++ code which is calling the API
am i right ??

please tell me if i am wrong
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isnt there any way to DIRECTLY call the API from JAVA programming

No. You need JNI as the interface.

in this case its not JAVA rather its C++ code which is calling the API

I'm not sure what you mean by this. You want to make the call from Java, not from C++, right?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
No. You need JNI as the interface.

Well, using JNA (Google for it) you can do something similar, but there needs to be something of a translation. And of course JNA needs to be downloaded and installed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!