Not Valid reference to the registry

P

Priya

Hi All,
I am working with OpenNETCF.Desktop.Communication dll to change the
registry of device from desktop.When i delete a key ,it is
throwing exception like "Not a valid reference to the registry" though the
key is there in the registry.
I tried with lot of options but it is giving the same problem.
Can you help me..
Thank you,
supriya
 
G

Guest

You're likely working with a WM 5.0 device and RAPI is not provisioned with
permissions to alter the registry by default on your device.
 
P

Priya

It is giving same problem in 4.2 version also.

You're likely working with a WM 5.0 device and RAPI is not provisioned
with permissions to alter the registry by default on your device.
 
P

Priya

Hi sir,

I am sending the code here.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using OpenNETCF.Desktop.Communication;

namespace DesktopPPCReg

{

public partial class Form1 : Form

{

private RAPI rp = new RAPI();

CERegistryKey regKey = CERegistry.Users;

CERegistryKey regNewKey = null;

public Form1()

{

InitializeComponent();

}

private void btnConnect_Click(object sender, EventArgs e)

{

try

{

rp.Connect( true );

}

catch ( Exception ex )

{

MessageBox.Show(ex.Message);

}

}

//Create key under HKEY_USERS

private void btnCrtKey_Click(object sender, EventArgs e)

{

try

{

regNewKey = regKey.CreateSubKey("sample");


regNewKey.Close();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

//to delete "sample" key under HKEYUSERS

private void btnDltKey_Click(object sender, EventArgs e)

{

try

{

regKey.DeleteSubKey("sample");

regKey.Close();

}

catch (Exception ex)

{

MessageBox.Show("Unable to delete the key ." +
ex.Message);

}

}


}

}
 
G

Guest

Just like is documented for the full framework and the CF, the
CreateSubKey(string) overload creates a key with _read_ permissions. You
cannot delete when you only have read permissions. Open it with write
permissions if you want to delete.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top