473,657 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3932

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_US ER\Software\Mic rosoft\Windows\ CurrentVersion\ Internet
Settings\P3P\Hi story\doublecli ck.com]
@=dword:0000000 5

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.co m) and it's value in one line of code.

Surely if VBS can do this C# can?

"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:%2******** ********@TK2MSF TNGP10.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\Micr osoft\Windows\C urrentVersion" +
@"\Internet Settings\P3P\Hi story\doublecli ck.com";
using ( RegistryKey k = Registry.Curren tUser.OpenSubKe y( 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.o rg> wrote in message
news:%2******** *******@tk2msft ngp13.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\Micr osoft\Windows\C urrentVersion" +
@"\Internet Settings\P3P\Hi story\doublecli ck.com";
using ( RegistryKey k = Registry.Curren tUser.OpenSubKe y( 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\Micr osoft\Windows\C urrentVersion\I nternet Settings\P3P\Hi story\";

public void AddBlockCookies ()

{

foreach(string x in strBlkCookiesLs t)

{
RegistryKey Key = Registry.Curren tUser;

using (Key.CreateSubK ey(sSubKey + x +
@"\"))Key.SetVa lue(null,Conver t.ToInt32(00000 005));

Key.Close;

}

}

Also tried
using (Key.OpenSubKey (sSubKey + x +
@"\"))Key.SetVa lue(null,Conver t.ToInt32(00000 005));

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.o rg> wrote in message
news:%2******** *******@tk2msft ngp13.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\Micr osoft\Windows\C urrentVersion" +
@"\Internet Settings\P3P\Hi story\doublecli ck.com";
using ( RegistryKey k = Registry.Curren tUser.OpenSubKe y( 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.Se tValue("Animal" , dd); //REG_SZ
testSettings.Se tValue("ID", ii); //REG_DWORD

Bern

"Yogi_Bear_ 79" <yo**********@y ahoo.com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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
388
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 strBlkCookiesLst)
1
5640
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' which gives you the data type as well as other things... After many tries, I managed to call the function without any errors. However, I get the data type, but not the value's name! (I even get the name length, but the string that supose to...
3
3161
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 I find a list of all the types which can be returned? For example, if it is a Word document will it return "document/doc".
5
8505
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 function determines the registry value type, however I cannot find a type eqivilant in vb.net that will create the REG_QWORD type (they keep coming out as REG_SZ, REG_BINARY or REG_DWORD) Does anyone know how I can do this?
2
470
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 message of the day) I write a html form that I could input massage in it ,I want to change the value of the LegalNoticeText with text box in this form, or if you have any other way that I can change the value of the LegalNoticeText?( user allow...
4
2328
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
9664
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 and copyright information (the word "CopyRight" with company name and year) is filled in automatically once a new project is created. However, I have no idea where I can configurate it in my new VB 2008. Thanks for your kindly advice!
3
2542
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 program, but I do not know how I would find the default handler to a file type. Any help is greatly appreciated. Code to launch application: ProcessStartInfo pInfo = new ProcessStartInfo();
1
9615
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 close the form because then the message pups up "MS Office Access can't change the work directory to I:\ " If I change it to D:\ I can close the form but by opening the form again the field is still showing I:\.
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.