native-methods

UnsatisfiedLinkError java exception when the class with the native method is not in the default package

让人想犯罪 __ 提交于 2020-02-06 08:49:27
问题 I am trying to open a URL with the default Windows browser, in Java. Unfortunately, I cannot use the Desktop class utilities since the code has to be compatible with 1.5. As a solution, I am calling ShellExecute by using a native method: public class ShellExec { public native int execute(String document); { System.loadLibrary("HSWShellExec"); } public static void main(String args[]) throws IOException { new ShellExec().execute("http://www.google.com/"); } } I put the DLL file in the Eclipse

How to correctly call P/Invoke methods in a class library?

☆樱花仙子☆ 提交于 2020-02-01 08:37:04
问题 I have multiple projects in a Visual Studio 2015 solution. Several of these projects do P/Invokes like: [DllImport("IpHlpApi.dll")] [return: MarshalAs(UnmanagedType.U4)] public static extern int GetIpNetTable(IntPtr pIpNetTable, [MarshalAs(UnmanagedType.U4)] ref int pdwSize, bool bOrder); So I moved all my P/Invokes to a separate class library and defined the single class as: namespace NativeMethods { [ SuppressUnmanagedCodeSecurityAttribute(), ComVisible(false) ] public static class

JVM (HotSpot) : Where do all the methods go ? method area ? native method stack?

空扰寡人 提交于 2020-01-23 21:52:27
问题 I am new to JVM (HotSpot), and try to understand the architecture of it and how it works, so my question is that do all the methods (both static and non-static) get translated into byte-code ? and when JVM loads the class files, does it load all the methods into somewhere ? like method area ? or native method stacks ? 回答1: It's dependent on the JVM implementation - different JVMs may choose to handle this in different ways (as long as they conform to the Java spec). So you have no absolute

Change screen Orientation with powershell - Where are the registry values stored?

99封情书 提交于 2020-01-15 04:45:50
问题 Hej from Sweden, I am trying out the code from the reference post: Powershell script to change screen Orientation The script works. The goal is to make sure that the rotation is either landscape - default or portrait 90 degrees clockwise. I need to either change the current code to just allow 2 values or make sure that the script only runs once. Either way, I need to know where the registry keys are stored for the CDS_UPDATEREGISTRY. Although I cannot figure out where in the registry the

Return an IOleCommandTarget from processing WM_GETOBJECT in a NativeWindow

你。 提交于 2020-01-04 17:13:28
问题 I am trying to retrieve an IOleCommandTarget reference from a panel control handle, so that I can call IOleCommandTarget.Exec() on it. NativeMethods.IOleCommandTarget target = null; if (GetObjectFromHandle<NativeMethods.IOleCommandTarget>(panel.Handle, out target)) { Guid guidCmdGroup = commandID.Guid; handled = (target.Exec(ref guidCmdGroup, commandID.ID, 0, null, 0) == NativeMethods.S_OK); } private static bool GetObjectFromHandle<T>(IntPtr hwnd, out T value) { Guid guid = typeof(T).GUID;

running dll method Javafx

孤人 提交于 2020-01-03 02:54:18
问题 I have C program (Dll) which I can call from Java using JNI. I want to use Javafx for the interface so I made a java class to call the dll. I am able to load the dll but I cannot call the method. The error message it gives me is java.lang.UnsatisfiedLinkError: mark1.Small_test.tester(DDDLjava/lang/String;Ljava/lang/String;Ljava/lang/String;DDD)[D java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl

Mockito throwing UnfinishedVerificationException (probably related to native method call)

99封情书 提交于 2019-12-23 09:27:57
问题 I have the following exception when I run a test case: org.mockito.exceptions.misusing.UnfinishedVerificationException: Missing method call for verify(mock) here: -> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Example of correct verification: verify(mock).doSomething() Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods. Those methods *cannot* be stubbed/verified. at com.bignibouX.tests.repository.member

Making a short alias for document.querySelectorAll

孤街浪徒 提交于 2019-12-17 23:29:28
问题 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? 回答1: 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

How to control the execution of an externl native DLL

大憨熊 提交于 2019-12-12 07:00:36
问题 I have this code in .NET: result = NativeMethods.gsapi_init_with_args(_ghostScriptInstance, args.Length, _argumentPointersHandle.AddrOfPinnedObject()); That in its turn executes this code [DllImport("C:\\gsdll64.dll", EntryPoint = "gsapi_init_with_args")] public static extern int gsapi_init_with_args(IntPtr instance, int argc, IntPtr argv); The problem is that because of yet unknown problem the native execution enters into an infinite loop and never returns. The question is how can I cap the