See the question and my original answer on StackOverflow

I think you need to do two changes:

1) change:

uint HKEY_LOCAL_MACHINE = 0x80000002;

to:

int HKEY_LOCAL_MACHINE = unchecked((int)0x80000002);

to avoid the type mismatch error, and

2) change:

string[] result = null;

to:

object[] result = null;

to avoid a forthcoming "System.InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'System.String[]'"