Solved

Delphi v1. win95 ini/registry access how to?

Posted on 1998-05-07
2
299 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Intraweb submit form as a POST request 4 327
how to center only a line in richedit? 4 61
CheckListBox usage 3 71
Firemonkey BASS_Init into a thread 17 32
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

830 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