Where can I find REGISTRY.INC ? 
Author Message
 Where can I find REGISTRY.INC ?

Any ideas where?

Couldn't locate on PB site or BB.

Thanks,
Paul



Mon, 02 Sep 2002 03:00:00 GMT  
 Where can I find REGISTRY.INC ?


Quote:
> Any ideas where?

> Couldn't locate on PB site or BB.

It's a file I created for some projects of my own.  Where did you find
reference to it?

Here it is:

'========================================================================
======
'
'  Registry routines for 32-bit PB/DLL
'  Copyright (c) 1997,98 by powerbasic, Inc. All Rights Reserved.
'
'  Note:  Requires WIN32API.INC file
'
'========================================================================
======

%HK = %HKEY_CURRENT_USER   'Class where entries are saved and retrieved

'------------------------------------------------------------------------
------
'
' SaveSetting - Saves or creates an application entry in the Windows
registry.
'
' Syntax:
'   Result = SaveSetting(AppName, Section, Key, Setting)
'
'   SaveSetting AppName, Section, Key, Setting
'
' Where:
'
'  AppName = String expression containing the name of the application.
'  Section = String expression containing the name of the section where
the
'            key setting is being saved.
'  Key     = String expression containing the name of the key setting
being
'            saved.
'  Setting = String expression containing the value that 'key' is being
set
'            to.
'
FUNCTION SaveSetting(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
                     BYVAL Key AS STRING, BYVAL Setting AS STRING) AS
LONG

  LOCAL hKey   AS LONG
  LOCAL Result AS LONG
  LOCAL zText  AS ASCIIZ * 2048

' ** Exit is AppName, Section or Key are null
  IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
    EXIT FUNCTION
  END IF

' ** Create the section
  IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
                    %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
%NULL, _
                    hKey, Result) <> %ERROR_SUCCESS THEN
    EXIT FUNCTION
  END IF

' ** Save the value for the key
  IF LEN(Setting) THEN
    zText = Setting
    RegSetValueEx hKey, Key+CHR$(0), 0, %REG_SZ, zText, LEN(Setting)+1
  ELSE
    RegSetValueEx hKey, Key+CHR$(0), 0, %REG_SZ, BYVAL %NULL, 0
  END IF

' ** Close the key
  RegCloseKey hKey

  FUNCTION = %TRUE

END FUNCTION

'------------------------------------------------------------------------
------
'
' SaveSettingDW - Saves or creates an application entry in the Windows
registry.
'
' Syntax:
'   Result = SaveSettingDW(AppName, Section, Key, Setting)
'
'   SaveSettingDW AppName, Section, Key, Setting
'
' Where:
'
'  AppName = String expression containing the name of the application.
'  Section = String expression containing the name of the section where
the
'            key setting is being saved.
'  Key     = String expression containing the name of the key setting
being
'            saved.
'  Setting = Numeric expression containing the value that 'key' is being
set
'            to.
'
FUNCTION SaveSettingDW(BYVAL AppName AS STRING, BYVAL Section AS STRING,
_
                       BYVAL Key AS STRING, BYVAL Setting AS LONG) AS
LONG

  LOCAL hKey   AS LONG
  LOCAL Result AS LONG

' ** Exit is AppName, Section or Key are null
  IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
    EXIT FUNCTION
  END IF

' ** Create the section
  IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
                    %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
%NULL, _
                    hKey, Result) <> %ERROR_SUCCESS THEN
    EXIT FUNCTION
  END IF

' ** Save the value for the key
  RegSetValueEx hKey, Key+CHR$(0), 0, %REG_DWORD, Setting, 4

' ** Close the key
  RegCloseKey hKey

  FUNCTION = %TRUE

END FUNCTION

