Using Jawin to complete a call to a DLL in the call window

Source: Internet
Author: User

Recently due to the special requirements of the project, we must call the Windows DLL in the program. We started with JNI, and later because there were too many DLLs to call, and very cumbersome. So we decided to use the open source Jawin call. Jawin can invoke a method in a DLL, or invoke a method in COM. Internally also provides a tool for directly exporting COM components to Java classes, which is personally considered convenient. Here is a test we made and passed it smoothly. 1, download jawin:http://jawinproject.sourceforge.net/.     2, configuration: "Will Jawin.jar placed in the%java_home%/jre/lib/ext." "Put the Jawin.dll under the C:/winnt/system32. Otherwise, an error occurs: Comexception:no Jawin in Java.library.path, or Jawin.dll in each project directory.

The example of debugging Jawin/njawin in EditPlus can be passed.    And in eclipse, there are times when the above error occurs: Comexception:no Jawin in Java.library.path.     "In Eclipse, the menu->window->preference->java->installed jres the original remove and builds a point to your Java SDK directory.  "OK." 3, the program test:

"The way to call Dll,dll does not need to be exported, direct call on it, the following is a download of the package provides an example:" I Win2000 under the test pass. * * Created on DEC, * */import ORG.JAWIN.FUNCPTR;

Import Org.jawin.ReturnFlags;

/** * @author GF Mail to gf@163.com * "TODO to" the template for this generated type comment go to * Window- Preferences-java-code Style-code Templates */public class Gfjawintest {

public static void Main (string[] args) {

try {

Funcptr MsgBox = new Funcptr ("USER32. DLL "," MessageBoxW ");

Msgbox.invoke_i (0, "Hello from-a DLL", "from Jawin", 0, Returnflags.check_none);

catch (Exception e) {

E.printstacktrace ();

}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.