Solved

Delphi v1. win95 ini/registry access how to?

Posted on 1998-05-07
2
306 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
[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
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1342610
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
ID: 1342611
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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