Friday, September 26, 2008

Win 32 API Sleep

Sleep Function

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Platforms: Win 32s, Win 95/98, Win NT

Sleep pauses program execution for a certain amount of time. This is more accurate than using a do-nothing loop, waiting for a certain amount of time to pass. The function does not return a value.

dwMilliseconds
The number of milliseconds to halt program execution for.

Example:

' Pause the program for 2 seconds, displaying the system
' time before and after the pause.

Debug.Print "The time is "; Time$ ' display the current time
Sleep 2000 ' 2000 milliseconds = 2 seconds to delay
Debug.Print "The time is "; Time$ ' this time will be 2 seconds later

Monday, September 22, 2008

virtual machine (VM)

A virtual machine (VM) is an environment, usually a program or operating system
which does not physically exist but is created within another environment. In this context, a VM is called a "guest" while the environment it runs within is called a "host." Virtual machines are often created to execute an instruction set different than that of the host environment. One host environment can often run multiple VMs at once. Because VMs are separated from the physical resources they use, the host environment is often able to dynamically assign those resources among them.

Friday, September 19, 2008

WIN 32 API -GetPixel

GetPixel Function

Declaration

Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As Long, ByVal nXPos As Long, ByVal nYPos As Long) As Long

Platforms

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

Description & Usage

GetPixel determines the color of a specific pixel on a device. The function finds the RGB value of the pixel which is checked.

Return Value

If an error occured, the function returns &HFFFF. If successful, the function returns the RGB value of the pixel which was checked.

Visual Basic-Specific Issues

None.

Parameters

hdc
A handle to a device context to the device to check a pixel of.
nXPos
The x-coordinate of the pixel to determine the color of.
nYPos
The y-coordinate of the pixel to determine the color of.

Example(VB 6.0)

 Fill all of window Form1 with the color which is located at
' coordinate (75,100)
Dim rgbVal As Long ' RGB color of the pixel


' Determine the color of the pixel on Form1 at (75,100).
rgbVal = GetPixel(Form1.hDC, 75, 100)

Thursday, September 18, 2008

WIN 32 API -SET FILE TIME

SetFileTime Function

Declare Function SetFileTime Lib "kernel32.dll" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Platforms

* Windows 95: Supported.
* Windows 98: Supported.
* Windows NT: Requires Windows NT 3.1 or later.
* Windows 2000: Supported.
* Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

SetFileTime sets the creation, last-accessed, and last-modified (last written-to) dates and times associated with a file. All the times are in UTC time (Coordinated Universal Time, a.k.a. Greenwich Mean Time (GMT)), not in the system's local time. The times actually stored on the system may vary slightly from the times passed to the function because file times are not stored with perfect resolution (for example, seconds data may be ignored).
Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.
Visual Basic-Specific Issues

None.
Parameters

hFile
A handle to the opened file to set the times of. The file must have been opened with at least write-level access.
lpCreationTime
The date and time to set as the file's creation time.
lpLastAccessTime
The date and time to set as the file's last access time.
lpLastWriteTime
The date and time to set as the file's last write-to (modification) time.

Example(VB 6.0)

' Set the modification time of C:\MyApp\test.txt to
' the current system date and time. Leave the other times as they
' were before calling the function.
Dim hFile As Long ' handle to the opened file
Dim ctime As FILETIME ' the time of creation
Dim atime As FILETIME ' the time of last access
Dim mtime As FILETIME ' the time of last modification
Dim retval As Long ' return value

' First, open the file C:\MyApp\test.txt for both read-level and
' write-level access, since we need to do both.
hFile = CreateFile("C:\MyApp\test.txt", GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ, ByVal CLng(0), OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0)
If hFile = -1 Then
Debug.Print "Could not open the file successfully -- aborting."
End ' terminate the program
End If

' Next, get the creation, last-access, and last-modification times.
retval = GetFileTime(hFile, ctime, atime, mtime)

' Get the system time (already in UTC) as a FILETIME structure.
GetSystemTimeAsFileTime mtime
' Set the retrieved creation and access times and the new modification
' time as the file's times.
retval = SetFileTime(hFile, ctime, atime, mtime)

' Close the file to free up resources.
retval = CloseHandle(hFile)

Monday, September 15, 2008

WIN 32 API -BEEP

Beep Function
Declaration
long Beep(DWORD dwFreq,DWORD dwDuration)
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
Beep plays a sound, but its exact behavior varies between platforms. Windows 95/98:
The function always plays the SystemDefault system sound, regardless of the values
passed to the function. Windows NT/2000: The function plays a tone through the
computer's internal speaker at the desired frequency for a specified duration.
Return Value
If an error occured, the function returns 0 (use GetLastError to get the error code). If
successful, the function returns a non-zero value.
Parameters
dwFreq
Windows NT/2000: The frequency, in hertz (Hz), of the tone to play. Windows
95/98: Ignored.
dwDuration
Windows NT/2000: The duration, in milliseconds, to play the desired tone.
Windows 95/98: Ignored.
Example(C)
// Attempt to play a note at 800 Hz for 2 seconds. This will only
// behave this way on Windows NT/2000; users of Windows 95/98 will only
hear the
// default sound.
long retval; // return value
retval=Beep(800,2000); // ideally, an 800 Hz tone for 2 seconds

WIN 32 API -ANGLE ARC

AngleArc Function
Declaration

long AngleArc(HDC hdc,long x,long y,long dwRadius,float eStartAngle,float eSweepAngle);

Platforms
· Windows 95: Not Supported
· Windows 98: Not Supported
· Windows NT: Requires Windows NT 3.1 or greater
· Windows 2000: Supported
· Windows CE: Not Supported
Description & Usage
AngleArc draws a circular arc on a device using the device's current pen. The circle
which the arc lies on is determined by its center and radius. The start and end points of
the arc are determined by angle measures in degrees, measured counterclockwise from
the line parallel to the positive x-axis (i.e., from due right). The arc itself is drawn either
clockwise or counterclockwise to connect the points, depending on the device's settings.
AngleArc also draws a line connecting the device's current point to the beginning of the
arc.
Return Value
If an error occurs, the function returns 0 (call GetLastError to get the error code). If the
function succeeds, the function returns a non-zero value.
Parameters
hdc
A handle to a device context of the device to draw the arc on.
x
The x coordinate of the center of the circle.
y
The y coordinate of the center of the circle.
dwRadius
The radius of the circle.
eStartAngle
The angle (in degrees) identifying the starting point of the arc.
eSweepAngle
The angle (in degrees) identifying the ending point of the arc.
Example (C)
// Draw an arc formed by the upper half of a circle (from 0 to 180'
degrees
// counterclockwise). The circle is centered at (100, 150) and has a
radius
// of 50. The arc is drawn using the solid black stock pen.
// (the value of device handle & the old pen selected)
HDC hdc;HPEN holdpen;
// handle to the black stock pen
HPEN hpen=GetStockObject(BLACK_PEN);
// select the pen
SelectObject(hdc, hpen);
// Make sure arcs are drawn going counterclockwise
SetArcDirection(hdc,AD_COUNTERCLOCKWISE);
// Draw the arc
retval = AngleArc(hdc,100,150,50,0,180);
// Select previous pen to restore the "defaults".
SelectObject(hdc, holdpen);

what is A System

System Is Set Of Components interact each other to achieve a specific goal

Just Answer


JustAnswer.com