native-methods

Is it possible to override a native method in a Java class in Android/dalvik?

只谈情不闲聊 提交于 2019-12-04 02:46:16
I am unit testing a class TestMe using EasyMock, and one of its methods (say method(N n) ) expects a parameter of type N which has a native method (say nativeMethod() ). class TestMe { void method(N n) { // Do stuff n.nativeMethod(); // Do more stuff } } method() needs to invoke N.nativeMethod() at some point, and the problem I'm having is that my Easymock mock object for N is unable to override the native method. I do not own class N but I can refactor TestMe in any way necessary. I decided to make my own class FakeN extends N which overrides nativeMethod to do nothing: class FakeN extends N

Trying to load an application's icon(s) using LoadImage, but the function returns 0

纵然是瞬间 提交于 2019-12-02 21:17:52
问题 I am trying to load an application's icon(s) using the LoadImage WinAPI function, but for some reason it always returns 0. I have read the documentation, but I cannot understand what I've done wrong. I get no exceptions except for when trying to convert IconPtr to Icon (which is becasue IconPtr is 0). Public Shared Function ExtractAssociatedIconArray(ByVal File As String, ByVal Sizes() As Size) As Icon() Dim ReturnArray(Sizes.Length) As Icon Dim Index As Integer = 0 For Each s As Size In

GetMouseMovePointsEx: Bounds / MOUSEMOVEPOINT in (mp_in) problems

陌路散爱 提交于 2019-12-02 17:14:52
问题 I'm trying to calculate cursor acceleration / velocity. I read Find the velocity of the mouse in C# and decided to take Hans's suggestion of using GetMouseMovePointsEx (pinvoke.net, MSDN). I made a demo program to test it out (see full code below) but it has a big limitation. It won't return points once the cursor leaves the window. In fact, the function returns -1 (win32Exception 1171, "The point passed to GetMouseMovePoints is not in the buffer") if execution isn't limited to points within

Trying to load an application's icon(s) using LoadImage, but the function returns 0

拟墨画扇 提交于 2019-12-02 09:52:44
I am trying to load an application's icon(s) using the LoadImage WinAPI function, but for some reason it always returns 0. I have read the documentation , but I cannot understand what I've done wrong. I get no exceptions except for when trying to convert IconPtr to Icon (which is becasue IconPtr is 0). Public Shared Function ExtractAssociatedIconArray(ByVal File As String, ByVal Sizes() As Size) As Icon() Dim ReturnArray(Sizes.Length) As Icon Dim Index As Integer = 0 For Each s As Size In Sizes 'IconPtr is always zero for some reason. Dim IconPtr As IntPtr = NativeMethods.LoadImage(Nothing,

GetMouseMovePointsEx: Bounds / MOUSEMOVEPOINT in (mp_in) problems

廉价感情. 提交于 2019-12-02 09:05:05
I'm trying to calculate cursor acceleration / velocity. I read Find the velocity of the mouse in C# and decided to take Hans's suggestion of using GetMouseMovePointsEx ( pinvoke.net , MSDN ). I made a demo program to test it out (see full code below) but it has a big limitation. It won't return points once the cursor leaves the window. In fact, the function returns -1 (win32Exception 1171, "The point passed to GetMouseMovePoints is not in the buffer") if execution isn't limited to points within the MainWindow. I suspect this may be because I'm using Mouse.GetPosition() to provide the mp_in

Is the class NativeMethods handled specially in .NET?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 03:20:17
https://msdn.microsoft.com/en-us/library/ms182161.aspx Are the three classes described on this paged handled specially in the .NET Framework? (NativeMethods, SafeNativeMethods and UnsafeNativeMethods) The reason I'm asking is I'm wondering if it is alright to create categories of NativeMethods classes. For example: ComNativeMethods User32NativeMethods OleStorageNativeMethods It's a convention, not a requirement. If you reflect into the CLR and take a look at code in there, you'll often see P/Invoke code inside a NativeMethods class. I believe that FxCop will recommend putting your P/Invoke

how to get the process output when using jna and CreateProcessW

ぐ巨炮叔叔 提交于 2019-11-30 19:43:32
问题 I'm trying to figure out how to read the standard out/err from the process I've created with CreateProcessW. I looked at the docs, googled and searched this list but I didn't find good pointers/samples yet :) Here's what I came up with so far (it's working fine on windows, it's a relevant snippet from my java code): Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class); Kernel32.StartupInfo startupInfo = new Kernel32.StartupInfo(); Kernel32.ProcessInfo

NullPointerExcetion Native Method Accessor… Hashing Words Issue

强颜欢笑 提交于 2019-11-29 18:09:37
I am writing a project that reads a file and sorts "Words". This code compiles correctly, yet then it gives me a null pointer exception. Any Ideas? import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Hashtable; public class Lab { Hashtable<String, Word> words = new Hashtable<String, Word>(); public void addWord(String s, int i) { if (words.containsKey(s)) { words.get(s).addOne(); words.get(s).addLine(i); } else { words.put(s, new Word(s)); words.get(s).addLine(i); } } public void main(String[] args) { System.out.println("HI"); File file = new

How to retrieve the file previews used by windows explorer in Windows vista and seven?

二次信任 提交于 2019-11-29 00:29:51
I am developing a Delphi documents management application, so somehow I am giving the user some functionality similar to windows explorer. I would like to know if there is a way to get the preview used by windows explorer. For example windows explorer creates a small thumbnail for a pdf document for example, and displays it when the user chooses to view "big icons". Is there a way to retrieve that preview? MyTImage := GiveMePreviewForFile('C:\Test\File.pdf'); RRUZ @user193655, using the IExtractImage interface is the way to go, this interface exposes methods that request a thumbnail image from

Making a short alias for document.querySelectorAll

谁说胖子不能爱 提交于 2019-11-28 15:58:27
I'm going to be running document.querySelectorAll() a whole lot, and would like a shorthand alias for it. var queryAll = document.querySelectorAll queryAll('body') TypeError: Illegal invocation Doesn't work. Whereas: document.querySelectorAll('body') Still does. How can I make the alias work? Sunday Ironfoot This seems to work: var queryAll = document.querySelectorAll.bind(document); bind returns a reference to the querySelectorAll function, changing the context of 'this' inside the querySelectorAll method to be the document object. The bind function is only supported in IE9+ (and all the