本文整理汇总了Java中com.sun.jna.Pointer类的典型用法代码示例。如果您正苦于以下问题:Java Pointer类的具体用法?Java Pointer怎么用?Java Pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pointer类属于com.sun.jna包,在下文中一共展示了Pointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.sun.jna.Pointer; //导入依赖的package包/类
@Override
public void init() {
super.init();
WindowManager.createWindow(handle, window, true);
long hwndGLFW = glfwGetWin32Window(window.getID());
HWND hwnd = new HWND(Pointer.createConstant(hwndGLFW));
WindowProc proc = new WindowProc() {
@Override
public long invoke(long hw, int uMsg, long wParam, long lParam) {
if (hw == hwndGLFW)
switch (uMsg) {
case WM_WINDOWPOSCHANGING:
WINDOWPOS pos = new WINDOWPOS(new Pointer(lParam));
pos.flags |= SWP_NOZORDER | SWP_NOACTIVATE;
pos.write();
break;
}
return org.lwjgl.system.windows.User32.DefWindowProc(hw, uMsg, wParam, lParam);
}
};
User32.INSTANCE.SetWindowLongPtr(hwnd, GWL_WNDPROC, Pointer.createConstant(proc.address()));
User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
User32.INSTANCE.SetWindowPos(hwnd, new HWND(Pointer.createConstant(HWND_BOTTOM)), 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
wallpaper = window.getResourceLoader().loadNVGTexture(getCurrentDesktopWallpaper(), true);
TaskManager.addTask(() -> window.setVisible(true));
}
示例2: loadFromInputStream
import com.sun.jna.Pointer; //导入依赖的package包/类
public Pointer loadFromInputStream(final InputStream in, String schemaName) {
final byte[] buffer = new byte[1024];
IfcEngineInterface.StreamCallback fn = new IfcEngineInterface.StreamCallback() {
public int invoke(Pointer pointer) {
try {
int read = in.read(buffer, 0, 1024);
if (read == -1) {
return -1;
}
ByteBuffer byteBuffer = pointer.getByteBuffer(0, read);
byteBuffer.put(buffer, 0, read);
return read;
} catch (IOException e) {
}
return -1;
}
};
callBacks.add(fn);
return engine.xxxxOpenModelByStream(0, fn, schemaName);
}
示例3: InstanceDerivedTransformationMatrix
import com.sun.jna.Pointer; //导入依赖的package包/类
public InstanceDerivedTransformationMatrix(Pointer model, Pointer instance, double _11, double _12, double _13, double _14, double _21, double _22, double _23, double _24,
double _31, double _32, double _33, double _34, double _41, double _42, double _43, double _44) {
this.model = model;
this.instance = instance;
this._11 = _11;
this._12 = _12;
this._13 = _13;
this._14 = _14;
this._21 = _21;
this._22 = _22;
this._23 = _23;
this._24 = _24;
this._31 = _31;
this._32 = _32;
this._33 = _33;
this._34 = _34;
this._41 = _41;
this._42 = _42;
this._43 = _43;
this._44 = _44;
}
示例4: read
import com.sun.jna.Pointer; //导入依赖的package包/类
public char[] read(String key) {
try {
byte[] serviceName = key.getBytes("UTF-8");
byte[] accountName = "NetBeans".getBytes("UTF-8");
int[] dataLength = new int[1];
Pointer[] data = new Pointer[1];
error("find", SecurityLibrary.LIBRARY.SecKeychainFindGenericPassword(null, serviceName.length, serviceName,
accountName.length, accountName, dataLength, data, null));
if (data[0] == null) {
return null;
}
byte[] value = data[0].getByteArray(0, dataLength[0]); // XXX ought to call SecKeychainItemFreeContent
return new String(value, "UTF-8").toCharArray();
} catch (UnsupportedEncodingException x) {
LOG.log(Level.WARNING, null, x);
return null;
}
}
示例5: owlGetMappedItem
import com.sun.jna.Pointer; //导入依赖的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);
}
}
示例6: main
import com.sun.jna.Pointer; //导入依赖的package包/类
public static void main(String[] args) {
final User32 user32 = User32.INSTANCE;
user32.EnumWindows(new User32.WNDENUMPROC() {
int count;
public boolean callback(Pointer hWnd, Pointer userData) {
byte[] windowText = new byte[512];
user32.GetWindowTextA(hWnd, windowText, 512);
String wText = Native.toString(windowText);
wText = (wText.isEmpty()) ? "" : "; text: " + wText;
System.out.println("Found window " + hWnd + ", total " + ++count + wText);
return true;
}
}, null);
}
示例7: findDefaultMode
import com.sun.jna.Pointer; //导入依赖的package包/类
private Pointer findDefaultMode(final Pointer runLoop) {
final Pointer modes = cf.CFRunLoopCopyAllModes(runLoop);
if (modes != Pointer.NULL) {
final int modesCount = cf.CFArrayGetCount(modes).intValue();
for (int i=0; i< modesCount; i++) {
final Pointer mode = cf.CFArrayGetValueAtIndex(modes, new NativeLong(i));
if (mode != Pointer.NULL && DEFAULT_RUN_LOOP_MODE.equals(cf.CFStringGetCStringPtr(mode, ENC_MAC_ROMAN))) {
return mode;
}
}
}
return null;
}
示例8: init
import com.sun.jna.Pointer; //导入依赖的package包/类
/**
* It's a heavy init method.
*/
public void init() {
for (int i = 0; i < poolSize; i++) {
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(fileSize);
final long address = ((DirectBuffer) byteBuffer).address();
Pointer pointer = new Pointer(address);
LibC.INSTANCE.mlock(pointer, new NativeLong(fileSize));
availableBuffers.offer(byteBuffer);
}
}
示例9: main
import com.sun.jna.Pointer; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
Pointer pointer;
System.out.println("running in " + System.getProperty("sun.arch.data.model"));
System.out.println("Loading dll");
autoHotKeyDll lib = (autoHotKeyDll) Native.loadLibrary("AutoHotkey.dll", autoHotKeyDll.class);
System.out.println("initialisation");
lib.ahktextdll(new WString(""), new WString(""), new WString(""));
// Thread.sleep(100);
// lib.addFile(new WString(System.getProperty("user.dir") + "\\lib.ahk"), 1);
// Thread.sleep(1000);
// System.out.println("function call");
// System.out.println("return:" + lib.ahkFunction(new WString("function"),new WString(""),new WString(""),new
// WString(""),new WString(""),new WString(""),new WString(""),new WString(""),new WString(""),new
// WString(""),new WString("")).getString(0));
Thread.sleep(1000);
System.out.println("displaying cbBox");
lib.ahkExec(new WString("Send {Right}"));
Thread.sleep(1000);
}
示例10: AVBitStreamFilter
import com.sun.jna.Pointer; //导入依赖的package包/类
/**
* @param name C type : const char*<br>
* @param codec_ids C type : AVCodecID*<br>
* @param priv_class C type : const AVClass*<br>
* @param init C type : init_callback*<br>
* @param filter C type : filter_callback*<br>
* @param close C type : close_callback*
*/
public AVBitStreamFilter(Pointer name, IntByReference codec_ids, Pointer priv_class, int priv_data_size, org.ffmpeg.avfilter6.AVFilter.init_callback init, filter_callback filter, close_callback close) {
super();
this.name = name;
this.codec_ids = codec_ids;
this.priv_class = priv_class;
this.priv_data_size = priv_data_size;
this.init = init;
this.filter = filter;
this.close = close;
}
示例11: invoke
import com.sun.jna.Pointer; //导入依赖的package包/类
@Override
public void invoke(Pointer streamRef, Pointer clientCallBackInfo, NativeLong numEvents, Pointer eventPaths, Pointer eventFlags, Pointer eventIds) {
final long st = System.currentTimeMillis();
final int length = numEvents.intValue();
final Pointer[] pointers = eventPaths.getPointerArray(0, length);
int flags[];
if (eventFlags == null) {
flags = new int[length];
LOG.log(DEBUG_LOG_LEVEL, "FSEventStreamCallback eventFlags == null, expected int[] of size {0}", length); //NOI18N
} else {
flags = eventFlags.getIntArray(0, length);
}
for (int i=0; i<length; i++) {
final Pointer p = pointers[i];
int flag = flags[i];
final String path = p.getString(0);
if ((flag & kFSEventStreamEventFlagMustScanSubDirs) == kFSEventStreamEventFlagMustScanSubDirs ||
(flag & kFSEventStreamEventFlagMount) == kFSEventStreamEventFlagMount ||
(flag & kFSEventStreamEventFlagUnmount) == kFSEventStreamEventFlagUnmount) {
events.add(ALL_CHANGE);
} else {
events.add(path);
}
LOG.log(DEBUG_LOG_LEVEL, "Event on {0}", new Object[]{path});
}
LOG.log(PERF_LOG_LEVEL, "Callback time: {0}", (System.currentTimeMillis() - st));
}
示例12: setPointer
import com.sun.jna.Pointer; //导入依赖的package包/类
@Override
public void setPointer(Pointer p) {
if (immutable) {
throw new UnsupportedOperationException("immutable reference");
}
super.setPointer(p);
}
示例13: getValue
import com.sun.jna.Pointer; //导入依赖的package包/类
public HANDLE getValue() {
Pointer p = getPointer().getPointer(0);
if (p == null)
return null;
if (INVALID_HANDLE_VALUE.getPointer().equals(p))
return INVALID_HANDLE_VALUE;
HANDLE h = new HANDLE();
h.setPointer(p);
return h;
}
示例14: apply
import com.sun.jna.Pointer; //导入依赖的package包/类
@Override
public int apply(Pointer opaque, Pointer buf, int buf_size) {
try {
byte[] tempbuf = new byte[buf_size];
int readLen = stream.read(tempbuf, 0, buf_size);
if (readLen == -1) return AVERROR_EOF;
buf.write(0, tempbuf, 0, readLen);
return readLen;
} catch (Exception ex) {
return -1;
}
}
示例15: getStringFromCFStringRef
import com.sun.jna.Pointer; //导入依赖的package包/类
/**
* Converts CFString object to String.
*
* @param cfStringPointer Pointer to CFString object
* @return String from CFString
*/
private String getStringFromCFStringRef(Pointer cfStringPointer) {
if (cfStringPointer != null) {
long lenght = cfLibrary.CFStringGetLength(cfStringPointer);
long maxSize = cfLibrary.CFStringGetMaximumSizeForEncoding(lenght, 0x08000100); // 0x08000100 = UTF-8
Pointer buffer = new Memory(maxSize);
if (cfLibrary.CFStringGetCString(cfStringPointer, buffer, maxSize, 0x08000100)) { // 0x08000100 = UTF-8
return buffer.getString(0L);
}
}
return null;
}