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

📄 g.html

📁 windowsAPI介绍。很详细的
💻 HTML
📖 第 1 页 / 共 4 页
字号:

<p ALIGN="left"><a NAME="getfullpathname"></a></p>

<h3 ALIGN="center">GetFullPathName</h3>
<code>

<p align="center">Declare Function GetFullPathName Lib &quot;kernel32.dll&quot; Alias 
&quot;GetFullPathNameA&quot; (ByVal lpFileName As String, ByVal nBufferLength As Long, 
ByVal lpBuffer As String, ByVal lpFilePart As String) As Long</code><br>
GetFullPathName appends a specified filename to the name of the current directory. For 
example, if you specify the file hello.txt and the current path (a.k.a. current directory) 
is C:\My Documents\Junk, the resulting filename would be C:\My Documents\Junk\hello.txt. 
This string is stored in the variable passed as <code>lpBuffer</code>. The function's 
return value is the length of the returned string.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>
    <td WIDTH="20%"><code>lpFileName</code></td>
    <td WIDTH="80%">The name of the file to append. </td>
  </tr>
  <tr>
    <td><code>nBufferLength</code></td>
    <td>The size of <code>lpBuffer</code>. </td>
  </tr>
  <tr>
    <td><code>lpBuffer</code></td>
    <td>A fixed-length string that receives the combined path and filename. </td>
  </tr>
  <tr>
    <td><code>lpFilePart</code></td>
    <td>??? (appears to have no effect) </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'Set current directory to C:\Windows\Media<br>
&nbsp;&nbsp;ChDir &quot;\Windows\Media&quot;<br>
&nbsp;&nbsp;'Append the filename ding.wav<br>
&nbsp;&nbsp;Dim buffer As String * 255<br>
&nbsp;&nbsp;x = GetFullPathName(&quot;ding.wav&quot;, 255, buffer, &quot;&quot;)<br>
&nbsp;&nbsp;Form1.Print Left(buffer, x) 'should be C:\Windows\Media\ding.wav</code><br>
<br>
<b>Related Call:</b> <a HREF="#getshortpathname">GetShortPathName</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="getlocaltime"></a></p>

<h3 ALIGN="center">GetLocalTime Sub</h3>
<code>

<p align="center">Declare Sub GetLocalTime Lib &quot;kernel32.dll&quot; (lpSystemTime As <a
HREF="appa.html#systemtime">SYSTEMTIME</a>)</code><br>
GetLocalTime returns you system's time and date. It sort of combines the Date$, Time$, and 
Timer functions because both the date and the time (down to the milliseconds) is returned 
by this, already sorted within the passed variable! As far as Windows 95 is concerned, 
&quot;local time&quot; is your system's time.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>
    <td WIDTH="20%"><code>lpSystemTime</code></td>
    <td WIDTH="80%">Receives the computer's date and time in absolute format. </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'Print the date in mm-dd-yyyy format.<br>
&nbsp;&nbsp;Dim loctime As SYSTEMTIME<br>
&nbsp;&nbsp;GetLocalTime loctime<br>
&nbsp;&nbsp;Debug.Print loctime.wMonth; &quot;-&quot;; loctime.wDay; &quot;-&quot;; 
loctime.wYear</code><br>
<br>
<b>Related Call:</b> <a HREF="#getsystemtime">GetSystemTime</a><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="getopenfilename"></a></p>

<h3 ALIGN="center">GetOpenFileName Function</h3>
<code>

<p align="center">Declare Function GetOpenFileName Lib &quot;comdlg32.dll&quot; Alias 
&quot;GetOpenFileNameA&quot; (pOPENFILENAME As <a HREF="appa.html#openfilename">OPENFILENAME</a>) 
As Long</code><br>
GetOpenFileName uses the standard Windows 95 Open File dialog box. While the Common Dialog 
custom control can be used to do this, using the API is quicker, and you don't need the 70 
Kb custom control! You need to set a lot of the parts of pOPENFILENAME for the call to 
work. The function returns 0 if the user hit the Cancel button. Note that this does not 
open the file or do anything with it, but merely gives you the filename(s).<br>
</p>

<table WIDTH="95%" CELLSPACING="0" BORDER="2">
  <tr>
    <td WIDTH="20%"><code>pOPENFILENAME</code></td>
    <td WIDTH="80%">Holds the parameters needed to open the dialog box. Also holds the 
    returned filename(s). </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'Call the Open File dialog box and read the filename<br>
