📄 g.html
字号:
<!DOCTYPE html PUBLIC "-//Netscape Comm. Corp.//DTD HTML//EN">
<html>
<head>
<title>Windows 95 API Dictionary: G</title>
<base TARGET="_self">
<script LANGUAGE="JavaScript">
<!--Cloak
function statbar(txt) {
window.status = txt;
setTimeout("erase()",3000);
}
function erase() {
window.status = "";
}
//Decloak-->
</script>
</head>
<body BGCOLOR="#004000" TEXT="#FFFFFF" LINK="#FFFF00" VLINK="#FF8000" ALINK="#80FF80">
<p><a NAME="top"></a></p>
<h1 ALIGN="center">- G -</h1>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getclipcursor"></a></p>
<h3 ALIGN="center">GetClipCursor Function</h3>
<code>
<p align="center">Declare Function GetClipCursor Lib "user32.dll" (lprc As <a
HREF="appa.html#rect">RECT</a>) As Long</code><br>
GetClipCursor finds the current confinement rectangle of the mouse cursor. The cursor is
confined to move inside this rectangle. Even a SetCursorPos cannot remove the cursor. If
there is no apparent confinement rectangle, it is actually the size of the screen. The
rectangle is put into <code>lprc</code>. You can safely ignore the value returned.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lprc</code></td>
<td WIDTH="80%">Receives the upper-left and lower-right corners of the confinement
rectange. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Print the corners of the confinement rectangle.<br>
Dim r As RECT<br>
x = GetClipCursor(r)<br>
Form1.Print r.Left; r.Top 'upper-left (x,y) pair<br>
Form1.Print r.Right; r.Bottom 'lower-right (x,y) pair</code><br>
<br>
<b>Related Call:</b> <a HREF="c.html#clipcursor">ClipCursor</a><br>
<b>Category:</b> <a HREF="index.html#mouse" REL="Index">Mouse</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getcomputername"></a></p>
<h3 ALIGN="center">GetComputerName Function</h3>
<code>
<p align="center">Declare Function GetComputerName Lib "kernel32.dll" Alias
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long</code><br>
GetComputerName reads the name of the user's computer. I don't know how useful this is,
because I haven't found any part of Windows where this value is actually used. But if you
want to use it, this is the function. It returns an error code you can safely disregard.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpBuffer</code></td>
<td WIDTH="80%">A fixed-length string large enough to hold the returned name. It recieves
the computer name. The name is followed by <code>vbNullChar</code>. </td>
</tr>
<tr>
<td><code>nSize</code></td>
<td>The length in characters of <code>lpBuffer</code>. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the computer's name<br>
Dim compname As String * 255, x As Long<br>
x = GetComputerName(compname, 255)<br>
compname = Trim(compname)<br>
compname = Left(compname, Len(compname) - 1)<br>
Debug.Print compname</code><br>
<br>
<b>Category:</b> <a HREF="index.html#systeminformation" REL="Index">System Information</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getcursorpos"></a></p>
<h3 ALIGN="center">GetCursorPos Function</h3>
<code>
<p align="center">Declare Function GetCursorPos Lib "user32.dll" (ByVal lpPoint
As <a HREF="appa.html#pointapi">POINTAPI</a>) As Long</code><br>
GetCursorPos reads the position of the mouse cursor. The x and y coordinates of the mouse
are returned inside of <code>lpPoint</code>, and the returned value can safely be ignored.<br>
</p>
<table WIDTH="95%" CELLSPACING="0" BORDER="2">
<tr>
<td WIDTH="20%"><code>lpPoint</code></td>
<td WIDTH="80%">Receives the x and y coordinates of the mouse. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Display the coordinates of the mouse<br>
Dim coord As POINTAPI<br>
x = GetCursorPos(coord)<br>
Debug.Print coord.x; coord.y</code><br>
<br>
<b>Related Call:</b> <a HREF="s.html#setcursorpos">SetCursorPos</a><br>
<b>Category:</b> <a HREF="index.html#mouse" REL="Index">Mouse</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getdc"></a></p>
<h3 ALIGN="center">GetDC Function</h3>
<code>
<p align="center">Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long)
As Long</code><br>
GetDC returns the device context (DC) of an object. The variable you give the result to
will be linked to that object's device context, and will change with it. You can get the
device context of many Visual Basic controls by accessing its .hDC property.<br>
</p>
<table WIDTH="95%" CELLSPACING="0" BORDER="2">
<tr>
<td WIDTH="20%"><code>hWnd</code></td>
<td WIDTH="80%">The handle of the object. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'The two statements below will return the same value<br>
Debug.Print Form1.hDC<br>
x = GetDC(Form1.hWnd)<br>
Debug.Print x</code><br>
<br>
<b>Related Call:</b> <a HREF="r.html#releasedc">ReturnDC</a><br>
<b>Catgeory:</b> <a HREF="index.html#devices" REL="Index">Devices</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getdesktopwindow"></a></p>
<h3 ALIGN="center">GetDesktopWindow Function</h3>
<code>
<p align="center">Declare Function GetDesktopWindow Lib "user32.dll" () As Long</code><br>
GetDesktopWindow returns the handle (hWnd) of the desktop window. The desktop window is
the image on your monitor, without the mouse cursor. Use this function to access the
screen image. The variable that receives the result is linked with the desktop window's
handle and changes with it.<br>
<br>
<b>Example:</b><br>
<code> desktophWnd = GetDesktopWindow()</code><br>
<br>
<b>Category:</b> <a HREF="index.html#systeminformation" REL="Index">System Information</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getdiskfreespace"></a></p>
<h3 ALIGN="center">GetDiskFreeSpace Function</h3>
<code>
<p align="center">Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias
"GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As
Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As
Long) As Long</code><br>
GetDiskFreeSpace tells you both the free space and total space on a disk, and more! It
puts four values into the numeric variables you pass to it. A cluster is the actual unit
of storage on a disk drive. A cluster can hold no more than 1 file, but a file can occupy
more than one cluster. A sector is a portion of a cluster. You can get the cluster size in
bytes by <code>lpSectorsPerCluster * lpBytesPerSector</code>. You get the drive's free
space by multiplying the cluster size by <code>lpNumberOfFreeClusters</code>, and the
drive's total space by multiplying the cluster size by <code>lpTotalNumberOfClusters</code>.
You can safely ignore the value returned.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpRootPathName</code></td>
<td WIDTH="80%">The root directory of the drive to get information on, such as c:\ or a:\.
</td>
</tr>
<tr>
<td><code>lpSectorsPerCluster</code></td>
<td>Receives the number of sectors in a cluster on the disk. </td>
</tr>
<tr>
<td><code>lpBytesPerSector</code></td>
<td>Receives the number of bytes in a sector on the disk. </td>
</tr>
<tr>
<td><code>lpNumberOfFreeClusters</code></td>
<td>Receives the number of unused, empty clusters on the disk. </td>
</tr>
<tr>
<td><code>lpTotalNumberOfClusters</code></td>
<td>Receives the total number of clusters, used and unused, on the disk. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Find the free space on the hard drive C:<br>
x = GetDriveFreeSpace("c:\", SectorsPerCluster, BytesPerSector,
FreeClusters, TotalClusters)<br>
Form1.Print "Free space on C:"; SectorsPerCluster * BytesPerSector *
FreeClusters; "bytes"</code><br>
<br>
<b>Category:</b> <a HREF="index.html#fileio" REL="Index">File I/O</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getdrivetype"></a></p>
<h3 ALIGN="center">GetDriveType Function</h3>
<code>
<p align="center">Declare Function GetDriveType Lib "kernel32.dll" Alias
"GetDriveTypeA" (ByVal nDrive As String) As Long</code><br>
GetDriveType reads the type of a disk drive. This could be a fixed (hard) drive, a floppy
drive, a CD-ROM drive, etc. The return value is the drive type. 0 means that the drive
type could not be determined for some reason. 1 means that the specified drive does not
exist. Other return values are one of the <a HREF="appb.html#drivetypeconstants">drive
type constants</a>.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>nDrive</code></td>
<td WIDTH="80%">The root directory of the drive to check, such as <code>c:\</code>. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Check to see what type of drive C: is<br>
x = GetDriveType("c:\")<br>
'x = DRIVE_FIXED, or hard drive</code><br>
<br>
<b>Category:</b> <a HREF="index.html#fileio" REL="Index">File I/O</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getfileattributes"></a></p>
<h3 ALIGN="center">GetFileAttributes Function</h3>
<code>
<p align="center">Declare Function GetFileAttributes Lib "kernel32.dll" Alias
"GetFileAttributesA& (ByVal lpFileName As String) As Long</code><br>
GetFileAttributes returns the attributes of a file or directory. A file's attributes say
if the file or directory is an archive (most files are), hidden, read-only, etc. If
successful, the return value has one or more <a HREF="appb.html#fileattributeflags">file
attribute flags</a> set. If a certain flag, for example read-only, is set, And-ing the
return value and the constant flag value will result in a non-zero value if the flag is
set and 0 if it is not (see the example for details). If the file cannot be found, -1 is
returned.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpFileName</code></td>
<td WIDTH="80%">The full name of the directory or file to check the attributes of. This
means that you must include the path. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Check the attributes of c:\windows\sol.exe (Solitaire)<br>
attribs = GetFileAttributes("C:\Windows\sol.exe")<br>
If (attribs And FILE_ATTRIBUTES_ARCHIVE) <> 0 Then Form1.Print "Archive
"<br>
If (attribs And FILE_ATTRIBUTES_READONLY) <> 0 Then Form1.Print "Read-only
"<br>
'and so on....</code><br>
<br>
<b>Related Call:</b> <a HREF="s.html#setfileattributes">SetFileAttributes</a><br>
<b>Category:</b> <a HREF="index.html#fileio" REL="Index">File I/O</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -