473,378 Members | 1,498 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,378 software developers and data experts.

How to add a DWORD value to the Registry

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
6 16777
"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
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
* "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
"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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Lee K | last post by:
This is not strictly a C++ issue but if anyone will know the answer its you guys! I am trying to figure out a date format stored in the registry by a piece of software (I am trying to write...
1
by: ChuckD_Duncan | last post by:
using Microsoft.Win32; RegistryKey key = Registry.LocalMachine; key = key.OpenSubKey("....."); ... key = key.OpenSubKey("PCF", true); double aDoubleValue = 0.25; key.SetValue("testkey",...
1
by: rdavis7408 | last post by:
I have a database that has a form that opens a report using date parameters. I have been using it for six months and last week I began to get the following Error Message: "File sharing lock...
1
by: Dixie | last post by:
Are there any MVPs out there who can produce a registry patch for this. 1. Click Start, click Run, type regedit, and then click OK. 2. Locate and then click the following subkey:...
3
by: Steve Montgomery | last post by:
Does anyone have a sample block of code they can share for checking a DWORD value on a remote network machine's registry? For example, to validate a patch deployment. MSDN has a great sample for...
3
by: Joe Delphi | last post by:
Hi, I want to store non-string values in the registry. I have a few Boolean flags and some integer numbers that I want to store. It appears that the SaveSettings command only handles the...
3
by: Bomber | last post by:
Hi all, I have this code Option Explicit Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long...
0
by: chaitanya15 | last post by:
How can i create a new DWORD value in windows registry using java. Can any one post a sample syntax and explain? I would like to modify the registry values.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.