📄 g.html
字号:
<td><code>wUnique</code></td>
<td>If nonzero, the last four characters of the filename are this number's hexadecimal
representation, and the file is not created. If zero, the last four characters are
generated by Windows, and the file is created. </td>
</tr>
<tr>
<td><code>lpTempFileName</code></td>
<td>A fixed-length string that receives the path and filename of the temporary file. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Display a randomly generated temporary filename<br>
Dim temppathx As String * 255, tempfilex As String * 255<br>
x = GetTempPath(255, temppath) 'get Windows's Temp directory<br>
temppath = Left(temppathx, x) 'extract useful data from it<br>
x = GetTempFileName(temppath, "API", 0, tempfilex<br>
'**The next line extracts the useful data from the string**<br>
tempfile = Left$(Trim$(tempfilex), Len(Trim$(tempfilex)) - 1)<br>
Form1.Print "Temporary filename is:"<br>
Form1.Print tempfile<br>
'Filename will be in format (path)\API????.TMP<br>
'This file also now exists in that path!</code><br>
<br>
<b>Related Call:</b> <a HREF="#gettemppath">GetTempPath</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">
<p ALIGN="left"><a NAME="gettemppath"></a></p>
<h3 ALIGN="center">GetTempPath Function</h3>
<code>
<p align="center">Declare Function GetTempPath Lib "kernel32.dll" Alias
"GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long</code><br>
GetTempPath finds Windows's default Temp directory. The Temp directory is where temporary
files made by and used by Windows-based programs should put their temporary files. Usually
this will be the \Temp subdirectory under your Windows directory, but not necessarily. The
path of the Temp directory is put into the string passed to the function. The function
returns the length of the information in the string.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>nBufferLength</code></td>
<td WIDTH="80%">The length in characters of <code>lpBuffer</code>. </td>
</tr>
<tr>
<td><code>lpBuffer</code></td>
<td>A fixed-length string that will receive the path of the Temp directory. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Display the Temp directory<br>
Dim tempdir As String * 255 'more than enough room!<br>
x = GetTempPath(255, tempdir) 'get the directory<br>
Form1.Print "The Temp directory is:"<br>
Form1.Print Left(tempdir, x) 'extract useful information</code><br>
<br>
<b>Related Call:</b> <a HREF="#gettempfilename">GetTempFileName</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">
<p ALIGN="left"><a NAME="gettimezoneinformation"></a></p>
<h3 ALIGN="center">GetTimeZoneInformation Function</h3>
<code>
<p align="center">Declare Function GetTimeZoneInformation Lib "kernel32.dll"
(lpTimeZoneInformation As <a HREF="appa.html#time_zone_information">TIME_ZONE_INFORMATION</a>)
As Long</code><br>
GetTimeZoneInformation reads the computer's current time zone settings. Since Windows 95
handles the system clock settings, there is usually no need for your programs to know this
information. The function returns an error code which can safely be ignored.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpTimeZoneInformation</code></td>
<td WIDTH="80%">The variable which receives the information about the time zone. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the name of the standard-time time zone's name<br>
Dim tzi As TIME_ZONE_INFORMATION, c As Integer, x As Long<br>
x = GetTimeZoneInformation(tzi)<br>
For c = 0 To 32<br>
If tzi.StandardName(c) = 0 Then Exit For<br>
Debug.Print Chr$(tzi.StandardName(c));<br>
Next c</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="getversionex"></a></p>
<h3 ALIGN="center">GetVersionEx Function</h3>
<code>
<p align="center">Declare Function GetVersionEx Lib "kernel32.dll" Alias
"GetVersionExA" (lpVersionInformation As <a HREF="appa.html#osversioninfo">OSVERSIONINFO</a>)
As Long</code><br>
GetVersionEx reads information about the version of Windows running the program. This
information includes the strict version number and the platform (3.x running Win32s,
Windows 95, Windows NT). The actual information is put into the variable passed to the
function. You can safely ignore the value returned.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpVersionInformation</code></td>
<td WIDTH="80%">Receives the version information. Set the <code>.dwOSVersionInfoSize</code>
member to the length of the variable, or Len(lpVersionInformation). </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the version number of Windows<br>
Dim os As OSVERSIONINFO<br>
os.dwOSVersionInfoSize = Len(os) 'Set size of variable<br>
x = GetVersionEx(os)<br>
Form1.Print os.dwMajorVersion; "."; os.dwMinorVersion<br>
'For Windows 95, may print 4 . 0</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="getwindowrect"></a></p>
<h3 ALIGN="center">GetWindowRect Function</h3>
<code>
<p align="center">Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As
Long, lpRect As <a HREF="appa.html#rect">RECT</a>) As Long</code><br>
GetWindowRect returns the size and position of a window. This information is stored inside
a RECT variable. The function puts the coordinates of the upper-left and lower-right
corners of the window into the RECT variable. If part of the window is off the screen,
those coordinates will be out of the normal range of the resolution (for example, if the
left side of a window is off the screen, its Left property will be negative). The returned
value can safely be ignored.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>hwnd</code></td>
<td WIDTH="80%">The handle of the window to read the position and width of. </td>
</tr>
<tr>
<td><code>lpRect</code></td>
<td>A RECT variable that will receive the coordinates of the upper-left and lower-right
corners of the window. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Find the width and height of Form1 using the GetWindowRect function<br>
Dim r As RECT<br>
x = GetWindowRect(Form1.hWnd, r)<br>
Form1.Print "Width ="; r.Right - r.Left<br>
Form1.Print "Height ="; r.Bottom - r.Top</code><br>
<br>
<b>Related Call:</b> <a HREF="s.html#setwindowpos">SetWindowPos</a><br>
<b>Category:</b> <a HREF="index.html#windows" REL="Index">Windows</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getwindowsdirectory"></a></p>
<h3 ALIGN="center">GetWindowsDirectory Function</h3>
<code>
<p align="center">Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long</code><br>
GetWindowsDirectory returns the path of the Windows directory. This is where Windows 95
itself is stored, along with the little applets that come with it. Never assume this is
"C:\Windows" because, while the default, it can be changed at installation. The
function returns the length in characters of the result; the string itself is passed to <code>lpBuffer</code>.
<code>lpBuffer</code> must be a fixed-length string.<br>
</p>
<table WIDTH="95%" CELLSPACING="0" BORDER="2">
<tr>
<td WIDTH="20%"><code>lpBuffer</code></td>
<td WIDTH="80%">A fixed-length string which will receive the path. Make sure it is
sufficiently long. </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> 'Get the Windows directory and extract it to a variable<br>
Dim buffer As String * 255, winpath As String<br>
n = GetWindowsDirectory(buffer, Len(buffer))<br>
winpath = Left(buffer, n)</code><br>
<br>
<b>Related Call:</b> <a HREF="#getsystemdirectory">GetSystemDirectory</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">
<p ALIGN="left"><a NAME="getwindowtext"></a></p>
<h3 ALIGN="center">GetWindowText Function</h3>
<code>
<p align="center">Declare Function GetWindowText Lib "user32.dll" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As
Long) As Long</code><br>
GetWindowText reads the .Caption property of a window. While you can easily do this with
any objects in your code just by looking at the .Caption property, this function works
with any window! If you know the handle of any window, even one in another program, you
can read its caption! The function returns the number of meaningful characters in <code>lpString</code>.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>hwnd</code></td>
<td WIDTH="80%">The handle of the window to read the .Caption property of. </td>
</tr>
<tr>
<td><code>lpString</code></td>
<td>A fixed-length string that will receive the .Caption property value. </td>
</tr>
<tr>
<td><code>cch</code></td>
<td>The length in characters of <code>lpString</code>. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the number of characters in the .Caption of Form1<br>
n = GetWindowTextLength(Form1.hWnd)<br>
'Create a string of n+1, to allow for the vbNullChar at the end<br>
buffer = Space$(n + 1)<br>
'Read and display the .Caption property<br>
x = GetWindowText(Form1.hWnd, buffer, n + 1)<br>
Form1.Print Left$(buffer, x)</code><br>
<br>
<b>Related Calls:</b> <a HREF="#getwindowtextlength">GetWindowTextLength</a>, <a
HREF="s.html#setwindowtext">SetWindowText</a><br>
<b>Category:</b> <a HREF="index.html#windows" REL="Index">Windows</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"><a NAME="getwindowtextlength"></a></p>
<h3 ALIGN="center">GetWindowTextLength Function</h3>
<code>
<p align="center">Declare Function GetWindowTextLength Lib "user32.dll" Alias
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long</code><br>
GetWindowTextLength finds the length in characters of a window's .Caption property. This
works with any window, not just ones in your program! This function is used in conjunction
with GetWindowsText. GetWindowsTextLength returns a number greater than or equal to the
length of a window's .Caption property. When you use it, be sure to add 1 to the result
because GetWindowText adds a <code>vbNullChar</code> to the end of the returned string.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>hwnd</code></td>
<td WIDTH="80%">The handle of the window to read the length of the .Caption property of. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the number of characters in the .Caption of Form1<br>
n = GetWindowTextLength(Form1.hWnd)<br>
'Create a string of n+1, to allow for the vbNullChar at the end<br>
buffer = Space$(n + 1)<br>
'Read and display the .Caption property<br>
x = GetWindowText(Form1.hWnd, buffer, n + 1)<br>
Form1.Print Left$(buffer, x)</code><br>
<br>
<b>Related Call:</b> <a HREF="g.html#getwindowtext">GetWindowText</a><br>
<b>Category:</b> <a HREF="index.html#windows" REL="Index">Windows</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>
<hr ALIGN="center" WIDTH="85%" SIZE="5">
<p ALIGN="left"> </p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -