By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,722 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,722 IT Pros & Developers. It's quick & easy.

How to add a DWORD value to the Registry

P: n/a
CMG
I am writing a little code to associate an extention with
my program. And as far as i can see, i need to do the
following:
Public Function associatefile(ByVal
FILE_EXTENTION_TO_ASSOCIATE As String, ByVal
FILE_EXTENTION_DESCRIPTION As String, ByVal EXE_NAME As
String, ByVal DEFAULT_OPEN_COMMAND As String, ByVal
DEFAULT_ICON As String, ByVal ACTION_NAME As String)
Dim RegKey As RegistryKey
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\")
RegKey.SetValue("", FILE_EXTENTION_DESCRIPTION)
RegKey.SetValue("EditFlags", 0)
RegKey.SetValue("AlwaysShowExt", "")
RegKey.SetValue("BrowserFlags", 8)
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\DefaultIcon\")
RegKey.SetValue("", DEFAULT_ICON)
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\shell\")
RegKey.SetValue("", ACTION_NAME)
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\shell\" & ACTION_NAME & "\command\")
RegKey.SetValue("", DEFAULT_OPEN_COMMAND)
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\shell\" & ACTION_NAME
& "\ddeexec\Application\")
RegKey.SetValue("", ACTION_NAME)
RegKey = Registry.ClassesRoot.CreateSubKey
("CMG.ASSOCIATION\shell\" & ACTION_NAME
& "\ddeexec\Topic\")
RegKey.SetValue("", "system")
RegKey = Registry.ClassesRoot.CreateSubKey
("Applications\" & EXE_NAME & "\shell\open\command\")
RegKey.SetValue("", DEFAULT_OPEN_COMMAND)
RegKey = Registry.ClassesRoot.CreateSubKey
(FILE_EXTENTION_TO_ASSOCIATE)
RegKey.SetValue("", "CMG.ASSOCIATION")
End Function

Example how to call it:

CMG.associatefile(".CMGCHECK", "CMG CHECKING
FILE", "CMGCHECK.EXE", """C:\CMGCHECK.EXE"" ""%
1""", "shell32.dll,44", "CHECK CMG DATABASE")

the values 0 and 8 should be dwords, but i just dnno how
to add it as dword... i searched on google and MSDN
without luck. The Object browser also has no data for
DWORD.

Thanx in advance.

N.B.

If the things i do above are not correct, plz tell me
what i am missing...
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"CMG" <vb****@divx-warez.nl> schrieb
RegKey.SetValue("EditFlags", 0)


This line added a DWORD here, so I don't see the problem.
--
Armin

Nov 20 '05 #2

P: n/a
CMG
No it doesn't, it just set's a normal string value, try it, and check ur
registry ;) The registry does not say DWORD, it just says normal value
"Armin Zingler" <az*******@freenet.de> schreef in bericht
news:%2****************@TK2MSFTNGP09.phx.gbl...
"CMG" <vb****@divx-warez.nl> schrieb
RegKey.SetValue("EditFlags", 0)


This line added a DWORD here, so I don't see the problem.
--
Armin

Nov 20 '05 #3

P: n/a
* "CMG" <vb****@divx-warez.nl> scripsit:
RegKey.SetValue("EditFlags", 0)
RegKey.SetValue("BrowserFlags", 8)


The lines above should save the value as DWORD in the registry...

There is a bug which causes the method to save a large number as string
(<http://weblogs.asp.net/tmeston/archive/2003/07/13/10021.aspx>), but I
think that's not the problem.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
"CMG" <vb****@divx-warez.nl> schrieb
No it doesn't, it just set's a normal string value, try it, and
check ur registry ;) The registry does not say DWORD, it just says
normal value

No, it says DWORD. Really, I checked it. To be exact, the type column says
"REG_DWORD".

Here's a screenshot:
EditFlags REG_DWORD 0x00000000 (0)

;-)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
CMG
U were right. I dnno what the fuck went wrong, but when i did it, there were
no dword values, now i fine-tuned my little script, and it works as it
should... For the ppl that might like this (dnno if this is of anny use to
you ppl, but hey, here it is annyway...)

CODE:::

Public Function associatefile(ByVal FILE_EXTENTION_TO_ASSOCIATE As String,
ByVal FILE_EXTENTION_DESCRIPTION As String, ByVal EXE_NAME As String, ByVal
EXE_FILE As String, ByVal DEFAULT_OPEN_COMMAND As String, ByVal DEFAULT_ICON
As String, ByVal ACTION_NAME As String)

Dim RegKey As RegistryKey

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME & "_auto_file\")

RegKey.SetValue("", FILE_EXTENTION_DESCRIPTION)

RegKey.SetValue("EditFlags", 0)

RegKey.SetValue("BrowserFlags", 8)

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME &
"_auto_file\DefaultIcon\")

RegKey.SetValue("", DEFAULT_ICON)

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME & "_auto_file\shell\")

RegKey.SetValue("", "open")

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME &
"_auto_file\shell\open\")

RegKey.SetValue("", ACTION_NAME)

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME &
"_auto_file\shell\open\command\")

RegKey.SetValue("", DEFAULT_OPEN_COMMAND)

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME &
"_auto_file\shell\open\ddeexec\Application\")

RegKey.SetValue("", EXE_NAME)

RegKey = Registry.ClassesRoot.CreateSubKey(EXE_NAME &
"_auto_file\shell\open\ddeexec\Topic\")

RegKey.SetValue("", "system")

RegKey = Registry.ClassesRoot.CreateSubKey("Applications\" & EXE_FILE &
"\shell\open\command\")

RegKey.SetValue("", DEFAULT_OPEN_COMMAND)

RegKey = Registry.ClassesRoot.CreateSubKey(FILE_EXTENTION_T O_ASSOCIATE)

RegKey.SetValue("", EXE_NAME & "_auto_file")

End Function

Example:::

CMG.associatefile(".CMGCHECK", "CMG CHECKING FILE", "CMGGHECK",
"CMGCHECK.EXE", """" & System.Windows.Forms.Application.ExecutablePath & """
""%1""", "shell32.dll,44", "CHECK CMG DATABASE")
"Armin Zingler" <az*******@freenet.de> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
"CMG" <vb****@divx-warez.nl> schrieb
No it doesn't, it just set's a normal string value, try it, and
check ur registry ;) The registry does not say DWORD, it just says
normal value

No, it says DWORD. Really, I checked it. To be exact, the type column says
"REG_DWORD".

Here's a screenshot:
EditFlags REG_DWORD 0x00000000 (0)

;-)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

P: n/a
* "Armin Zingler" <az*******@freenet.de> scripsit:
Here's a screenshot:
EditFlags REG_DWORD 0x00000000 (0)


;-)))

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.