当前位置: 首页>>代码示例>>Java>>正文


Java Kernel32Util.formatMessageFromLastErrorCode方法代码示例

本文整理汇总了Java中com.sun.jna.platform.win32.Kernel32Util.formatMessageFromLastErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java Kernel32Util.formatMessageFromLastErrorCode方法的具体用法?Java Kernel32Util.formatMessageFromLastErrorCode怎么用?Java Kernel32Util.formatMessageFromLastErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jna.platform.win32.Kernel32Util的用法示例。


在下文中一共展示了Kernel32Util.formatMessageFromLastErrorCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeAsAdmin

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
public static void executeAsAdmin(String command, String args) {
	SHELLEXECUTEINFO execInfo = new SHELLEXECUTEINFO();
	execInfo.lpFile = new WString(command);
	if (args != null) {
		execInfo.lpParameters = new WString(args);
	}
	execInfo.nShow = Shell32X.SW_SHOWDEFAULT;
	execInfo.fMask = Shell32X.SEE_MASK_NOCLOSEPROCESS;
	execInfo.lpVerb = new WString("runas");
	boolean result = Shell32X.INSTANCE.ShellExecuteEx(execInfo);

	if (!result) {
		int lastError = Kernel32.INSTANCE.GetLastError();
		String errorMessage = Kernel32Util.formatMessageFromLastErrorCode(lastError);
		throw new RuntimeException("Error performing elevation: " + lastError + ": " + errorMessage + " (apperror=" + execInfo.hInstApp + ")");
	}
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-Client,代码行数:18,代码来源:Elevator.java

示例2: freeSpace

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
public static long freeSpace(File file)
{
	if (!file.isDirectory() || !file.exists())
		return -2;

	WinNT.LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new WinNT.LARGE_INTEGER.ByReference();
	lpTotalNumberOfFreeBytes.clear();

	boolean ret = Kernel32.INSTANCE.GetDiskFreeSpaceEx(file.getPath(),
			null, null, lpTotalNumberOfFreeBytes);
	if (ret)
		return lpTotalNumberOfFreeBytes.getValue();
	else
	{
		String s = Kernel32Util
				.formatMessageFromLastErrorCode(Kernel32.INSTANCE
						.GetLastError());
		log.severe("error in File.freeSpace getting for \""
				+ file.getPath() + "\" " + s);
	}

	return -1;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:24,代码来源:FileUtils.java

示例3: totalSpace

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
public static long totalSpace(File file)
{
	if (!file.isDirectory() || !file.exists())
		return -2;

	WinNT.LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new WinNT.LARGE_INTEGER.ByReference();
	lpTotalNumberOfBytes.clear();

	boolean ret = Kernel32.INSTANCE.GetDiskFreeSpaceEx(file.getPath(),
			null, lpTotalNumberOfBytes, null);
	if (ret)
		return lpTotalNumberOfBytes.getValue();
	else
	{
		String s = Kernel32Util
				.formatMessageFromLastErrorCode(Kernel32.INSTANCE
						.GetLastError());
		log.severe("error in File.totalSpace getting for \""
				+ file.getPath() + "\" " + s);
	}

	return -1;

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:25,代码来源:FileUtils.java

示例4: msync

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
public static void msync(RandomAccessFile raf, long addr, long length)
        throws IOException {
    int retry = 0;
    boolean success;
    int lastError = 0;
    // FlushViewOfFile can fail with ERROR_LOCK_VIOLATION if the memory system is writing dirty
    // pages to disk. As there is no way to synchronize the flushing then we retry a limited
    // number of times.
    do {
        success = KERNEL_32.FlushViewOfFile(new Pointer(addr), new SIZE_T(length));
        if (success || (lastError = KERNEL_32.GetLastError()) != ERROR_LOCK_VIOLATION)
            break;
        retry++;
    } while (retry < 3);

    if (success) {
        // Finally calls FlushFileBuffers
        raf.getChannel().force(false);
    } else {
        throw new IOException(Kernel32Util.formatMessageFromLastErrorCode(lastError));
    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:23,代码来源:WindowsMsync.java

示例5: Win32Process

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
/**
 * creates a new Win32 Process given a process id
 * @param pid the process id that describes this process
 * @throws IOException if something goes wrong with creating the process reference
 */
public Win32Process(int pid) throws IOException
{
    handle = Kernel32.INSTANCE.OpenProcess(
            0x0400 | /* PROCESS_QUERY_INFORMATION */
            0x0800 | /* PROCESS_SUSPEND_RESUME */
            0x0001 | /* PROCESS_TERMINATE */
            0x00100000 /* SYNCHRONIZE */,
            false,
            pid);
    if (handle == null) 
        throw new IOException("OpenProcess failed: " 
    + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()));
    this.pid = pid;
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:20,代码来源:Win32Process.java

示例6: WinProcess

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
public WinProcess(int pid_) throws IOException {
	this();
	this.handle = Kernel32.INSTANCE.OpenProcess(0x0400 | // PROCESS_QUERY_INFORMATION
			0x0800 | // PROCESS_SUSPEND_RESUME
			0x0001 | // PROCESS_TERMINATE
			0x0200 | // PROCESS_SET_INFORMATION
			0x00100000, // SYNCHRONIZE
			false, pid_);
	if (this.handle == null) {
		throw new IOException("OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE.GetLastError()) + " (pid: " + pid_ + ")");
	}
	this.pid = pid_;
}
 
开发者ID:laurent-clouet,项目名称:sheepit-client,代码行数:14,代码来源:WinProcess.java

示例7: win32ErrorIOException

import com.sun.jna.platform.win32.Kernel32Util; //导入方法依赖的package包/类
/**
 * returns an IOException exception  with a Java-style error report from native implementation.
 * 
 * @param functionName The name of the native function the call has failed.
 */
private static IOException win32ErrorIOException(final String functionName) {
    final int err = Kernel32.INSTANCE.GetLastError();
    final String mess = Kernel32Util.formatMessageFromLastErrorCode(err);
    return new IOException(functionName + " error=" + err + ", " + mess);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:11,代码来源:WindowsProcess.java


注:本文中的com.sun.jna.platform.win32.Kernel32Util.formatMessageFromLastErrorCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。