注册表修改 win2000、xp或以上的系统下能否通过程序修改其他windows用户的注册表,如果可行能不能说一下方法谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 很难。注册表 HKEY_USERS下面是所有用户的配置,像HKEY_USERS\S-1-5-12这样的,但是其中只有一个是当前用户的,而且这个项被映射到了HKEY_CURRENT_USER下面,但是要想知道其他用户的像"S-1-5-12"这样的标识,是很难的。 大概这样试试,用LogonUser API取得其他用户的Security Token,用ImpersonateUser将当前线程转换到该用户名下,调用LoadUserProfile装入用户设定(包括注册表项),读写注册表,将当前线程转换回来。IntPtr tokenHandle;LogonUser(username, domain, password, ... , ref tokenHandle); // 登录用户WindowsIdentity newId = new WindowsIdentity(tokenHandle); // 创建用户身法WindowsImpersonationContext impersonatedUser = newId.Impersonate(); // 将当前线程转换到该用户名下LoadUserProfile(tokenHandle, ...); // 装入用户注册表//... 读写注册表impersonatedUser.Undo(); // 将当前线程切换回来。WindowsImpersonationContext类 有调用LogonUser的例子LoadUserProfile 介绍了LoadUserProfile的用法。你也可以试着用该调用拿到的指向用户注册表项的句柄来读写注册表。读写注册表可参考Microsoft.Win32.RegistryKey等类。 要有管理员权限,Demo: RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM", false); retval = (string)key.GetValue(keyName);key.Close(); return retval; C#修改注册表(IE),以修改IE代理服务器为例:using System;using System.Collections;using System.Threading;using System.Runtime.InteropServices;using System.Diagnostics;using Microsoft.Win32;namespace TestBlog{ class Program { [DllImport(@"wininet", SetLastError = true, CharSet = CharSet.Auto, EntryPoint = "InternetSetOption", CallingConvention = CallingConvention.StdCall)] public static extern bool InternetSetOption ( int hInternet, int dmOption, IntPtr lpBuffer, int dwBufferLength ); public static void SetProxy(string proxy) { //打开注册表 RegistryKey regKey = Registry.CurrentUser; string SubKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings"; RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true); //更改健值,设置代理, optionKey.SetValue("ProxyEnable", 1); optionKey.SetValue("ProxyServer", proxy); //激活代理设置 InternetSetOption(0, 39, IntPtr.Zero, 0); InternetSetOption(0, 37, IntPtr.Zero, 0); } } "LocalMachine\\Software\\Microsoft\\MSCRM",没找到这一项,请问这项里包含什么内容 NetUserAdd FunctionThe NetUserAdd function adds a user account and assigns a password and privilege level. 注册表的数据文件不是一个,而是很多个。其中HKCU信息是从用户目录(c:\My Documents\username\...)下的NTUSER.DAT和USRCLASS.DAT中装载的。不用的用户登录后,注册表会加载不同的HKCU信息。有就是说,用户登录后HKCU中的信息,在该用户没有登录的情况下,是找不到的。即使你用了管理员权限也没有用。至于HKEY_USERS下的HKEY_USERS\S-1-5-12,并不是真正的用户,而是内置用户的SID。比如S-1-5-18是Local System帐号。真正用户的SID格式像这样(其中有个GUID):S-1-5-21-1547161642-813497703-xxxxxxxx-1003这就是为什么我在4楼的回复让你尝试LogonUser和LoadUserProfile。 竖着的图片菜单怎么做?? 一道委托的题目 数据的绑定 主页上想链接到企业邮箱的代码怎么写 数据入库的时候如何先对比后更新? 求助,关于屏蔽自定义控件的某些属性的问题 installshield 10.5 中的对话框如何选择???????? 关于发行充值卡相关的C#实现 用C# + jmail收发邮件问题! 高分求用c#写的类似QQ的源代码 请问怎样防止输入脚本 帮我
LogonUser(username, domain, password, ... , ref tokenHandle); // 登录用户
WindowsIdentity newId = new WindowsIdentity(tokenHandle); // 创建用户身法
WindowsImpersonationContext impersonatedUser = newId.Impersonate(); // 将当前线程转换到该用户名下
LoadUserProfile(tokenHandle, ...); // 装入用户注册表
//... 读写注册表
impersonatedUser.Undo(); // 将当前线程切换回来。WindowsImpersonationContext类 有调用LogonUser的例子
LoadUserProfile 介绍了LoadUserProfile的用法。你也可以试着用该调用拿到的指向用户注册表项的句柄来读写注册表。读写注册表可参考Microsoft.Win32.RegistryKey等类。
Demo:
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM", false);
retval = (string)key.GetValue(keyName);key.Close();
return retval;
using System.Collections;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Microsoft.Win32;namespace TestBlog
{
class Program
{
[DllImport(@"wininet",
SetLastError = true,
CharSet = CharSet.Auto,
EntryPoint = "InternetSetOption",
CallingConvention = CallingConvention.StdCall)] public static extern bool InternetSetOption
(
int hInternet,
int dmOption,
IntPtr lpBuffer,
int dwBufferLength
);
public static void SetProxy(string proxy)
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true);
//更改健值,设置代理,
optionKey.SetValue("ProxyEnable", 1);
optionKey.SetValue("ProxyServer", proxy); //激活代理设置
InternetSetOption(0, 39, IntPtr.Zero, 0);
InternetSetOption(0, 37, IntPtr.Zero, 0);
}
}
"LocalMachine\\Software\\Microsoft\\MSCRM",没找到这一项,请问这项里包含什么内容
下的NTUSER.DAT和USRCLASS.DAT中装载的。不用的用户登录后,注册表会加载不同的HKCU信息。有就是说,用户登录后HKCU中的信息,在该用户没有登录的情况下,是找不到的。即使你用了管理员权限也没有用。至于HKEY_USERS下的HKEY_USERS\S-1-5-12,并不是真正的用户,而是内置用户的SID。比如S-1-5-18是Local System帐号。
真正用户的SID格式像这样(其中有个GUID):S-1-5-21-1547161642-813497703-xxxxxxxx-1003这就是为什么我在4楼的回复让你尝试LogonUser和LoadUserProfile。