⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hellodllgeneric.java

📁 java 调用windows的api
💻 JAVA
字号:
/*
 * HelloDllGeneric.java -
 *
 * This file is part of the Jawin Project: http://jawinproject.sourceforge.net/
 * 
 * Please consult the LICENSE file in the project root directory,
 * or at the project site before using this software.
 */

/* $Id: HelloDllGeneric.java,v 1.1 2004/06/14 20:22:23 arosii_moa Exp $ */

package demos;

import org.jawin.COMException;
import org.jawin.FuncPtr;
import org.jawin.ReturnFlags;
import org.jawin.io.LittleEndianOutputStream;
import org.jawin.io.NakedByteStream;

/**
 * Demo that uses the Win32 MessageBoxW API-method with the generic FuncPtr invoke.
 *
 * @version     $Revision: 1.1 $
 * @author      Morten Andersen, arosii_moa (at) users.sourceforge.net
 */
public class HelloDllGeneric {

	public static void main(String[] args) throws Exception {
		FuncPtr msgBox = null;
		try {
			msgBox = new FuncPtr("USER32.DLL", "MessageBoxW");

			NakedByteStream nbs = new NakedByteStream();
			LittleEndianOutputStream leos = new LittleEndianOutputStream(nbs);
			leos.writeInt(0);
			leos.writeStringUnicode("Generic Hello From a DLL");
			leos.writeStringUnicode("From Jawin");
			leos.writeInt(0);
			msgBox.invoke("IGGI:I:", 16, nbs, null, ReturnFlags.CHECK_FALSE);
		} catch (COMException e) {
			// handle exception
			e.printStackTrace();
			throw e;
		} finally {
			if (msgBox != null) {
				try {
					msgBox.close();
				} catch (COMException e) {
					// handle fatal exception
					e.printStackTrace();
					throw e;
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -