com.sun.jna.Native.toCharArray()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中com.sun.jna.Native.toCharArray()方法的一些代码示例,展示了Native.toCharArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.toCharArray()方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:toCharArray

Native.toCharArray介绍

暂无

代码示例

代码示例来源:origin: brettwooldridge/NuProcess

  1. private char[] getCommandLine(List<String> commands)
  2. {
  3. StringBuilder sb = new StringBuilder();
  4. boolean isFirstCommand = true;
  5. for (String command : commands) {
  6. if (isFirstCommand) {
  7. isFirstCommand = false;
  8. } else {
  9. // Prepend a space before the second and subsequent components of the command line.
  10. sb.append(' ');
  11. }
  12. // It's OK to apply CreateProcess escaping to even the first item in the commands
  13. // list (the path to execute). Since Windows paths cannot contain double-quotes
  14. // (really!), the logic in WindowsCreateProcessEscape.quote() will either do nothing
  15. // or simply add double-quotes around the path.
  16. WindowsCreateProcessEscape.quote(sb, command);
  17. }
  18. return Native.toCharArray(sb.toString());
  19. }

代码示例来源:origin: net.java.dev.jna/platform

  1. /**
  2. * Set a string value in registry.
  3. *
  4. * @param hKey
  5. * Parent key.
  6. * @param name
  7. * Value name.
  8. * @param value
  9. * Value to write to registry.
  10. */
  11. public static void registrySetStringValue(HKEY hKey, String name,
  12. String value) {
  13. char[] data = Native.toCharArray(value);
  14. int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ,
  15. data, data.length * Native.WCHAR_SIZE);
  16. if (rc != W32Errors.ERROR_SUCCESS) {
  17. throw new Win32Exception(rc);
  18. }
  19. }

代码示例来源:origin: net.java.dev.jna/platform

  1. /**
  2. * Set an expandable string value in registry.
  3. *
  4. * @param hKey
  5. * Parent key.
  6. * @param name
  7. * Value name.
  8. * @param value
  9. * Value to write to registry.
  10. */
  11. public static void registrySetExpandableStringValue(HKEY hKey, String name,
  12. String value) {
  13. char[] data = Native.toCharArray(value);
  14. int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0,
  15. WinNT.REG_EXPAND_SZ, data, data.length * Native.WCHAR_SIZE);
  16. if (rc != W32Errors.ERROR_SUCCESS) {
  17. throw new Win32Exception(rc);
  18. }
  19. }

代码示例来源:origin: brettwooldridge/NuProcess

  1. char[] cwdChars = (cwd != null) ? Native.toCharArray(cwd.toAbsolutePath().toString()) : null;
  2. if (!NuKernel32.CreateProcessW(null, getCommandLine(commands), null /*lpProcessAttributes*/, null /*lpThreadAttributes*/, true /*bInheritHandles*/,
  3. dwCreationFlags, env, cwdChars, startupInfo, processInfo)) {

相关文章

Native类方法