Skip to content

WriteBinary - cRegistry

Writes a Binary Value into the currently open Key of the Windows Registry

Type: Procedure

Parameters

Parameter Type Description
sValue WString
pValueData Pointer Pointer to the address of the variable to write
iDataLength Integer The number of bytes to write

Syntax

Procedure WriteBinary WString sValue Pointer pValueData Integer iDataLength

Call Example

Send WriteBinary sValue pValueData iDataLength

Description

Use WriteBinary to write a Binary value into the currently open Key. If the value does not exist, it will be created.

When writing binary data, you need to store the data initially into a variable and then pass its address along with its length to the WriteBinary function. To get the memory address of a variable, use the AddressOf global function.

Sample

In this example, a password is written in binary form to the Registry. The binary form merely consists of storing each character's ASCII code, which prevents its value from being human-readable.

Use cRegistry.pkg

Object oRegistry is a cRegistry

    Procedure DoWriteData
        Integer iError
        String sPassword

        Move "LetMeIn" To sPassword

        // Open the Key...
        Get CreateKey "Software\MyCompany\MyProduct" to iError
        If (iError =0) Begin
            Send WriteBinary "Password" (AddressOf(sPassword)) (Length(sPassword))
            Send CloseKey // must close all open Keys
        End
    End_Procedure

End_Object

Send DoWriteData of oRegistry
Col 1 Col 2
Note: This encryption algorithm is provided only to illustrate how to write a binary value - if you want to encrypt data, you should use a more robust system than this.