&nbsp;&nbsp;Dim file As OPENFILENAME, x As Long, filename As String<br>
&nbsp;&nbsp;file.hwndOwner = Form1.hWnd 'Calling form's handle<br>
&nbsp;&nbsp;file.lpstrTitle = &quot;Open File&quot; 'Title bar<br>
&nbsp;&nbsp;'Set the File Type drop-box values<br>
&nbsp;&nbsp;file.lpstrFilter = &quot;Text Files&quot; &amp; vbNullChar &amp; 
&quot;*.txt&quot; &amp; vbNullChar &amp; vbNullChar<br>
&nbsp;&nbsp;file.lpstrFile = Space(255) 'Path and file buffer<br>
&nbsp;&nbsp;file.nMaxFile = 255 'Length of buffer<br>
&nbsp;&nbsp;file.lpstrFileTitle = Space(255) 'File name buffer<br>
&nbsp;&nbsp;file.nMaxFileTitle = 255 'Length of buffer<br>
&nbsp;&nbsp;'Only existing files, and hide read-only check box<br>
&nbsp;&nbsp;file.flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY<br>
&nbsp;&nbsp;file.lStructSize = Len(file) 'Variable's size<br>
&nbsp;&nbsp;x = GetOpenFileName(file)<br>
&nbsp;&nbsp;If x = 0 Then Exit Sub 'Abort if user hit Cancel<br>
&nbsp;&nbsp;'Extract the filename<br>
&nbsp;&nbsp;temp = Trim(file.lpstrFile)<br>
&nbsp;&nbsp;filename = Left(temp, Len(temp) - 1)</code><br>
<br>
<b>Related Call:</b> <a HREF="#getsavefilename">GetSaveFileName</a><br>
<b>Category:</b> <a HREF="index.html#commondialog" REL="Index">Common Dialog</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>

<hr ALIGN="center" WIDTH="85%" SIZE="5">

<p ALIGN="left"><a NAME="getparent"></a></p>

<h3 ALIGN="center">GetParent Function</h3>
<code>

<p align="center">Declare Function GetParent Lib &quot;user32.dll&quot; (ByVal hwnd As 
Long) As Long</code><br>
GetParent returns the handle of the parent control of an object. For example, the parent 
of a command button may be the frame control it is in. The parent of that frame might then 
be the form. If successful, the function returns the handle of the parent control. If it 
fails (for example, you try to find the parent of a form), it returns 0.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>
    <td WIDTH="20%"><code>hwnd</code></td>
    <td WIDTH="80%">The handle of the object you want to find the parent of. </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'This will work if button Command1 sits &quot;on&quot; form Form1<br>
&nbsp;&nbsp;Form1.Print GetParent(Command1.hWnd)<br>
&nbsp;&nbsp;Form1.Print Form1.hWnd 'should be the same value</code><br>
<br>
<b>Related Call:</b> <a HREF="s.html#setparent">SetParent</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="getprivateprofileint"></a></p>

<h3 ALIGN="center">GetPrivateProfileInt Function</h3>
<code>

<p align="center">Declare Function GetPrivateProfileInt Lib &quot;kernel32.dll&quot; Alias 
&quot;GetPrivateProfileIntA&quot; (ByVal lpApplicationName As String, ByVal lpKeyName As 
String, ByVal nDefault As Long, ByVal lpFileName As String) As Long</code><br>
GetPrivateProfileInt reads an integer value from any INI file. The parameters you pass to 
the function specify which value to read. If successful, the function returns the value 
read. If the value you try to read does not exist or is a string (as opposed to a number), 
it returns the default value you pass to it.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>
    <td WIDTH="20%"><code>lpApplicationName</code></td>
    <td WIDTH="80%">The header of the INI file section the value is in. The heading is the 
    string in brackets at the top of a section of the file. Do not put the brackets into this 
    string. </td>
  </tr>
  <tr>
    <td><code>lpKeyName</code></td>
    <td>The name of the value to read. This is the string on the left side of the = sign in 
    the INI file. </td>
  </tr>
  <tr>
    <td><code>nDefault</code></td>
    <td>If the function fails to read a valid value, this is the value returned. Make it 
    something that wouldn't be returned if successful, such as -1. </td>
  </tr>
  <tr>
    <td><code>lpFileName</code></td>
    <td>The filename of the INI file to read from. </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'Read the value for &quot;type&quot; under the [keyboard] section of 
SYSTEM.INI<br>
&nbsp;&nbsp;'(This example assumes Windows is in the C:\Windows directory)<br>
&nbsp;&nbsp;returned = GetPrivateProfileInt(&quot;keyboard&quot;, &quot;type&quot;, -1, 
&quot;C:\Windows\system.ini&quot;)<br>
&nbsp;&nbsp;If returned = -1 Then<br>
&nbsp;&nbsp;&nbsp;&nbsp;Form1.Print &quot;Function call failed.&quot;<br>
&nbsp;&nbsp;Else<br>
&nbsp;&nbsp;&nbsp;&nbsp;Form1.Print returned<br>
&nbsp;&nbsp;End If</code><br>
<br>
<b>Related Call:</b> <a HREF="#getprofileint">GetProfileInt</a><br>
<b>Category:</b> <a HREF="index.html#inifiles" REL="Index">INI Files</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>

