Problem z funkcją DWORD rejestru...

  • 1 Odpowiedzi
  • 993 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

Problem z funkcją DWORD rejestru...
« dnia: Wrzesień 13, 2006, 16:46:42 »
Czy ktoś wie dlaczego ta funkcja nie wstawia wpisu typu DWORD do rejestru?

/// <summary>
      /// Create a DWORD value in the specified registry key
      /// </summary>
      /// <param name="Key">Name of hKey to access</param>
      /// <param name="keyName">Name of key</param>
      /// <param name="valueName">Name of value</param>
      /// <param name="dwordData">Value data</param>
      /// <returns>ERROR_SUCCESS if successful</returns>
      public int CreateValueDWORD(UIntPtr Key, string keyName, string valueName, uint dwordData)
      {
         UIntPtr hkey = UIntPtr.Zero;

         try
         {
            int result = RegOpenKeyEx(Key, keyName, 0, KeyAccess.None, ref hkey);
         //   if (ERROR_SUCCESS != result)
         //      return result;

            byte[] bytes = BitConverter.GetBytes(dwordData);
            return RegSetValueEx(hkey, valueName, 0, KeyType.Dword,
               bytes, (uint)bytes.Length);
         }
         finally
         {
            if (UIntPtr.Zero != hkey)
            {
               RegCloseKey(hkey);
            }
         }
         WriteRegistryKey(Key, keyName, valueName, dwordData);
         return ERROR_SUCCESS;
      }

*

Offline MacBirdie

  • *****
  • 1943
  • Płeć: Mężczyzna
  • I znów Poznań ;)
    • macbirdie.net
  • Sprzęt: iPhone 4 16GB | iPad 3G 64GB | iPhone 3G 8GB
Problem z funkcją DWORD rejestru...
« Odpowiedź #1 dnia: Wrzesień 14, 2006, 01:02:41 »
Ty mając dane wejściowe, kod i debugger powinieneś to wiedzieć. ;)
Zobacz jaki błąd ona zwraca i w ogóle w którym miejscu się sypie, wtedy spróbujemy coś zaradzić.