내 레지스트리의 키 중 하나의 이름을 바꾸는 데 문제가 있습니다. 나도 몰라하지만 항상 자동으로 할 프로그램을 사용하려고 했으므로 이름을 변경하십시오.RegOpenKeyEx에서 오류를 반환합니다. 161
int resul = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Company", 0,0,out result);
내가 잘 키를 열지 않을거야 어떤 이유 : 내가 키를 열 때 문제가
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
private static readonly IntPtr HKEY_LOCAL_MACHINE = new IntPtr(-2147483646);
[DllImport("advapi32")]
public static extern int RegRenameKey(SafeRegistryHandle hKey, [MarshalAs(UnmanagedType.LPWStr)] string oldname,
[MarshalAs(UnmanagedType.LPWStr)] string newname);
[DllImport("Advapi32.dll", EntryPoint = "RegOpenKeyExW", CharSet = CharSet.Unicode)]
public static extern int RegOpenKeyEx(IntPtr hKey, [In] string lpSubKey, int ulOptions, int samDesired, out IntPtr phkResult);
static void Main(string[] args)
{ //mhmmm si, todo esta bien , bueno ire a ver lo que iba oka ver
///Estas intentando renombrar una clave de registro una la crpeta que la contiene...
IntPtr result;
SafeRegistryHandle hKey = null;//no es necesario, esta funcuonando, si no, no me hubiere retorando un int
hKey = new SafeRegistryHandle(HKEY_LOCAL_MACHINE,true);
int resul = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Company", 0,0,out result);
Console.WriteLine(resul);
int rosul = RegRenameKey(hKey, "SOFTWARE\\Company\\", "SOFTWARE\\Editado\\");
Console.WriteLine(rosul);
Console.ReadLine(); //Ok a ver dejamever unos ejemplos de advapi, los tienes ahi? mierdaaa no tiees ideas de los peos que se acaba de tirar mi perro
}
}
}
: 코드는 다음과입니다. 오류의 반환 나에게 :
이내 regedit를 규칙의 이름이 변경되지 않습니다
이http://blogs.microsoft.co.il/pavely/2015/09/29/regrenamekey-hidden-registry-api/
누군가가 도움이되기를 바랍니다 : 내가 참조처럼했다
제 ... 그것은 내 컴퓨터에만 해당됩니다.
64 비트 OS를 사용하는 경우 스크린 샷에 32 비트가 아닌 64 비트 레지스트리 하이브가 표시됩니다. .NET은 일반적으로 응용 프로그램의 비트 수에 따라 액세스를 리디렉션하지만이 경우 Win32 API에 액세스하므로'KEY_WOW64_32KEY' 또는'KEY_WOW64_64KEY' 플래그를 전달해야 할 수도 있습니다. – linuxuser27