473,624 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem writing multiple values to registery

6 New Member
Hi all i am usiing this code to write mulitiple values to registery but it only write one value. could any one help me make this code so that it write multiple values to registery. Currently it only writes nickname but not pwd value!!
I tried this but gave me error :


Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Save the value to the registry
  3.     SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname",+Text7.Text "pwd", strString
  4.  
  5.  

complete code :


Expand|Select|Wrap|Line Numbers
  1.  
  2. Const REG_SZ = 1 ' Unicode nul terminated string
  3. Const REG_BINARY = 3 ' Free form binary
  4. Const HKEY_CURRENT_USER = &H80000001
  5. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  6. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  7. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
  8. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  9. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
  10. Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
  11.  
  12.  
  13.  
  14.  
  15. Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
  16.     Dim Ret
  17.     'Create a new key
  18.     RegCreateKey hKey, strPath, Ret
  19.     'Save a string to the key
  20.     RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
  21.     'close the key
  22.     RegCloseKey Ret
  23. End Sub
  24. Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String)
  25.     Dim Ret
  26.     'Create a new key
  27.     RegCreateKey hKey, strPath, Ret
  28.     'Set the key's value
  29.     RegSetValueEx Ret, strValue, 0, REG_BINARY, CByte(strData), 4
  30.     'close the key
  31.     RegCloseKey Ret
  32. End Sub
  33.  
  34. Private Sub Command14_Click()
  35. 'Dim strString As String
  36.     Dim strString As String
  37.     'Ask for a value
  38.     'strString = InputBox("Please enter a value to be saved as a binary value in the registry.", App.Title)
  39.  
  40.  
  41.     'Save the value to the registry
  42.  
  43.  
  44.     SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname", strString
  45.  
  46. '    SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname",+Text7.Text, "pwd", strString ===> did not work
  47.  
  48.  
  49. End Sub
  50.  
  51.  
Jun 17 '06 #1
1 1728
sashi
1,754 Recognized Expert Top Contributor
hi method,

try this method.. good luck to u my fren..

SaveString HKEY_CURRENT_US ER, "Software\xyz\" ,trim(Text6.Tex t), "nickname",(tri m(Text7.Text), "pwd", strString
Jun 18 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2395
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a hierarchy of algebraic matrices with the addition operation. Thus, I want to have a virtual base class class Matr;
7
2911
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
7
2020
by: Brian Henry | last post by:
I am trying to deploy my VB.NET project with a setup project, and I need to make a reg key entry.. but it also needs to have the path to where the program was installed in they string i placed in the key. How do I go about insertint the installation path (folder only) to the file into the registery on installation of the setup project? Say my project was installe to "c:\program files\myproject" I want to make a registry key string at...
12
3753
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My question is about storing data in a database. Yes I understand that you can link to a database in your program and read and write to the database etc etc. Well, that's all find and dandy but what if the person you're writing the application for...
4
1096
by: a | last post by:
Hi everybody, I have the following setup: - Windows XP Pro with SP2 and all updates installed - Apache 2.054 - PHP 4.4.x (not sure if 1 or 2) My app consists in a html form page which sends its content to a php script. The php script then runs an external process using exec (or passthru). This is where the problems start.
1
2742
by: method | last post by:
I am trying to delete registery key encluding all its subkeys . I want to delete the bold part HKEY_CURRENT_USER, "Software\xyz\foldername\" using an api that i found on the net but i keep geting error!! could any one tell me how to delete entire key with its subkeys ? I changed : Private Sub Command3_Click()
10
6634
by: David Thielen | last post by:
Hi; I am trying to write to the event log using: public const string EVENT_LOG_NAME = "Windward Portal"; if (!EventLog.SourceExists(EVENT_LOG_NAME)) EventLog.CreateEventSource(EVENT_LOG_NAME, "Application"); And I am getting the exception: System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +48
2
1421
by: Jason | last post by:
I've got 20 PC's that I need to change the Description/name field for each NIC, and each PC has three NIC adapters (all PC's are the same Hardware). I know how to change it maunaully in the registery, but I need to do this in C#. I know the path HKLM\System\Controlset001\Control\Network\{4D36E972-........} is the same on all my PC's but the folders beneth that path are all different from PC to PC, and I want to go into each one and...
43
2347
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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
8488
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
7170
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...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2611
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
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
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.