Windows API Guide: EnableWindow Function


Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Byte)

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

FillMemory fills a location in memory with a certain value. The function does this by setting each byte starting at the given memory location to the desired value. The memory location is identified by a pointer to the memory address.

Return Value

FillMemory does not return a value.

Visual Basic-Specific Issues

A pointer to any variable can be automatically generated merely by passing that variable as Destination. However, if either a String or a Long holding the desired memory address is passed, the ByVal keyword must preceed it. See the example below for a demonstration.

Parameters

Destination
A pointer to the location in memory (often the memory address of a variable) to begin filling with a certain value.
Length
The number of memory bytes, beginning with the address identified by Destination, to fill.
Fill
The byte value to set each byte in the desired memory location to.

Example

' This code is licensed according to the terms and conditions listed here. ' Initialize all the elements in an array of bytes to the value 76.  Also ' set each character in a 20-character string to the character "X". Dim bytearray(0 To 9) As Byte  ' array of 10 bytes Dim bytestring As String  ' string to fill Dim c As Integer  ' counter variable ' Fill the memory at bytearray() in order to initialize its members to 76.  Note that, to ' identify the pointer to bytearray()'s memory, it is passed as normal. FillMemory bytearray(0), 10, 76  ' fill 10 bytes to the byte value 76 ' Display the results to verify that it worked. For c = 0 To 9  ' loop through each element   Debug.Print bytearray(c);  ' each value displayed will be 76 Next c ' Now fill a 20-character string with "X" (using its ASCII code).  Note how, in Visual ' Basic, the ByVal keyword must preceed the string in this case. bytestring = Space(20)  ' make the string 20 characters long FillMemory ByVal bytestring, 20, Asc("X")  ' set the contents to a bunch of "X"'s ' Display the results to verify that it worked. Debug.Print bytestring  ' will be twenty X's

See Also

ZeroMemory

Category

Memory

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: July 25, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/f/fillmemory.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net