'------------------------------------------------------------------------
------
'
' SaveSettingB - Saves or creates an application entry in the Windows
registry.
'
' Syntax:
'   Result = SaveSettingB(AppName, Section, Key, Setting, Length)
'
'   SaveSettingB AppName, Section, Key, Setting, Length
'
' Where:
'
'  AppName = String expression containing the name of the application.
'  Section = String expression containing the name of the section where
the
'            key setting is being saved.
'  Key     = String expression containing the name of the key setting
being
'            saved.
'  Setting = Binary expression containing the value that 'key' is being
set
'            to.
'  Length  = Length of binary data in Setting
'
FUNCTION SaveSettingB(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
                      BYVAL Key AS STRING, ANY, BYVAL Length AS LONG) AS
LONG

  LOCAL hKey     AS LONG
  LOCAL Result   AS LONG
  LOCAL pSetting AS DWORD

' ** Exit is AppName, Section or Key are null
  IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
    EXIT FUNCTION
  END IF

' ** Get a pointer to the setting value
  ! mov EAX, [EBP+20]
  ! mov pSetting, EAX

' ** Create the section
  IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
                    %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
%NULL, _
                    hKey, Result) <> %ERROR_SUCCESS THEN
    EXIT FUNCTION
  END IF

' ** Save the value for the key
  RegSetValueEx hKey, Key+CHR$(0), 0, %REG_BINARY, BYVAL pSetting, Length

' ** Close the key
  RegCloseKey hKey

  FUNCTION = %TRUE

END FUNCTION

'------------------------------------------------------------------------
------
'
' GetSetting - Retrieves application entry in the Windows registry.
'
' Syntax:
'   Value = GetSetting(AppName, Section, Key)
'
' Where:
'
'  AppName = String expression containing the name of the application.
'  Section = String expression containing the name of the section where
the
'            key setting is being saved.
'  Key     = String expression containing the name of the key setting
being
'            saved.
'  Default = Default value if no registry value is found.
'
' Returns:
'
'  Value   = Value from the registry.  If the value is DWORD, use the
CVL()
'            or CVDWD() functions to convert from string to numeric.
'
FUNCTION GetSetting(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
                    BYVAL Key AS STRING, BYVAL Default AS STRING) AS
STRING

  LOCAL hKey    AS LONG
  LOCAL Result  AS LONG
  LOCAL KeyType AS LONG
  LOCAL Buffer  AS STRING * 2048
  LOCAL Size    AS LONG

' ** Exit is AppName, Section or Key are null
  IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
    FUNCTION = Default
    EXIT FUNCTION
  END IF

' ** Open the section
  IF RegOpenKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0,
%KEY_ALL_ACCESS, _
                  hKey) <> %ERROR_SUCCESS THEN
    FUNCTION = Default
    EXIT FUNCTION
  END IF

' ** Get the key value
  Size = SIZEOF(Buffer)
  Result = RegQueryValueEx(hKey, Key+CHR$(0), 0, KeyType, Buffer, Size)

' ** Close the registry
  RegCloseKey hKey

' ** Exit if not successful or nothing there
  IF (Result <> %ERROR_SUCCESS) OR (Size = 0) THEN
    FUNCTION = Default
    EXIT FUNCTION
  END IF

' ** Return the data
  IF KeyType = %REG_SZ THEN
    FUNCTION = LEFT$(Buffer, Size - 1)
  ELSE
    FUNCTION = LEFT$(Buffer, Size)
  END IF

END FUNCTION



Mon, 02 Sep 2002 03:00:00 GMT  
 Where can I find REGISTRY.INC ?
Dave,

There's a reference to it in a webserver on the BB in the Internet Section

Thanks,

Paul


Quote:


> > Any ideas where?

> > Couldn't locate on PB site or BB.

> It's a file I created for some projects of my own.  Where did you find
> reference to it?

> Here it is:

> '========================================================================
> ======
> '
> '  Registry routines for 32-bit PB/DLL
> '  Copyright (c) 1997,98 by PowerBASIC, Inc. All Rights Reserved.
> '
> '  Note:  Requires WIN32API.INC file
> '
> '========================================================================
> ======

