Writing the registry

J

Jeff Jeff

hello,

Me again.

When i try to write the registry with this code :

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

if (objRegistryKey != null)
objRegistryKey.SetValue("Order", objListIcones);

where objListIcones is a string[].

I get the following errors :


System.ArgumentException was unhandled
Message="The output byte buffer is too small to contain the encoded data,
encoding 'Unicode' fallback 'System.Text.EncoderReplacementFallback'.\r\nParameter
name: bytes"
Source="mscorlib"
ParamName="bytes"
StackTrace:
at System.Text.Encoding.ThrowBytesOverflow()
at System.Text.Encoding.ThrowBytesOverflow(EncoderNLS encoder, Boolean
nothingEncoded)
at System.Text.UnicodeEncoding.GetBytes(Char* chars, Int32 charCount,
Byte* bytes, Int32 byteCount, EncoderNLS encoder)
at System.Text.UnicodeEncoding.GetBytes(String s, Int32 charIndex,
Int32 charCount, Byte[] bytes, Int32 byteIndex)
at Microsoft.WindowsMobile.Rapi.CERegistryKey.SetValue(String name,
Object value)
at TweakWM6.Main.cmdUpdateIcone_Click(Object sender, EventArgs e)
in C:\Data\Dev\TweakWM6\TweakWM6\Main.cs:line 316
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TweakWM6.Program.Main() in C:\Data\Dev\TweakWM6\TweakWM6\Program.cs:line
17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Any clue for this error ?

Thanks for your time


WBR,
Jeff
mailto:[email protected]
 
F

Fabien

Hi,

If you want to set a Multi String Value, try to add this parameter :
objRegistryKey.SetValue("Order", objListIcones,
RegistryValueKind.MultiString);

BR

Fabien Decret
Windows Embedded Consultant

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


hello,

Me again.

When i try to write the registry with this code :

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

if (objRegistryKey != null)
objRegistryKey.SetValue("Order", objListIcones);

where objListIcones is a string[].

I get the following errors :

System.ArgumentException was unhandled
Message="The output byte buffer is too small to contain the encoded data,
encoding 'Unicode' fallback 'System.Text.EncoderReplacementFallback'.\r\nParameter
name: bytes"
Source="mscorlib"
ParamName="bytes"
StackTrace:
at System.Text.Encoding.ThrowBytesOverflow()
at System.Text.Encoding.ThrowBytesOverflow(EncoderNLS encoder, Boolean
nothingEncoded)
at System.Text.UnicodeEncoding.GetBytes(Char* chars, Int32 charCount,
Byte* bytes, Int32 byteCount, EncoderNLS encoder)
at System.Text.UnicodeEncoding.GetBytes(String s, Int32 charIndex,
Int32 charCount, Byte[] bytes, Int32 byteIndex)
at Microsoft.WindowsMobile.Rapi.CERegistryKey.SetValue(String name,
Object value)
at TweakWM6.Main.cmdUpdateIcone_Click(Object sender, EventArgs e)
in C:\Data\Dev\TweakWM6\TweakWM6\Main.cs:line 316
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.Unsa­feNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TweakWM6.Program.Main() in C:\Data\Dev\TweakWM6\TweakWM6\Program.cs:line
17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Any clue for this error ?

Thanks for your time

WBR,
Jeff
mailto:[email protected]
 
J

Jeff Jeff

Thanks Fabien,

But SetValue depends of :

public void SetValue(string name, object value)
Member of Microsoft.WindowsMobile.Rapi.CERegistryKey

and i don't have a third parameters :)

But thanks a lot to try ;)

Regards

Jeff


WBR,
Jeff
mailto:[email protected]
Hi,

If you want to set a Multi String Value, try to add this parameter :
objRegistryKey.SetValue("Order", objListIcones,
RegistryValueKind.MultiString);

BR

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

Me again.

When i try to write the registry with this code :

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

if (objRegistryKey != null)
objRegistryKey.SetValue("Order", objListIcones);
where objListIcones is a string[].

I get the following errors :

System.ArgumentException was unhandled

Message="The output byte buffer is too small to contain the encoded
data,

encoding 'Unicode' fallback
'System.Text.EncoderReplacementFallback'.\r\nParameter

name: bytes"

Source="mscorlib"

ParamName="bytes"

StackTrace:

at System.Text.Encoding.ThrowBytesOverflow()

at System.Text.Encoding.ThrowBytesOverflow(EncoderNLS encoder,
Boolean

nothingEncoded)

at System.Text.UnicodeEncoding.GetBytes(Char* chars, Int32 charCount,

Byte* bytes, Int32 byteCount, EncoderNLS encoder)

at System.Text.UnicodeEncoding.GetBytes(String s, Int32 charIndex,

Int32 charCount, Byte[] bytes, Int32 byteIndex)

at Microsoft.WindowsMobile.Rapi.CERegistryKey.SetValue(String name,

Object value)

at TweakWM6.Main.cmdUpdateIcone_Click(Object sender, EventArgs e)

in C:\Data\Dev\TweakWM6\TweakWM6\Main.cs:line 316

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons

button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&

m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&

m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,

Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager.System.Windows.Form
s.Unsa-feNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32

dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(In
t32

reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32

reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at TweakWM6.Program.Main() in
C:\Data\Dev\TweakWM6\TweakWM6\Program.cs:line

17

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence

assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext,

ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

Any clue for this error ?

Thanks for your time

WBR,
Jeff
mailto:[email protected]
 

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