regex - How can I change SharedSection in registry using C#? -



regex - How can I change SharedSection in registry using C#? -

regarding this stackoverflow entry in registry system\\currentcontrolset\\control\\session manager\\subsystems have alter in value windows > string parameter sharedsection=sharedsection=1024,20480,768 3rd value 768 2048.

what best way via c#?

i tried following:

var mykey = registry.localmachine.opensubkey("system\\currentcontrolset\\control\\session manager\\subsystems").getvalue("windows");

the local variable mykey contains next string:

"c:\\windows\\system32\\csrss.exe objectdirectory=\\windows sharedsection=1024,20480,768 windows=on subsystemtype=windows serverdll=basesrv,1 serverdll=winsrv:userserverdllinitialization,3 serverdll=sxssrv,4 profilecontrol=off maxrequestthreads=32"

do need alter value 768 2048 using regular expressions or there improve way?

for example:

try { updatesharedsection(-1, -1, 2048); } catch(exception e) { //.. } first param maximum size of system-wide heap second param size of each desktop heap third param size of desktop heap associated non-interactive windows station.

...

public void updatesharedsection(int z) { updatesharedsection(-1, -1, z); } public void updatesharedsection(int x, int y, int z) { registrykey key = registry.localmachine.opensubkey("system\\currentcontrolset\\control\\session manager\\subsystems", true); key.setvalue("windows", _sharedsection(x, y, z, key.getvalue("windows").tostring())); } /// <param name="x">the maximum size of system-wide heap (in kilobytes) / -1 default</param> /// <param name="y">the size of each desktop heap / -1 default</param> /// <param name="z"> size of desktop heap associated non-interactive windows station / -1 default</param> /// <param name="raw">raw info line</param> /// <returns></returns> private string _sharedsection(int x, int y, int z, string raw) { func<int, string, string> setval = delegate(int xyz, string def) { homecoming (xyz == -1) ? def : xyz.tostring(); }; homecoming regex.replace(raw, @"sharedsection=(\d+),(\d+),(\d+)", delegate(match m) { homecoming string.format( "sharedsection={0},{1},{2}", setval(x, m.groups[1].value), setval(y, m.groups[2].value), setval(z, m.groups[3].value)); }, regexoptions.ignorecase); }

c# regex registry

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -