Reputation: 4283
I'm automating setting dcom properties of an app programmatically in c#. When I manually change the setting thru component services I see the following entry in registry. But I need to do it programmatically. This is what I did to create this entry in the registry:
Here is the result:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{0B902D3B-6517-4EBD-B61B-6F5830A77578}]
@="TestClient.AccBkrcn"
"LaunchPermission"=hex:01,00,04,80,74,00,00,00,84,00,00,00,00,00,00,00,14,00,\
00,00,02,00,60,00,04,00,00,00,00,00,14,00,1f,00,00,00,01,01,00,00,00,00,00,\
05,12,00,00,00,00,00,18,00,1f,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,\
20,02,00,00,00,00,18,00,03,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,38,\
02,00,00,00,00,14,00,1f,00,00,00,01,01,00,00,00,00,00,05,04,00,00,00,01,02,\
00,00,00,00,00,05,20,00,00,00,20,02,00,00,01,02,00,00,00,00,00,05,20,00,00,\
00,20,02,00,00
Upvotes: 1
Views: 3331
Reputation: 22158
If you simply want to write the value above to the registry using C#, you can use the RegistryKey
class in the Microsoft.Win32 namespace:
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Classes\AppID\{0B902D3B-6517-4EBD-B61B-6F5830A77578", true);
key.SetValue("TestClient.AccBkrcn", new byte[] { 01,00,04,80,74,00,00,00,84,00,00,00,00,00,00,00,14,00,
00,00,02,00,60,00,04,00,00,00,00,00,14,00,1f,00,00,00,01,01,00,00,00,00,00,
05,12,00,00,00,00,00,18,00,1f,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,
20,02,00,00,00,00,18,00,03,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,38,
02,00,00,00,00,14,00,1f,00,00,00,01,01,00,00,00,00,00,05,04,00,00,00,01,02,
00,00,00,00,00,05,20,00,00,00,20,02,00,00,01,02,00,00,00,00,00,05,20,00,00,
00,20,02,00,00 });
EDIT:
As Brent points out, you'll need to prefix each number with 0x or this won't work.
Upvotes: 0
Reputation: 44931
You can use the Microsoft.Win32.Registry methods, especially SetValue
to perform this task. Using the SetValue
method, arrays of Byte[] are automatically stored as binary.
Upvotes: 1