Solved

Delphi v1. win95 ini/registry access how to?

Posted on 1998-05-07
2
277 Views
Last Modified: 2010-04-06
I am trying to obtain the name of the current domain server PDC from either the Windows 95 registry (I think I know where it is stored(?)) using Delphi v1. Should this not be possible, is there another way of obtaining this info during runtime - possibly from ini files if Delphi 1 can't read the registry. If this is the case, which ini file(S) do I search. Thanks in advance for any help anyone is able to offer. The idea is that the resulting programme will be required to run in different domain environments and will therefore need to dynamically locate the server name.
0
Comment
Question by:rigsby
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
Comment Utility
Yo,
you could use generic thunks to read the registry. Generic thunking allows you to call a 32bit function fromout a 16bit application. There is a delphi unit on the net called call32.pas which provides generic thunking for Delphi 1. Get it at

http://sunsite.icm.edu.pl/delphi/ftp/freeware/call32nt.zip

and the helpfile at

http://sunsite.icm.edu.pl/delphi/ftp/docs/call32nt.zip

Then declare the function prototypes as
type
  PDWORD = ^LongInt;

var

  RegCloseKey32: function(hKey: HKEY): Longint;

  RegQueryValueEx: function(hKey: LongInt; lpValueName: PChar;
  lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD; id: LongInt): Longint;

  RegOpenKeyEx: function(hKey: LongInt; lpSubKey: PChar;
  ulOptions: LongInt; samDesired: LongInt; var phkResult: LongInt; id: LongInt): Longint;

  id_RegCloseKey32,
  id_RegQueryValueEx,
  id_RegOpenKeyEx     : LongInt;

bind to the functions with

begin
  id_RegCloseKey32 := Declare32('id_RegCloseKey32', 'advapi32.dll', 'i');
  id_RegQueryValueEx := Declare32('RegQueryValueEx', 'advapi32.dll', 'ippppp');
  id_RegOpenKeyEx := Declare32('RegOpenKeyEx', 'advapi32.dll', 'ipiip');
end;

and use the functions like

begin
  aResult := id_RegCloseKey32(aKey, id_RegCloseKey32);
  aResult := RegOpenKeyEx(aKey, aSubKey, aOption, aSAM, aResult, id_RegOpenKeyEx);
  aResult := RegQueryValueEx(aKey, aName, Reserved, aType, aData, aDataLength, id_RegQueryValueEx);
end;


Slash/d003303
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
oops, some typos and one thing I forgot :
the line

aResult := id_RegCloseKey32(aKey, id_RegCloseKey32);

should read

aResult := RegCloseKey32(aKey, id_RegCloseKey32);

and the binding code misses the lines

  @RegCloseKey32 := @Call32;
  @RegOpenKeyEx := @Call32;
  @RegQueryValueEx := @Call32;

Slash/d003303
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

10 Experts available now in Live!

Get 1:1 Help Now