Solved

Accessing NT4.0 Registry

Posted on 1998-04-20
10
367 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 82
VBA color chart bars 12 78
Run code from text file in vb 1 57
Crystal reports - Formula Field code need assistance with code 17 52
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

867 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

12 Experts available now in Live!

Get 1:1 Help Now