Solved

Accessing NT4.0 Registry

Posted on 1998-04-20
10
366 Views
Last Modified: 2008-02-01
I am having problems reading values from the NT4.0 registry.  I can write to the reg OK but then cannot read my values, or values already there, in any way.

I am using a win32 api called 'regopenkey' to get the values and this seems to work fine on win95.
0
Comment
Question by:philw
  • 4
  • 3
  • 2
  • +1
10 Comments
 

Expert Comment

by:bwoods
ID: 1425402
It depends on what type of values you are reading/writing and what procedures you are using to do so.  There is no way I can tell you what you are doing wrong without seeing the actual code.
If you would, post back with your code...
Just cut it down to the actual API calls you are using to write and read the data.  There are some issues with NT registry over 95 in practice, but as long as you are careful, the NT registry is just as accessible as 95's.  
0
 

Author Comment

by:philw
ID: 1425403
Here is the code for the whole function.

Public Function GetOrderPrefix95()

    Dim lReturn As Long
    Dim hwndSettings As Long
    Dim lpName As String
    Dim lpcbName As Long
    Dim lpClass As String
    Dim lpcbClass As Long
    Dim lpData As String
    Dim lpcbData As Long
   
    lpcbName = 255
    lpName = Space$(lpcbName)
    lpcbClass = 255
    lpClass = Space$(lpcbClass)
   
    lReturn = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\QPOS\Settings", 0&, KEY_ALL_ACCESS, hwndSettings)
   
    lpcbName = 255
    lpName = Space$(lpcbName)
    lpcbData = 255
    lpData = Space$(lpcbData)
   
    lReturn = RegQueryValueEx(hwndSettings, "Order Prefix", 0&, REG_SZ, lpData, lpcbData)
   
    If lReturn <> ERROR_SUCCESS Then
        gAPIDisplayError lReturn, "GetOrderPrefix95"
    Else
        GetOrderPrefix95 = Left$(lpData, lpcbData - 1)
    End If
   
    lReturn = RegCloseKey(hwndSettings)
   
End Function



0
 
LVL 4

Expert Comment

by:zsi
ID: 1425404
philw,

Are you sure that the code that you are using to write the registry data is putting it where you are expecting it to go?

Could you also post the code that you are using to write the data?

zsi
0
 

Author Comment

by:philw
ID: 1425405
I cannot read any data from the registry not just data I have writen.

0
 

Expert Comment

by:MikeABB
ID: 1425406
There is an excellent code sample in the April issue of VBPJ that makes reading from and writing to the registry a breeze.  If you would like this sample, you can either download it from their web page, or I could send it to you.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:philw
ID: 1425407
I would be greatfull if you would send it to me as a cannot find it vbpj's site
0
 

Expert Comment

by:MikeABB
ID: 1425408
philw,
  Please send me your email address so that I may mail you the zip file.
0
 

Author Comment

by:philw
ID: 1425409
My E-Mail address is philw@gordian-pc.co.uk
0
 

Expert Comment

by:bwoods
ID: 1425410
Philw,
  Sorry it took me so long to get back, but it looks like they've
got you taken care of in the interim.  One suggestion... If you can't read anything at all out of the registry, then it's probable that your error is early on - most likely when you first try to open the key.  Check the return value of every registry operation.  This has two purposes, the first being that you will know exactly where your calls go bad, and the second being that you want to be extremely careful with your customers' registry's.  If you don't make sure that each and every registry call is successful, you could think you are writing to one key, when in fact you are writing to another, totally destroying their registry.  It's not the best way to get repeat business!
Good luck.  Let us know if you just can't get it...
0
 

Accepted Solution

by:
MikeABB earned 100 total points
ID: 1425411
There is an excellent code sample in the April issue of VBPJ that makes reading from and writing to the registry a breeze. I have sent it to you and I hope that everything works well for you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now