打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Calling the Win32 API from Java | J/Invoke

Calling the Win32 API from Java

To make calling the Win32 API easier, the com.jinvoke.win32 package provides helper classes that contain J/Invoke declaration offunctions for the most commonly used Win32 DLLs. You just need to importthe class you need and directly call the stubbed out Java methodcorresponding to the Win32 API you want to call.

The available APIs are declared in a set of classes, one for each Windows DLL, as shown in the following table.

J/Invoke Win32 Helper Class

DLL Name

Functionality

com.jinvoke.win32.Kernel32

KERNEL32.DLL

Base services

com.jinvoke.win32.Gdi32

GDI32.DLL

Graphics device interface

com.jinvoke.win32.User32

USER32.DLL

User interface

com.jinvoke.win32.Advapi32

ADVAPI32.DLL

Crypto API, event logging

com.jinvoke.win32.Shell32

SHELL32.DLL

Windows shell API

com.jinvoke.win32.Winmm

WINMM.DLL

Multimedia

com.jinvoke.win32.WinInet

WININET.DLL

Internet

The Win32 API uses many constants and structures which are defined in com.jinvoke.win32.WinConstants class and the com.jinvoke.win32.structs package respectively.

For instance, MessageBox is contained in USER32 .DLL and therefore declared in the User32 class. Import this class and you can call MessageBox directly. Thus, the previous example could be simplified as shown below:

import com.jinvoke.win32.User32;
import
 static com.jinvoke.win32.WinConstants.*;

public class CallingWin32API {
    public static void main(String[] args) {
        User32.MessageBox(0, "This MessageBox is a native Win32 MessageBox", "Caption", MB_ICONINFORMATION|MB_OK);
    }
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
学 Win32 汇编[2]: 最简单的 Win32 程序
Calling a DLL C++ function or class from a VC++ application
暴强贴:从.NET平台调用Win32 API - 水之真谛
用 NASM 编写代码
在C#程序设计中使用Win32类库
python在桌面输出弹框提示
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服