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


Java Memory类代码示例

本文整理汇总了Java中com.sun.jna.Memory的典型用法代码示例。如果您正苦于以下问题:Java Memory类的具体用法?Java Memory怎么用?Java Memory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDiskSize

import com.sun.jna.Memory; //导入依赖的package包/类
private long getDiskSize(Disk disk) {
    long result = -1l;
    Kernel32 kernel32 = Kernel32.INSTANCE;
    HANDLE diskHandle = kernel32.CreateFile(disk.path, WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ, null,
            WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
    if (WinBase.INVALID_HANDLE_VALUE.equals(diskHandle)) {
        return result;
    }
    try {
        Memory output = new Memory(Native.getNativeSize(LARGE_INTEGER.class));
        IntByReference lpBytes = new IntByReference();
        boolean success = kernel32.DeviceIoControl(diskHandle,
                WinioctlUtil.CTL_CODE(Winioctl.FILE_DEVICE_DISK, 0x17, Winioctl.METHOD_BUFFERED,
                        Winioctl.FILE_READ_ACCESS),
                null, 0, output, Native.getNativeSize(LARGE_INTEGER.class), lpBytes, null);
        // TODO: Check success?
        result = output.getLong(0);
    }
    finally {
        Kernel32Util.closeHandle(diskHandle);
    }
    return result;
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:24,代码来源:DeviceManager.java

示例2: getIcon

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Gets the icon that corresponds to a given icon handler.
 * 
 * @param hIcon
 *            Handler to the icon to get
 * @return The icon that corresponds to a given icon handler
 */
public static BufferedImage getIcon(final HICON hIcon) {
	final int width = ICON_SIZE;
	final int height = ICON_SIZE;
	final short depth = ICON_DEPTH;
	final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

	final Memory lpBitsColor = new Memory(width * height * depth / ICON_BYTE_SIZE);
	final Memory lpBitsMask = new Memory(width * height * depth / ICON_BYTE_SIZE);
	final BITMAPINFO info = new BITMAPINFO();
	final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER();
	info.bmiHeader = hdr;
	hdr.biWidth = width;
	hdr.biHeight = height;
	hdr.biPlanes = 1;
	hdr.biBitCount = depth;
	hdr.biCompression = WinGDI.BI_RGB;

	final HDC hDC = User32.INSTANCE.GetDC(null);
	final ICONINFO piconinfo = new ICONINFO();
	User32.INSTANCE.GetIconInfo(hIcon, piconinfo);

	GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmColor, 0, height, lpBitsColor, info, WinGDI.DIB_RGB_COLORS);
	GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmMask, 0, height, lpBitsMask, info, WinGDI.DIB_RGB_COLORS);

	int r, g, b, a, argb;
	int x = 0, y = height - 1;
	for (int i = 0; i < lpBitsColor.size(); i = i + 3) {
		b = lpBitsColor.getByte(i) & 0xFF;
		g = lpBitsColor.getByte(i + 1) & 0xFF;
		r = lpBitsColor.getByte(i + 2) & 0xFF;
		a = 0xFF - lpBitsMask.getByte(i) & 0xFF;

		argb = a << 24 | r << 16 | g << 8 | b;
		image.setRGB(x, y, argb);
		x = (x + 1) % width;
		if (x == 0) {
			y--;
		}
	}

	User32.INSTANCE.ReleaseDC(null, hDC);
	GDI32.INSTANCE.DeleteObject(piconinfo.hbmColor);
	GDI32.INSTANCE.DeleteObject(piconinfo.hbmMask);

	return image;
}
 
开发者ID:ZabuzaW,项目名称:Mem-Eater-Bug,代码行数:54,代码来源:User32Util.java

示例3: finalizeClashesByEI

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * @param modelId
 * @param size
 * @return
 */
