自动添加环境变量代码
来源:互联网 发布:js prop checked 编辑:程序博客网 时间:2024/05/21 12:15
#region SetEnvironmentPath [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult); public static string RegKey = @"System\CurrentControlSet\Control\Session Manager\Environment"; public static string NewPathForFolder = @Application.StartupPath+"\\OOI_HOME"; public enum SendMessageTimeoutFlags : uint { SMTO_NORMAL = 0x0000, SMTO_BLOCK = 0x0001, SMTO_ABORTIFHUNG = 0x0002, SMTO_NOTIMEOUTIFNOTHUNG = 0x0008 } private static void SetEnvironmentPath() { RegistryKey key0 = Microsoft.Win32.Registry.LocalMachine; RegistryKey key = key0.OpenSubKey(RegKey, true); string OOI_HOMEPath = (String)key.GetValue("OOI_HOME");//OOI_HOME if (OOI_HOMEPath == null || OOI_HOMEPath.IndexOf(NewPathForFolder, 0) == -1) { //OOI_HOMEPath += ";" + NewPathForFolder;OOI_HOMEPath = NewPathForFolder; key.SetValue("OOI_HOME", OOI_HOMEPath);//OOI_HOME IntPtr HWND_BROADCAST = (IntPtr)0xffff; const UInt32 WM_SETTINGCHANGE = 0x001A; UIntPtr result; IntPtr settingResult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, (UIntPtr)0, "Environment", SendMessageTimeoutFlags.SMTO_NORMAL, 10000, out result); } } #endregion
0 0
- 自动添加环境变量代码
- 自动添加修改环境变量
- Java环境变量自动添加工具的制作
- Xcode开启自动功能,添加环境变量
- eclipse添加自动代码提示
- Linux添加环境变量和Django自动切换配置文件版本
- 添加环境变量
- 添加环境变量
- 环境变量添加
- 添加环境变量
- 添加环境变量
- 添加环境变量
- 添加环境变量
- 添加环境变量
- 添加环境变量
- 添加环境变量
- ios自动布局使用代码添加约束
- 用Java代码自动添加按钮
- 性能调优基础篇之 String
- 防火墙和我国大家哈感觉说的
- android service 之一 (start service)
- ARC在IBOutlet属性中的使用
- 的话去接我的机会就爱上的国际化
- 自动添加环境变量代码
- COCOS2D-X 像素级碰撞检测
- getRealPath()和getContextPath()的区别
- 回去后我的干活就噶是假的
- 快速排序递归非递归队列堆栈实现
- 电话过去我估计的后果和骄傲是电玩
- Codeforces 455C Civilization(并查集+dfs)
- 都回去后金额我是大家哈高速的话几千万
- hdu1695 dfs+欧拉函数