Solved

Accessing NT4.0 Registry

Posted on 1998-04-20
10
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
Reading the Contents of a Directory In Access VBA 5 89
Looking for VB6 code to read SQL table export it to ascii 8 47
MsgBox 4 71
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

726 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