Solved

Delphi v1. win95 ini/registry access how to?

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

631 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