⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g.html

📁 windowsAPI介绍。很详细的
💻 HTML
📖 第 1 页 / 共 4 页
字号:
    <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>&nbsp;&nbsp;'Display a randomly generated temporary filename<br>
&nbsp;&nbsp;Dim temppathx As String * 255, tempfilex As String * 255<br>
&nbsp;&nbsp;x = GetTempPath(255, temppath) 'get Windows's Temp directory<br>
&nbsp;&nbsp;temppath = Left(temppathx, x) 'extract useful data from it<br>
&nbsp;&nbsp;x = GetTempFileName(temppath, &quot;API&quot;, 0, tempfilex<br>
&nbsp;&nbsp;'**The next line extracts the useful data from the string**<br>
&nbsp;&nbsp;tempfile = Left$(Trim$(tempfilex), Len(Trim$(tempfilex)) - 1)<br>
&nbsp;&nbsp;Form1.Print &quot;Temporary filename is:&quot;<br>
&nbsp;&nbsp;Form1.Print tempfile<br>
&nbsp;&nbsp;'Filename will be in format (path)\API????.TMP<br>
&nbsp;&nbsp;'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 &quot;kernel32.dll&quot; Alias 
&quot;GetTempPathA&quot; (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>&nbsp;&nbsp;'Display the Temp directory<br>
&nbsp;&nbsp;Dim tempdir As String * 255 'more than enough room!<br>
&nbsp;&nbsp;x = GetTempPath(255, tempdir) 'get the directory<br>
&nbsp;&nbsp;Form1.Print &quot;The Temp directory is:&quot;<br>
&nbsp;&nbsp;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 &quot;kernel32.dll&quot; 
(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>&nbsp;&nbsp;'Read the name of the standard-time time zone's name<br>
&nbsp;&nbsp;Dim tzi As TIME_ZONE_INFORMATION, c As Integer, x As Long<br>
&nbsp;&nbsp;x = GetTimeZoneInformation(tzi)<br>
&nbsp;&nbsp;For c = 0 To 32<br>
&nbsp;&nbsp;&nbsp;&nbsp;If tzi.StandardName(c) = 0 Then Exit For<br>
&nbsp;&nbsp;&nbsp;&nbsp;Debug.Print Chr$(tzi.StandardName(c));<br>
&nbsp;&nbsp;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 &quot;kernel32.dll&quot; Alias 
&quot;GetVersionExA&quot; (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>&nbsp;&nbsp;'Read the version number of Windows<br>
&nbsp;&nbsp;Dim os As OSVERSIONINFO<br>
&nbsp;&nbsp;os.dwOSVersionInfoSize = Len(os) 'Set size of variable<br>
&nbsp;&nbsp;x = GetVersionEx(os)<br>
&nbsp;&nbsp;Form1.Print os.dwMajorVersion; &quot;.&quot;; os.dwMinorVersion<br>
&nbsp;&nbsp;'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 &quot;user32.dll&quot; (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>&nbsp;&nbsp;'Find the width and height of Form1 using the GetWindowRect function<br>
&nbsp;&nbsp;Dim r As RECT<br>
&nbsp;&nbsp;x = GetWindowRect(Form1.hWnd, r)<br>
&nbsp;&nbsp;Form1.Print &quot;Width =&quot;; r.Right - r.Left<br>
&nbsp;&nbsp;Form1.Print &quot;Height =&quot;; 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 &quot;kernel32.dll&quot; Alias 
&quot;GetWindowsDirectoryA&quot; (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 
&quot;C:\Windows&quot; 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>&nbsp;&nbsp;'Get the Windows directory and extract it to a variable<br>
&nbsp;&nbsp;Dim buffer As String * 255, winpath As String<br>
&nbsp;&nbsp;n = GetWindowsDirectory(buffer, Len(buffer))<br>
&nbsp;&nbsp;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 &quot;user32.dll&quot; Alias 
&quot;GetWindowTextA&quot; (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>&nbsp;&nbsp;'Read the number of characters in the .Caption of Form1<br>
&nbsp;&nbsp;n = GetWindowTextLength(Form1.hWnd)<br>
&nbsp;&nbsp;'Create a string of n+1, to allow for the vbNullChar at the end<br>
&nbsp;&nbsp;buffer = Space$(n + 1)<br>
&nbsp;&nbsp;'Read and display the .Caption property<br>
&nbsp;&nbsp;x = GetWindowText(Form1.hWnd, buffer, n + 1)<br>
&nbsp;&nbsp;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 &quot;user32.dll&quot; Alias 
&quot;GetWindowTextLengthA&quot; (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>&nbsp;&nbsp;'Read the number of characters in the .Caption of Form1<br>
&nbsp;&nbsp;n = GetWindowTextLength(Form1.hWnd)<br>
&nbsp;&nbsp;'Create a string of n+1, to allow for the vbNullChar at the end<br>
&nbsp;&nbsp;buffer = Space$(n + 1)<br>
&nbsp;&nbsp;'Read and display the .Caption property<br>
&nbsp;&nbsp;x = GetWindowText(Form1.hWnd, buffer, n + 1)<br>
&nbsp;&nbsp;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 + -