public static string[] ReadRegistryKeyMultiSzValue(IntPtr key, string name) { Import.RType type = Import.RType.RegMultiSz; uint size = 0; if (Import.RegQueryValueEx(key, name, 0, ref type, null, ref size) != 0) { return(null); } byte[] d = new byte[(int)size]; if (Import.RegQueryValueEx(key, name, 0, ref type, d, ref size) != 0) { return(null); } List <string> strings = new List <string>(); string s = Encoding.Unicode.GetString(d, 0, (int)size); int start; int end = -1; while (true) { start = end + 1; end = s.IndexOf('\0', start); if (end <= start) { break; } strings.Add(s.Substring(start, end - start)); } return(strings.ToArray()); }
public static string ReadRegistryKeySzValue(IntPtr key, string name) { Import.RType type = Import.RType.RegSz; uint size = 0; if (Import.RegQueryValueEx(key, name, 0, ref type, null, ref size) != 0) { return(null); } byte[] d = new byte[(int)size]; if (Import.RegQueryValueEx(key, name, 0, ref type, d, ref size) != 0) { return(null); } return(Encoding.Unicode.GetString(d, 0, (int)size)); }