Показать сообщение отдельно

  #4  
Старый 09.12.2009, 00:05
BrainDeaD
Постоянный
Регистрация: 09.06.2005
Сообщений: 531
Провел на форуме:
3516666

Репутация: 439


По умолчанию

Код:
[StructLayout(LayoutKind.Sequential)]
        public struct SECURITY_ATTRIBUTES
        {
            public int nLength;
            public IntPtr lpSecurityDescriptor;
            public bool bInheritHandle;
        }
[DllImport("advapi32.dll", EntryPoint = "RegCreateKeyEx")]
          public static extern uint RegCreateKeyEx(uint hKey, string lpSubKey, uint Reserved, string lpClass, uint dwOptions, uint samDesired, ref SECURITY_ATTRIBUTES lpSecurityAttributes, ref uint phkResult, ref uint lpdwDisposition);
          [DllImport("advapi32.dll", EntryPoint = "RegSetValueEx")]
          public static extern uint RegSetValueEx(uint hKey, string lpValueName, uint Reserved, uint dwType, string lpData, uint cbData);
static void SetKey()
        {
            SECURITY_ATTRIBUTES secattr = new SECURITY_ATTRIBUTES();
            secattr.nLength = Marshal.SizeOf(secattr);
            secattr.lpSecurityDescriptor = (IntPtr)0;
            secattr.bInheritHandle = true;

            uint neworused = 0;
            uint hIDKey = 0;

            RegistryKey key = Registry.LocalMachine;
            RegistryKey currKey = key.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");

            uint res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", 0, null, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ref secattr, ref hIDKey, ref neworused);
            if (res == ERROR_SUCCESS)
            {
                res = RegSetValueEx(hIDKey, "SFCSetting", 0, REG_SZ, "dword:ffffff9d", keyLength);
            }
что-то вроде этого. разбирайтесь. к сожалению сейчас нет времени помочь большим.
 
Ответить с цитированием