<hr ALIGN="center" WIDTH="85%" SIZE="5">

<p ALIGN="left"><a NAME="getprivateprofilestring"></a></p>

<h3 ALIGN="center">GetPrivateProfileString Function</h3>
<code>

<p align="center">Declare Function GetPrivateProfileString Lib &quot;kernel32.dll&quot; 
Alias &quot;GetPrivateProfileStringA&quot; (ByVal lpApplicationName As String, ByVal 
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize 
As Long, ByVal lpFileName As String) As Long</code><br>
GetPrivateProfileString reads a string value from any INI file. The parameters you pass to 
it specify which value in particular to read. The function always returns the length in 
characters of the data in the returned string <code>lpReturnedString</code>. If the 
function was successful, this data will be the string data read from the INI file. If it 
failed (because the specified file and/or section and/or value doesn't exist), the given 
default string is used.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>
    <td WIDTH="20%"><code>lpApplicationName</code></td>
    <td WIDTH="80%">The header of the section that the value in the INI file is in. This is 
    the name enclosed in brackets in the INI file. Do not include the brackets with this 
    parameter. </td>
  </tr>
  <tr>
    <td><code>lpKeyName</code></td>
    <td>The name of the value in the specified section of the INI file to read. This is the 
    name on the left side of the = sign. </td>
  </tr>
  <tr>
    <td><code>lpDefault</code></td>
    <td>The string to put into <code>lpReturnedString</code> if the function fails to find the 
    specified value. </td>
  </tr>
  <tr>
    <td><code>lpReturnedString</code></td>
    <td>Pass a fixed-length string as this. The function will put the returned value into it. </td>
  </tr>
  <tr>
    <td><code>nSize</code></td>
    <td>The length in characters of <code>lpReturnedString</code>. </td>
  </tr>
  <tr>
    <td><code>lpFileName</code></td>
    <td>The filename of the INI file to read from. </td>
  </tr>
</table>
<b>

<p>Example:</b><br>
<code>&nbsp;&nbsp;'This example reads the &quot;scrnsave.exe&quot; value from the [boot] 
section of SYSTEM.INI.<br>
&nbsp;&nbsp;'(This example assumes the Windows directory is C:\Windows)<br>
&nbsp;&nbsp;Dim buffer As String * 255<br>
&nbsp;&nbsp;x = GetPrivateProfileString(&quot;boot&quot;, &quot;scrnsave.exe&quot;, 
&quot;(not found)&quot;, buffer, 255, &quot;c:\windows\system.ini&quot;)<br>
&nbsp;&nbsp;If buffer = &quot;(not found)&quot; Then<br>
&nbsp;&nbsp;&nbsp;&nbsp;Form1.Print &quot;Screen saver not found.&quot;<br>
&nbsp;&nbsp;Else<br>
&nbsp;&nbsp;&nbsp;&nbsp;Form1.Print &quot;The screen saver is &quot;; Left(buffer, x)<br>
&nbsp;&nbsp;End If</code><br>
<br>
<b>Related Calls:</b> <a HREF="#getprofilestring">GetProfileString</a>, <a
HREF="w.html#writeprivateprofilestring">WritePrivateProfileString</a><br>
<b>Category:</b> <a HREF="index.html#inifiles" REL="Index">INI Files</a><br>
<a HREF="index.html" REL="Index">返回到索引.</a> </p>

<hr ALIGN="center" WIDTH="85%" SIZE="5">

<p ALIGN="left"><a NAME="getprofileint"></a></p>

<h3 ALIGN="center">GetProfileInt Function</h3>
<code>

<p align="center">Declare Function GetProfileInt Lib &quot;kernel32.dll&quot; Alias 
&quot;GetProfileIntA&quot; (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal 
nDefault As Long) As Long</code><br>
GetProfileInt reads an integer value from the WIN.INI file. The parameters you pass to the 
function specify which value to read. If successful, the function returns the value read. 
If the value you try to read does not exist or is a string (as opposed to a number), it 
returns the default value you pass to it. This is basically a watered-down version of 
GetPrivateProfileInt, because unlike that function, GetProfileInt only works with WIN.INI.<br>
</p>

<table WIDTH="95%" BORDER="2" CELLSPACING="0">
  <tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -