Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

creating a registry entry using vb6

Posted on 2003-03-21
7
Medium Priority
?
136 Views
Last Modified: 2010-05-18
I would like to make an entry in HKEY_LOCAL_MACHINE but in a directory (section) I specify "MyCompany\MyPackage" and finally my key "Registration Code"
So that the result would store my "Registration Code" key and value in the following area.
HKEY_LOCAL_MACHINE\MyCompany\MyPackage\

Also, currently I am storing this registration code simply in
HKEY_LOCAL_MACHINE
However, sometimes the value/key gets erased, is there a better place to store this value.  Could this area change by loggin on as someone else or what should I look for?
0
Comment
Question by:screebar
7 Comments
 

Expert Comment

by:Chimo
ID: 8185088
You have to use windows API to read/write anywere you want in the registry.

You can look here to find a list of API you may use and code example that read and write to regitry:
http://www.mvps.org/vbnet/api/_api/apir.htm
0
 

Author Comment

by:screebar
ID: 8185105
I am currently using "RegCreateKey" however it does not create my "subdirectories" or sections below HKEY_LOCAL_MACHINE
-->>>  MyCompany\MyPackage    <<<<<----
That is what is not happening and I cannot find where you can add these.
0
 

Author Comment

by:screebar
ID: 8185106
I am currently using "RegCreateKey" however it does not create my "subdirectories" or sections below HKEY_LOCAL_MACHINE
-->>>  MyCompany\MyPackage    <<<<<----
That is what is not happening and I cannot find where you can add these.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
Chimo earned 200 total points
ID: 8185127
I think you will have to create all key one after the other.  Check if MyCompany exist, if not create it, after do the same with MyPackage and so on for each key.  After that create and set your values.

Public Sub CreateNewKey(sNewKeyName As String, _
                        lPredefinedKey As Long)

  'handle to the new key
   Dim hKey As Long
   Dim result As Long
   
   Call RegCreateKeyEx(lPredefinedKey, _
                       sNewKeyName, 0&, _
                       vbNullString, _
                       REG_OPTION_NON_VOLATILE, _
                       KEY_ALL_ACCESS, 0&, hKey, result)
   
   Call RegCloseKey(hKey)

End Sub
0
 

Author Comment

by:screebar
ID: 8185207
Ok, your previous link looks like there is some info, it is not "spoon feeding me" thought ;).  I will tinker with it tomorrow.  Thanks for the help, once I succeed I will award the points.  Any more "spoon feeding" would be appreciated!
0
 

Expert Comment

by:CleanupPing
ID: 8531846
Hi screebar,
This old question (QID 20559321) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8957413
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Accept Chimo's comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question