473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Change Type of (Default) Registry Value

I'm Creating new Keys in the registry, but when I do, they always have
a Vaule called (Default) type RG_SZ. I need them to be DWord
dword:00000005

Is there a way to automaticaly make the (Default) a Dword using the
CreateSubKey method?

If not, How can I use the SetValue Method t change the Default from
RG_SZ to DWord?
Nov 16 '05 #1
6 3912

I don't think you can change it's type. Why do you need that anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Setting Cookies to always block for a list of sites (3500+)
The key is
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet
Settings\P3P\History\doubleclick.com]
@=dword:00000005

The only value in these keys is default, and it's a Dword. I can get it all
to work if I use VBS & a .txt file. As VBS allows me to create the subkey
(doubleclick.com) and it's value in one line of code.

Surely if VBS can do this C# can?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

I don't think you can change it's type. Why do you need that anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3

Indeed you're right, you can change the default value type. My
mistake.

Surely if VBS can do this C# can?


Yep

string key = @"Software\Microsoft\Windows\CurrentVersion" +
@"\Internet Settings\P3P\History\doubleclick.com";
using ( RegistryKey k = Registry.CurrentUser.OpenSubKey( key, true ) )
k.SetValue( null, 5 );

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #4
Nice,
Didn't think of stringing them together like that...

Will test tommorow, thanks self teaching myself this
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Indeed you're right, you can change the default value type. My
mistake.

Surely if VBS can do this C# can?


Yep

string key = @"Software\Microsoft\Windows\CurrentVersion" +
@"\Internet Settings\P3P\History\doubleclick.com";
using ( RegistryKey k = Registry.CurrentUser.OpenSubKey( key, true ) )
k.SetValue( null, 5 );

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #5
Mattias,

It still doesn't work..
private string sSubKey =
@"Software\Microsoft\Windows\CurrentVersion\Intern et Settings\P3P\History\";

public void AddBlockCookies()

{

foreach(string x in strBlkCookiesLst)

{
RegistryKey Key = Registry.CurrentUser;

using (Key.CreateSubKey(sSubKey + x +
@"\"))Key.SetValue(null,Convert.ToInt32(00000005)) ;

Key.Close;

}

}

Also tried
using (Key.OpenSubKey(sSubKey + x +
@"\"))Key.SetValue(null,Convert.ToInt32(00000005)) ;

But since I have to create the key first to get this to work the default
value is already created, that's why I went to the first idea.
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Indeed you're right, you can change the default value type. My
mistake.

Surely if VBS can do this C# can?


Yep

string key = @"Software\Microsoft\Windows\CurrentVersion" +
@"\Internet Settings\P3P\History\doubleclick.com";
using ( RegistryKey k = Registry.CurrentUser.OpenSubKey( key, true ) )
k.SetValue( null, 5 );

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #6
When you create the value the type is controlled by the data type of the
value parameter.

int ii=200;
string dd="Dog";

testSettings.SetValue("Animal", dd); //REG_SZ
testSettings.SetValue("ID", ii); //REG_DWORD

Bern

"Yogi_Bear_79" <yo**********@yahoo.com> wrote in message
news:20**************************@posting.google.c om...
I'm Creating new Keys in the registry, but when I do, they always have
a Vaule called (Default) type RG_SZ. I need them to be DWord
dword:00000005

Is there a way to automaticaly make the (Default) a Dword using the
CreateSubKey method?

If not, How can I use the SetValue Method t change the Default from
RG_SZ to DWord?

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Yogi_Bear_79 | last post by:
It still doesn't work.. private string sSubKey = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings\P3P\History\"; public void AddBlockCookies() { foreach(string x in...
1
by: Asaf Ganot | last post by:
Hi, I'm looking for a way to retrieve the date type of a registry value using c#. Since I couldn't find a way to do it with 'Microsoft.Win32', I tried to use the good old API call 'RegEnumValue'...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
5
by: Dave | last post by:
I'd like to create a Registry key value where the Registry key value type is REG_QWORD. I'm using SetValue(name As String, value As Object), and I understand that the object type used in this...
2
by: nikou_70 | last post by:
I have a message in (LegalNoticeText) in winlogin in registry ,when user( in our network) log to windows can see massage that I put in LegalNoticeText , every day I should change this message(it's...
4
by: CDMAPoster | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/f06bd4c45037ef29 Lyle wrote: :Terry Kreft wrote: : :>Suck it and See? :
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
3
by: LordHog | last post by:
Hello, How would I go about finding the default handler, let's say a text file (*.txt), then launch the default handler with the file as an argument? I had found how to launch an external...
1
by: Simon van Beek | last post by:
Dear reader, Under | Tools | Options | the form Options will open. Under the tab you find the field "Default database folder". By opening the form this field shows on my pc I:\. I can't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.