public Set<RenderEngineClash> finalizeClashesByEI(Pointer modelId, int size) {
	Set<RenderEngineClash> clashes = new HashSet<RenderEngineClash>();
	
	Memory pG1 = new Memory(size * 4 * getPlatformMultiplier());
	Memory pG2 = new Memory(size * 4 * getPlatformMultiplier());
	engine.finalizeClashesByEI(modelId, pG1, pG2);
	for (int i = 0; i < size; i++) {
		Long eid1 = null;
		Long eid2 = null;
		if (getPlatformMultiplier() == 1) {
			eid1 = (long)pG1.getInt(i * 4 * getPlatformMultiplier());
			eid2 = (long)pG2.getInt(i * 4 * getPlatformMultiplier());
		} else {
			eid1 = pG1.getLong(i * 4 * getPlatformMultiplier());
			eid2 = pG2.getLong(i * 4 * getPlatformMultiplier());
		}

		RenderEngineClash clash = new RenderEngineClash();
		clash.setEid1(eid1);
		clash.setEid2(eid2);
		clashes.add(clash);
	}
	return clashes;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:30,代码来源:IfcEngine.java

示例4: finalizeClashesByGuid

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * @param modelId
 * @param size
 * @return
 */
public Set<RenderEngineClash> finalizeClashesByGuid(Pointer modelId, int size) {
	Set<RenderEngineClash> clashes = new HashSet<RenderEngineClash>();
	Memory pG1 = new Memory(size * 4 * getPlatformMultiplier());
	Memory pG2 = new Memory(size * 4 * getPlatformMultiplier());
	engine.finalizeClashesByGuid(modelId, pG1, pG2);
	for (int i = 0; i < size; i++) {
		Pointer memory1 = pG1.getPointer(i * 4 * getPlatformMultiplier());
		String pG1Str = memory1.getString(0);
		Pointer memory2 = pG2.getPointer(i * 4 * getPlatformMultiplier());
		String pG2Str = memory2.getString(0);

		RenderEngineClash clash = new RenderEngineClash();
		clash.setGuid1(pG1Str);
		clash.setGuid2(pG2Str);
		clashes.add(clash);
	}
	return clashes;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:24,代码来源:IfcEngine.java

示例5: owlGetMappedItem

import com.sun.jna.Memory; //导入依赖的package包/类
public float[] owlGetMappedItem(Pointer model, Pointer instance, long owlInstance) {
	Memory memory = new Memory(16 * 4 * getPlatformMultiplier());
	LongByReference owlInstanceReference = new LongByReference();
	owlInstanceReference.setValue(owlInstance);
	engine.owlGetMappedItem(model, instance, owlInstanceReference, memory);
	if (getPlatformMultiplier() == 2) {
		double[] doubleArray = memory.getDoubleArray(0, 16);
		float[] floatArray = new float[16];
		for (int i=0; i<16; i++) {
			floatArray[i] = (float)doubleArray[i];
		}
		return floatArray;
	} else {
		return memory.getFloatArray(0, 16);
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:17,代码来源:IfcEngine.java

示例6: NSFSearchExtended3

import com.sun.jna.Memory; //导入依赖的package包/类
public native short NSFSearchExtended3 (int hDB, 
int hFormula, 
int hFilter, 
int FilterFlags, 
Memory ViewTitle, 
int SearchFlags, 
int SearchFlags1, 
int SearchFlags2, 
int SearchFlags3, 
int SearchFlags4, 
short NoteClassMask, 
NotesTimeDateStruct Since, 
NotesCallbacks.b32_NsfSearchProc EnumRoutine,
Pointer EnumRoutineParameter, 
NotesTimeDateStruct retUntil, 
int namelist);
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:17,代码来源:NotesNativeAPI32.java

示例7: NSFSearchExtended3

import com.sun.jna.Memory; //导入依赖的package包/类
public native short NSFSearchExtended3 (long hDB, 
long hFormula, 
long hFilter, 
int filterFlags, 
Memory ViewTitle, 
int SearchFlags, 
int SearchFlags1, 
int SearchFlags2, 
int SearchFlags3, 
int SearchFlags4, 
short NoteClassMask, 
NotesTimeDateStruct Since, 
NotesCallbacks.b64_NsfSearchProc EnumRoutine,
Pointer EnumRoutineParameter, 
NotesTimeDateStruct retUntil, 
long namelist);
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:17,代码来源:NotesNativeAPI64.java

示例8: get

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Retrieves a message from a message queue, provided the queue is not in a QUIT state.
 * The message will be stored in the buffer specified in the Buffer argument.<br>
 * Note: The error code {@link INotesErrorConstants#ERR_MQ_QUITTING} indicates that the
 * message queue is in the QUIT state, denoting that applications that are reading
 * the message queue should terminate. For instance, a server addin's message queue
 * will be placed in the QUIT state when a "tell &lt;addin&gt; quit" command is input at the console.

 * @param buffer buffer used to read data
 * @param waitForMessage if the specified message queue is empty, wait for a message to appear in the queue. The timeout argument specifies the amount of time to wait for a message.
 * @param timeoutMillis if waitForMessage is set to <code>true</code>, the number of milliseconds to wait for a message before timing out. Specify 0 to wait forever. If the message queue goes into a QUIT state before the Timeout expires, MQGet will return immediately.
 * @param offset the offset in the buffer where to start writing the message
 * @param length the max length of the message in the buffer
 * @return Number of bytes written to the buffer
 */
public int get(Memory buffer, boolean waitForMessage, int timeoutMillis, int offset, int length) {
	checkHandle();

	if (length > NotesConstants.MQ_MAX_MSGSIZE) {
		throw new IllegalArgumentException("Max size for the buffer is "+NotesConstants.MQ_MAX_MSGSIZE+" bytes. You specified one with "+length+" bytes.");
	}

	ShortByReference retMsgLength = new ShortByReference();

	short result = NotesNativeAPI.get().MQGet(m_queue, buffer, (short) (length & 0xffff),
			waitForMessage ? NotesConstants.MQ_WAIT_FOR_MSG : 0,
					timeoutMillis, retMsgLength);
	NotesErrorUtils.checkResult(result);
	return retMsgLength.getValue();
}
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:31,代码来源:MessageQueue.java

示例9: getAttributes

import com.sun.jna.Memory; //导入依赖的package包/类
@Override
protected FileAttributes getAttributes(@NotNull String path) throws Exception {
  Memory buffer = new Memory(256);
  int res = SystemInfo.isLinux ? myLibC.__lxstat64(STAT_VER, path, buffer) : myLibC.lstat(path, buffer);
  if (res != 0) return null;

  int mode = getModeFlags(buffer) & LibC.S_MASK;
  boolean isSymlink = (mode & LibC.S_IFMT) == LibC.S_IFLNK;
  if (isSymlink) {
    if (!loadFileStatus(path, buffer)) {
      return FileAttributes.BROKEN_SYMLINK;
    }
    mode = getModeFlags(buffer) & LibC.S_MASK;
  }

  boolean isDirectory = (mode & LibC.S_IFMT) == LibC.S_IFDIR;
  boolean isSpecial = !isDirectory && (mode & LibC.S_IFMT) != LibC.S_IFREG;
  long size = buffer.getLong(myOffsets[OFF_SIZE]);
  long mTime1 = SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME]) : buffer.getLong(myOffsets[OFF_TIME]);
  long mTime2 = myCoarseTs ? 0 : SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME] + 4) : buffer.getLong(myOffsets[OFF_TIME] + 8);
  long mTime = mTime1 * 1000 + mTime2 / 1000000;

  boolean writable = ownFile(buffer) ? (mode & LibC.WRITE_MASK) != 0 : myLibC.access(path, LibC.W_OK) == 0;

  return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FileSystemUtil.java

示例10: getOsDirectory

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * This function returns the path specification of the local Domino or Notes
 * executable / data / temp directory.<br>
 * <br>
 * Author: Ulrich Krause
 * 
 * @param osDirectory
 *            {@link OSDirectory}
 * @return path
 */
public static String getOsDirectory(OSDirectory osDirectory) {
	Memory retPathName = new Memory(NotesConstants.MAXPATH);
	switch (osDirectory) {
	case EXECUTABLE:
		NotesNativeAPI.get().OSGetExecutableDirectory(retPathName);
		break;
	case DATA:
		NotesNativeAPI.get().OSGetDataDirectory(retPathName);
		break;
	case TEMP:
		NotesNativeAPI.get().OSGetSystemTempDirectory(retPathName, NotesConstants.MAXPATH);
		break;
	case VIEWREBUILD:
		NotesNativeAPI.get().NIFGetViewRebuildDir(retPathName, NotesConstants.MAXPATH);
		break;
	case DAOS:
		NotesNativeAPI.get().DAOSGetBaseStoragePath(retPathName, NotesConstants.MAXPATH);
		break;			
	default:
		throw new IllegalArgumentException("Unsupported directory type: "+osDirectory);
	}
	NotesNativeAPI.get().OSPathAddTrailingPathSep(retPathName);
	return NotesStringUtils.fromLMBCS(retPathName, -1);
}
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:35,代码来源:PlatformUtils.java

示例11: getFlags

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Reads the note flags (e.g. {@link NotesConstants#NOTE_FLAG_READONLY})
 * 
 * @return flags
 */
private short getFlags() {
	checkHandle();
	
	Memory retFlags = new Memory(2);
	retFlags.clear();
	
	if (PlatformUtils.is64Bit()) {
		NotesNativeAPI64.get().NSFNoteGetInfo(m_hNote64, NotesConstants._NOTE_FLAGS, retFlags);
	}
	else {
		NotesNativeAPI32.get().NSFNoteGetInfo(m_hNote32, NotesConstants._NOTE_FLAGS, retFlags);
	}
	short flags = retFlags.getShort(0);
	return flags;
}
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:21,代码来源:NotesNote.java

示例12: errToString

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Converts a C API error code to an error message
 * 
 * @param err error code
 * @return error message
 */
public static String errToString(short err) {
	if (err==0)
		return "";

	Memory retBuffer = new Memory(256);
	short outStrLength = NotesNativeAPI.get().OSLoadString(0, err, retBuffer, (short) 255);
	if (outStrLength==0) {
		return "";
	}
	Memory newRetBuffer = new Memory(outStrLength);
	for (int i=0; i<outStrLength; i++) {
		newRetBuffer.setByte(i, retBuffer.getByte(i));
	}
	
	String message = NotesStringUtils.fromLMBCS(newRetBuffer, outStrLength);
	return message;
}
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:24,代码来源:NotesErrorUtils.java

示例13: NSFSearchExtended3

import com.sun.jna.Memory; //导入依赖的package包/类
public short NSFSearchExtended3 (long hDB, 
long hFormula, 
long hFilter, 
int filterFlags, 
Memory ViewTitle, 
int SearchFlags, 
int SearchFlags1, 
int SearchFlags2, 
int SearchFlags3, 
int SearchFlags4, 
short NoteClassMask, 
NotesTimeDateStruct Since, 
NotesCallbacks.b64_NsfSearchProc EnumRoutine,
Pointer EnumRoutineParameter, 
NotesTimeDateStruct retUntil, 
long namelist);
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:17,代码来源:INotesNativeAPI64.java

示例14: removeItem

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Method to remove an item from a note
 * 
 * @param itemName item name
 */
public void removeItem(String itemName) {
	checkHandle();
	
	Memory itemNameMem = NotesStringUtils.toLMBCS(itemName, false);
	
	short result;
	if (PlatformUtils.is64Bit()) {
		result = NotesNativeAPI64.get().NSFItemDelete(m_hNote64, itemNameMem, (short) (itemNameMem.size() & 0xffff));
	}
	else {
		result = NotesNativeAPI32.get().NSFItemDelete(m_hNote32, itemNameMem, (short) (itemNameMem.size() & 0xffff));
	}
	if (result==INotesErrorConstants.ERR_ITEM_NOT_FOUND) {
		return;
	}
	NotesErrorUtils.checkResult(result);
}
 
开发者ID:klehmann,项目名称:domino-jna,代码行数:23,代码来源:NotesNote.java

示例15: setArray

import com.sun.jna.Memory; //导入依赖的package包/类
/**
 * Stores the values from {@code array} allocating memory as needed.
 *
 * @param array the array of {@link E}s to write to the referenced memory.
 *            The array size must be the same as defined for this
 *            {@link FixedArrayByReference}.
 */
public void setArray(E[] array) {
	if (array == null) {
		throw new NullPointerException("array cannot be null");
	}
	if (array.length != size) {
		throw new IllegalArgumentException("array size must be " + size);
	}

	if (size < 1) {
		super.setPointer(Pointer.NULL);
		return;
	} else if (getPointer() == null) {
		// Allocate new memory
		super.setPointer(new Memory(getElementSize() * size));
	}

	setElements(array);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:26,代码来源:FixedArrayByReference.java


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