> %HK = %HKEY_CURRENT_USER   'Class where entries are saved and retrieved

> '------------------------------------------------------------------------
> ------
> '
> ' SaveSetting - Saves or creates an application entry in the Windows
> registry.
> '
> ' Syntax:
> '   Result = SaveSetting(AppName, Section, Key, Setting)
> '
> '   SaveSetting AppName, Section, Key, Setting
> '
> ' Where:
> '
> '  AppName = String expression containing the name of the application.
> '  Section = String expression containing the name of the section where
> the
> '            key setting is being saved.
> '  Key     = String expression containing the name of the key setting
> being
> '            saved.
> '  Setting = String expression containing the value that 'key' is being
> set
> '            to.
> '
> FUNCTION SaveSetting(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
>                      BYVAL Key AS STRING, BYVAL Setting AS STRING) AS
> LONG

>   LOCAL hKey   AS LONG
>   LOCAL Result AS LONG
>   LOCAL zText  AS ASCIIZ * 2048

> ' ** Exit is AppName, Section or Key are null
>   IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
>     EXIT FUNCTION
>   END IF

> ' ** Create the section
>   IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
>                     %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
> %NULL, _
>                     hKey, Result) <> %ERROR_SUCCESS THEN
>     EXIT FUNCTION
>   END IF

> ' ** Save the value for the key
>   IF LEN(Setting) THEN
>     zText = Setting
>     RegSetValueEx hKey, Key+CHR$(0), 0, %REG_SZ, zText, LEN(Setting)+1
>   ELSE
>     RegSetValueEx hKey, Key+CHR$(0), 0, %REG_SZ, BYVAL %NULL, 0
>   END IF

> ' ** Close the key
>   RegCloseKey hKey

>   FUNCTION = %TRUE

> END FUNCTION

> '------------------------------------------------------------------------
> ------
> '
> ' SaveSettingDW - Saves or creates an application entry in the Windows
> registry.
> '
> ' Syntax:
> '   Result = SaveSettingDW(AppName, Section, Key, Setting)
> '
> '   SaveSettingDW AppName, Section, Key, Setting
> '
> ' Where:
> '
> '  AppName = String expression containing the name of the application.
> '  Section = String expression containing the name of the section where
> the
> '            key setting is being saved.
> '  Key     = String expression containing the name of the key setting
> being
> '            saved.
> '  Setting = Numeric expression containing the value that 'key' is being
> set
> '            to.
> '
> FUNCTION SaveSettingDW(BYVAL AppName AS STRING, BYVAL Section AS STRING,
> _
>                        BYVAL Key AS STRING, BYVAL Setting AS LONG) AS
> LONG

>   LOCAL hKey   AS LONG
>   LOCAL Result AS LONG

> ' ** Exit is AppName, Section or Key are null
>   IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
>     EXIT FUNCTION
>   END IF

> ' ** Create the section
>   IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
>                     %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
> %NULL, _
>                     hKey, Result) <> %ERROR_SUCCESS THEN
>     EXIT FUNCTION
>   END IF

> ' ** Save the value for the key
>   RegSetValueEx hKey, Key+CHR$(0), 0, %REG_DWORD, Setting, 4

> ' ** Close the key
>   RegCloseKey hKey

>   FUNCTION = %TRUE

> END FUNCTION

> '------------------------------------------------------------------------
> ------
> '
> ' SaveSettingB - Saves or creates an application entry in the Windows
> registry.
> '
> ' Syntax:
> '   Result = SaveSettingB(AppName, Section, Key, Setting, Length)
> '
> '   SaveSettingB AppName, Section, Key, Setting, Length
> '
> ' Where:
> '
> '  AppName = String expression containing the name of the application.
> '  Section = String expression containing the name of the section where
> the
> '            key setting is being saved.
> '  Key     = String expression containing the name of the key setting
> being
> '            saved.
> '  Setting = Binary expression containing the value that 'key' is being
> set
> '            to.
> '  Length  = Length of binary data in Setting
> '
> FUNCTION SaveSettingB(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
>                       BYVAL Key AS STRING, ANY, BYVAL Length AS LONG) AS
> LONG

