Writing the registry

J

Jeff Jeff

Hello all,

I m trying to write a little Winforms app to tweak WM6 registry.
I have no problem to read registry, but i m not able to write on it.

I get "Error on Rapi: 5" which is not very helpful.

I m using : Microsoft.WindowsMobile.Rapi;

and here is the code i use :

private void cmdUpdate_Click(object sender, EventArgs e)
{
try
{
Device objDevice = objRapiManager.Devices[cboDevices.SelectedIndex];

CERegistryKey objRegistryKey = CERegistry.CurrentUser(objDevice.Session);
objRegistryKey = objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu");

objRegistryKey.SetValue("GridView", "1");
objRegistryKey.Close();
}
catch (System.Exception ex)
{
throw ex;
}
}

Thanks alot for your help.

Best regards

Jeff
 
G

Guest

Try using the overloaded method for OpenSubKey

objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu", true);

The second parameter indicates that the key is writable.

Rick D.
Contractor
 
J

Jeff Jeff

Hello Rick,

Thanks for your reply but its seems that they change OpenSubKey as i got
this error :

Error 1 No overload for method 'OpenSubKey' takes '2' arguments

Regards

Jeff

Try using the overloaded method for OpenSubKey

objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu",
true);

The second parameter indicates that the key is writable.

Rick D.
Contractor
Jeff Jeff said:
Hello all,

I m trying to write a little Winforms app to tweak WM6 registry. I
have no problem to read registry, but i m not able to write on it.

I get "Error on Rapi: 5" which is not very helpful.

I m using : Microsoft.WindowsMobile.Rapi;

and here is the code i use :

private void cmdUpdate_Click(object sender, EventArgs e)
{
try
{
Device objDevice = objRapiManager.Devices[cboDevices.SelectedIndex];
CERegistryKey objRegistryKey =
CERegistry.CurrentUser(objDevice.Session); objRegistryKey =
objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu");

objRegistryKey.SetValue("GridView", "1");
objRegistryKey.Close();
}
catch (System.Exception ex)
{
throw ex;
}
}
Thanks alot for your help.

Best regards

Jeff
 
F

Fabien

Hi,

I think it is a security problem; you are not authorized to write this
key via RAPI. You must change the level of the RAPI policy.
Check out this post on my blog: http://fabdecret.blogspot.com/2007/04/windows-mobile-security.html

BR

Fabien Decret
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/

Hello Rick,

Thanks for your reply but its seems that they change OpenSubKey as i got
this error :

Error 1 No overload for method 'OpenSubKey' takes '2' arguments

Regards

Jeff


Try using the overloaded method for OpenSubKey

The second parameter indicates that the key is writable.
Rick D.
Contractor
Hello all,
I m trying to write a little Winforms app to tweak WM6 registry. I
have no problem to read registry, but i m not able to write on it.
I get "Error on Rapi: 5" which is not very helpful.
I m using : Microsoft.WindowsMobile.Rapi;
and here is the code i use :
private void cmdUpdate_Click(object sender, EventArgs e)
{
try
{
Device objDevice = objRapiManager.Devices[cboDevices.SelectedIndex];
CERegistryKey objRegistryKey =
CERegistry.CurrentUser(objDevice.Session); objRegistryKey =
objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu");
objRegistryKey.SetValue("GridView", "1");
objRegistryKey.Close();
}
catch (System.Exception ex)
{
throw ex;
}
}
Thanks alot for your help.
Best regards
Jeff- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
 
J

Jeff Jeff

Hello Fabien,


Thanks for the clue.
In fact spv must be "designer" to be able to write the registry by rapi.

Now it works fine.

Thanks alot for your time.

Best regards
Hi,

I think it is a security problem; you are not authorized to write this
key via RAPI. You must change the level of the RAPI policy.
Check out this post on my blog:
http://fabdecret.blogspot.com/2007/04/windows-mobile-security.html
BR

Fabien Decret
Windows Embedded Consultant
ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/
Hello Rick,

Thanks for your reply but its seems that they change OpenSubKey as i
got this error :

Error 1 No overload for method 'OpenSubKey' takes '2'
arguments

Regards

Jeff
Try using the overloaded method for OpenSubKey

objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu",
true);

The second parameter indicates that the key is writable.

Rick D.
Contractor
:
Hello all,

I m trying to write a little Winforms app to tweak WM6 registry. I
have no problem to read registry, but i m not able to write on it.

I get "Error on Rapi: 5" which is not very helpful.

I m using : Microsoft.WindowsMobile.Rapi;

and here is the code i use :

private void cmdUpdate_Click(object sender, EventArgs e)
{
try
{
Device objDevice =
objRapiManager.Devices[cboDevices.SelectedIndex];
CERegistryKey objRegistryKey =
CERegistry.CurrentUser(objDevice.Session); objRegistryKey =
objRegistryKey.OpenSubKey(@"Software\Microsoft\Shell\StartMenu");
objRegistryKey.SetValue("GridView", "1");
objRegistryKey.Close();
}
catch (System.Exception ex)
{
throw ex;
}
}
Thanks alot for your help.
Best regards

Jeff- Masquer le texte des messages pricidents -
- Afficher le texte des messages pricidents -
 

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

Similar Threads

Writing the registry 2

Top