如何通过java程序创建注册表项? [英] how to create registry key through java program?

查看:834
本文介绍了如何通过java程序创建注册表项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过java程序创建注册表项,以便在启动时添加jar文件。

I want to create registry key through java program to add the jar file in the start up.

RegistryKey r=new RegistryKey(RootKey.HKEY_CURRENT_USER,"Software/Microsoft/Windows/CurrentVersion/Run");
        r.createSubkey("sample");

但我收到错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: ca.beq.util.win32.registry.RegistryKey.testInitialized()V
        at ca.beq.util.win32.registry.RegistryKey.testInitialized(Native Method)

我该怎么做?

谢谢

How can i do that?
Thanks

推荐答案

在库中添加 JRegistryKey.jar 。 br>
然后在我的项目中复制并粘贴 JRegistryKey.dll

Add the JRegistryKey.jar in the library.
Then copy and paste JRegistryKey.dll in my project.

之后我运行相同的程序,注册表项已成功创建。

After that I run the same program ,The registry key is created successfully.

RegistryKey r=new RegistryKey(RootKey.HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
        RegistryValue v=new RegistryValue("name or the registrykey",ValueType.REG_SZ,"my jar file path");
        r.setValue(v);

这篇关于如何通过java程序创建注册表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