Solved

Accessing NT4.0 Registry

Posted on 1998-04-20
10
369 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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
 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

828 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