- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我为这个 c 方法编写了等效的 Java 方法:
HRESULT h3 = CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT h4 = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
IShellItemImageFactory * item;
HRESULT h = SHCreateItemFromParsingName(L"C:\\Users\\Marcel\\Desktop\\CosmosKernel2Boot.iso", NULL, IID_IShellItemImageFactory, (void**)&item);
if (SUCCEEDED(h)) {
HBITMAP bit;
SIZE size = { 32,32 };
HRESULT hh = item->GetImage(size, SIIGBF_RESIZETOFIT, &bit);
if (SUCCEEDED(hh)) {
cout << "SUCCEEDED";
}
}
item->Release();
CoUninitialize();
Java:
Ole32Extra.INSTANCE.CoInitializeEx(null,Ole32.COINIT_MULTITHREADED);
Ole32Extra.INSTANCE.CoInitializeSecurity(null, -1, null, null, Ole32Extra.RPC_C_AUTHN_LEVEL_DEFAULT, Ole32Extra.RPC_C_IMP_LEVEL_IMPERSONATE, null, Ole32Extra.EOAC_NONE, null);
PointerByReference factory = new PointerByReference();
WinNT.HRESULT h5 = Shell32Extra.INSTANCE.SHCreateItemFromParsingName(new WString("C:\\Users\\Marcel\\Desktop\\Test.txt"),null,new Guid.REFIID(new Guid.IID(Shell32Extra.IID_IShellItemImageFactory)),factory);
if(COMUtils.SUCCEEDED(h5)) {
IShellItemImageFactory factory1 = new IShellItemImageFactory(factory.getValue());
PointerByReference bitP = new PointerByReference();
WinUser.SIZE size = new WinUser.SIZE(32,32);
WinNT.HRESULT hi = factory1.GetImage(size,0,bitP);
if(COMUtils.SUCCEEDED(hi)) {
WinDef.HBITMAP bit = new WinDef.HBITMAP(bitP.getPointer());
System.out.println("SUCCEEDED");
}else{
System.out.println(hi);
}
factory1.Release();
}else{
System.out.println(h5);
}
Ole32Extra.INSTANCE.CoUninitialize();
当我运行 c 方法时,一切正常,并打印出“SUCCEEDED”。
但是当我运行 Java 方法时,HRESULT hi 总是返回 -2147024882这意味着 E_OUTOFMEMORY。
我不知道为什么会抛出这个错误,但我希望任何人都可以提供帮助
错误正是发生在这一行中:
HRESULT hh = item->GetImage(size, SIIGBF_RESIZETOFIT, &bit);
WinDef.HBITMAP bit = new WinDef.HBITMAP(bitP.getPointer());
最佳答案
解决办法是SIZE结构不能按值传递。 (在 C++ 中可以)。您必须创建一个扩展 SIZE 并实现 Structure.ByValue 的类 SIZEByValue。现在它正在工作。
关于java - Jna E_OUTOFMEMORY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52953419/
我正在使用 JNA 加载 native 库: MyLibrary INSTANCE = (MyLibrary) Native.loadLibrary("mylibrary.so", MyLibrary
任何人都可以为我提供一个 JNA 鼠标钩子(Hook)的工作示例,它能够在我的 Java Swing 应用程序之外跟踪鼠标移动/单击吗? 提前致谢 最佳答案 是的,这里是代码... public cl
我在哪里可以获得支持 ARM64 的 JNA 库? com.sun.jna_4.jar 包含适用于 ARM 的 native libjnidispatch.so 库,但不包含适用于 ARM64 的库。
我正在尝试使用 JNA,因为我想使用一个用 c++ 编写的 .dll,而我的其余代码是用 Java 编写的。但是,如果我尝试导入 JNA 类 Eclipse 声称“com.sun.jna.Librar
我使用以下代码从java程序控制Windows服务 public class PostgresService2 { public static void main(String[] args)
我有一个用于 C 函数 mpv_set_option_string 的 JNA Java 接口(interface),定义为: public interface MPV extends StdCall
我正在查看中央 Maven 存储库,并看到一个 net.java.dev.jna 和一个用于 JNA 的 com.sun.jna groupId。 JNA 的 github,使用 com.sun.jn
我已经开始构建一个 java 服务,它结合了 JNA 来加载 native C/C++ 库,我想在 Raspberry PI aka arm 平台上运行 java 服务。我已经成功地建立了一个稳定的服
我要离开 this如何传递 com.sun.jna.Structure 的示例包含 com.sun.jna.StringArray使用 JNA 从 Java 转换为 native C 代码,并且无法在
我正在准备 spring-boot 应用程序。然后我得到以下错误: JNA not found. native methods will be disabled. java.lang.ClassNot
遇到令人抓狂的阻塞错误: Exception in thread "main" java.lang.Error: Structure.getFieldOrder() on class com.luke
我已经下载并复制 Jna.jar 和 Platform.jar 到/usr/cassandra/apache-cassandra-1.0.7/lib 文件夹,但在 Cassandra 启动时仍然看到以
我有一个像这样的 JNA 库 stub : public interface FREngine extends Library { NativeLibrary JNA_NATIVE_LIB =
我想使用 JNAerator 为 JNA 生成一些 C++ API 函数的 Java 包装器。问题是我无法在工作时使用 JNAerator Studio 或从我的 PC 访问 Github。我只有 G
在 JNA 中,如何从 Xlib 映射联合结构,如以下 XEvent typedef union _XEvent { int type; /* must not be changed *
我正在尝试使用 JNA 从 java 运行 ShellExecute 函数。我在非 unicode 文件夹上运行 ShellExecuteA 没有任何问题 import com.sun.jna.*;
在弄清楚如何将 ClientToScreen winapi 函数与 JNA 结合使用时遇到问题。 我仍然得到窗口句柄坐标的 0, 0 输出。我引用了这个,但我确信我做得不对 https://msdn.
我有两个局部变量: Pointer output; int output_len; /* or better `size_t output_len;` */ 我需要将这些变量的指针传递到 JNA 函数
我有一个openvr binding有一段时间以来有一个小问题 基本上,每当我释放某些几何 3D 模型(基站或 Controller )的内存时,我都会时不时地收到错误: "java.lang.Err
我是 JNA 新手,我想将 DsGetDcName 方法转换为 JNA。 DWORD DsGetDcName( __in LPCTSTR ComputerName, __in LPCT
我是一名优秀的程序员,十分优秀!