I have this P/Invoke RegSetValueExW that sets the value to the registry key. in C#
[DllImport("coredll.dll", EntryPoint = "RegSetValueExW")]
public static extern int RegSetValueExW(uint hKey, string lpValueName,
uint lpReserved,
uint lpType,
byte[] lpData,
uint lpcbData);
I'm having a problem with the 4th param byte[] lpdata. I need to pass a DWORD with a value of 5 (int) in it. Everything is OK if I pass a string (REG_SZ), just need to convert using the GetBytes function.
If I call GetBytes("5") it converts it to ascii value of 53 so it writes 53 on the registry value instead of 5