>   LOCAL hKey     AS LONG
>   LOCAL Result   AS LONG
>   LOCAL pSetting AS DWORD

> ' ** Exit is AppName, Section or Key are null
>   IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
>     EXIT FUNCTION
>   END IF

> ' ** Get a pointer to the setting value
>   ! mov EAX, [EBP+20]
>   ! mov pSetting, EAX

> ' ** Create the section
>   IF RegCreateKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0, "", _
>                     %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL
> %NULL, _
>                     hKey, Result) <> %ERROR_SUCCESS THEN
>     EXIT FUNCTION
>   END IF

> ' ** Save the value for the key
>   RegSetValueEx hKey, Key+CHR$(0), 0, %REG_BINARY, BYVAL pSetting, Length

> ' ** Close the key
>   RegCloseKey hKey

>   FUNCTION = %TRUE

> END FUNCTION

> '------------------------------------------------------------------------
> ------
> '
> ' GetSetting - Retrieves application entry in the Windows registry.
> '
> ' Syntax:
> '   Value = GetSetting(AppName, Section, Key)
> '
> ' Where:
> '
> '  AppName = String expression containing the name of the application.
> '  Section = String expression containing the name of the section where
> the
> '            key setting is being saved.
> '  Key     = String expression containing the name of the key setting
> being
> '            saved.
> '  Default = Default value if no registry value is found.
> '
> ' Returns:
> '
> '  Value   = Value from the registry.  If the value is DWORD, use the
> CVL()
> '            or CVDWD() functions to convert from string to numeric.
> '
> FUNCTION GetSetting(BYVAL AppName AS STRING, BYVAL Section AS STRING, _
>                     BYVAL Key AS STRING, BYVAL Default AS STRING) AS
> STRING

>   LOCAL hKey    AS LONG
>   LOCAL Result  AS LONG
>   LOCAL KeyType AS LONG
>   LOCAL Buffer  AS STRING * 2048
>   LOCAL Size    AS LONG

> ' ** Exit is AppName, Section or Key are null
>   IF (LEN(AppName) * LEN(Section) * LEN(Key)) = 0 THEN
>     FUNCTION = Default
>     EXIT FUNCTION
>   END IF

> ' ** Open the section
>   IF RegOpenKeyEx(%HK, "SOFTWARE\"+AppName+"\"+Section, 0,
> %KEY_ALL_ACCESS, _
>                   hKey) <> %ERROR_SUCCESS THEN
>     FUNCTION = Default
>     EXIT FUNCTION
>   END IF

> ' ** Get the key value
>   Size = SIZEOF(Buffer)
>   Result = RegQueryValueEx(hKey, Key+CHR$(0), 0, KeyType, Buffer, Size)

> ' ** Close the registry
>   RegCloseKey hKey

> ' ** Exit if not successful or nothing there
>   IF (Result <> %ERROR_SUCCESS) OR (Size = 0) THEN
>     FUNCTION = Default
>     EXIT FUNCTION
>   END IF

> ' ** Return the data
>   IF KeyType = %REG_SZ THEN
>     FUNCTION = LEFT$(Buffer, Size - 1)
>   ELSE
>     FUNCTION = LEFT$(Buffer, Size)
>   END IF

> END FUNCTION



Tue, 03 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Finding Template Registry

2. File Not Found INC.CLW

3. C55B-compile error can't find ABHTMSUP.INC

4. Need to find Kernel32.inc

5. Types.inc and OSUtils.inc

6. CA Cans VO ?

7. It's not bad canned meat...

8. It's not bad canned meat...

9. It's not bad canned meat...

10. Using CGI module with 'canned queries'

11. It's not bad canned meat...

12. Cannot find the right record using random read in TPS but can find in DBF

 

 
Powered by phpBB® Forum Software