Board index » delphi » Win 95 API

Win 95 API

Hello!
Can you tell me, how to use the function "Openregkey" or any other
win95 API function or where to get a book, faq,...??

Robert

 

Re:Win 95 API


Quote
Robert fink wrote:

> Hello!
> Can you tell me, how to use the function "Openregkey" or any other
> win95 API function or where to get a book, faq,...??

There is a help file in Borland Delphi, called Win 32 Programmers Reference
(SDK Help File). There You can find info about RegOpenKey and newer Ex function
and all APIs... Same You can find in MSDN Library, but it is costly...

Greetings,
        Raymond

Re:Win 95 API


Robert fink napisa3:

Quote

> Hello!
> Can you tell me, how to use the function "Openregkey" or any other
> win95 API function or where to get a book, faq,...??

// I have written some instructions for You about using API Registry...

uses
        System;  // please be sure to add System unit in your uses clause

procedure OpenOrCreateMyKey;
var
  res, resdisp, del_res: DWORD; // res is the result of the create function,
                                // if the function success the return is
ERROR_SUCCESS
  phkey                : HKEY;
begin

  // two methods, RegCreateKeyEx is safer than OpenKeyEx because if the
specified subkey doesn't exists
  // it will create it for You. These are available simpler methods, too,
called RegOpenKey, RegCreateKey (no Ex)
  // first method
  res := RegOpenKeyEx(HKEY_LOCAL_MACHINE, // handle of open key or predefined
constant
                     'SOFTWARE\BLEBLE',  // name of subkey to open
                     0,                         // reserved, must be zero
                     NIL,               // security access mask
                     phkey              // handle of open key
                     );

  // second method, better
  res := RegCreateKeyEx(HKEY_LOCAL_MACHINE, // predefined constant or handle to
key opened before
                       'SOFTWARE\BLEBLE',  // name of subkey to create, can be
full path, except ROOT Key name
                       0,
                       NIL,
                       REG_OPTION_NON_VOLATILE, // for Windows NT
                       KEY_ALL_ACCESS,          // for Windows NT, You can
leave it and use always this constant
                       NIL,                        // security attributes, requires special
handling, leave it NIL
                       phkey,              // here will be returned handle to newly
opened/created key
                       @resdisp);
{
resdisp - >

Points to a variable that receives one of the following disposition values:

Value   Meaning
REG_CREATED_NEW_KEY     The key did not exist and was created.
REG_OPENED_EXISTING_KEY The key existed and was simply opened without being
created.

Quote
}

  // do something with the key, eg. set/read values
  (...)

  RegCloseKey(phkey);                      // always close no more needed key handle
end;

// Deleting key
// first open something like before, or give predefined constant value
procedure DeleteMyKey;
begin

  del_res := RegDeleteKey(HKEY_LOCAL_MACHINE, 'SOFTWARE\BLEBLE');

end;

//Windows 95: The RegDeleteKey function deletes a key and all its descendents.
//Windows NT: The RegDeleteKey function deletes the specified key. This
function cannot delete a key that has subkeys.

// Documentaion taken from Win32 SDK Help File

{
hKey

Identifies a currently open key or any of the following predefined reserved
handle values:

HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
The key specified by the lpSubKey parameter must be a subkey of the key
identified by hKey.

lpSubKey

Points to a null-terminated string specifying the name of the key to delete.
This parameter cannot be NULL, and the specified key must not have subkeys.

Quote
}

Re:Win 95 API


Quote
Rajmund Rzepecki wrote:

> Robert fink napisa3:

> > Hello!
> > Can you tell me, how to use the function "Openregkey" or any other
> > win95 API function or where to get a book, faq,...??

> // I have written some instructions for You about using API Registry...

> uses
>         System;  // please be sure to add System unit in your uses clause

<SNIP>
I always thought that system was automatically added...At least in TP7.

--
This is my .SIG file.  Enjoy.

Other Threads