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

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

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

Native.toCharArray介绍

暂无

代码示例

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

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

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

/**
 * Set a string value in registry.
 *
 * @param hKey
 *            Parent key.
 * @param name
 *            Value name.
 * @param value
 *            Value to write to registry.
 */
public static void registrySetStringValue(HKEY hKey, String name,
    String value) {
  char[] data = Native.toCharArray(value);
  int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ,
      data, data.length * Native.WCHAR_SIZE);
  if (rc != W32Errors.ERROR_SUCCESS) {
    throw new Win32Exception(rc);
  }
}

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

/**
 * Set an expandable string value in registry.
 *
 * @param hKey
 *            Parent key.
 * @param name
 *            Value name.
 * @param value
 *            Value to write to registry.
 */
public static void registrySetExpandableStringValue(HKEY hKey, String name,
    String value) {
  char[] data = Native.toCharArray(value);
  int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0,
      WinNT.REG_EXPAND_SZ, data, data.length * Native.WCHAR_SIZE);
  if (rc != W32Errors.ERROR_SUCCESS) {
    throw new Win32Exception(rc);
  }
}

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

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

相关文章

Native类方法