📄 g.html
字号:
<p ALIGN="left"><a NAME="getfullpathname"></a></p>
<h3 ALIGN="center">GetFullPathName</h3>
<code>
<p align="center">Declare Function GetFullPathName Lib "kernel32.dll" Alias
"GetFullPathNameA" (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> 'Set current directory to C:\Windows\Media<br>
ChDir "\Windows\Media"<br>
'Append the filename ding.wav<br>
Dim buffer As String * 255<br>
x = GetFullPathName("ding.wav", 255, buffer, "")<br>
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 "kernel32.dll" (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,
"local time" 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> 'Print the date in mm-dd-yyyy format.<br>
Dim loctime As SYSTEMTIME<br>
GetLocalTime loctime<br>
Debug.Print loctime.wMonth; "-"; loctime.wDay; "-";
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 "comdlg32.dll" Alias
"GetOpenFileNameA" (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> 'Call the Open File dialog box and read the filename<br>
Dim file As OPENFILENAME, x As Long, filename As String<br>
file.hwndOwner = Form1.hWnd 'Calling form's handle<br>
file.lpstrTitle = "Open File" 'Title bar<br>
'Set the File Type drop-box values<br>
file.lpstrFilter = "Text Files" & vbNullChar &
"*.txt" & vbNullChar & vbNullChar<br>
file.lpstrFile = Space(255) 'Path and file buffer<br>
file.nMaxFile = 255 'Length of buffer<br>
file.lpstrFileTitle = Space(255) 'File name buffer<br>
file.nMaxFileTitle = 255 'Length of buffer<br>
'Only existing files, and hide read-only check box<br>
file.flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY<br>
file.lStructSize = Len(file) 'Variable's size<br>
x = GetOpenFileName(file)<br>
If x = 0 Then Exit Sub 'Abort if user hit Cancel<br>
'Extract the filename<br>
temp = Trim(file.lpstrFile)<br>
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 "user32.dll" (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> 'This will work if button Command1 sits "on" form Form1<br>
Form1.Print GetParent(Command1.hWnd)<br>
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 "kernel32.dll" Alias
"GetPrivateProfileIntA" (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> 'Read the value for "type" under the [keyboard] section of
SYSTEM.INI<br>
'(This example assumes Windows is in the C:\Windows directory)<br>
returned = GetPrivateProfileInt("keyboard", "type", -1,
"C:\Windows\system.ini")<br>
If returned = -1 Then<br>
Form1.Print "Function call failed."<br>
Else<br>
Form1.Print returned<br>
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 "kernel32.dll"
Alias "GetPrivateProfileStringA" (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> 'This example reads the "scrnsave.exe" value from the [boot]
section of SYSTEM.INI.<br>
'(This example assumes the Windows directory is C:\Windows)<br>
Dim buffer As String * 255<br>
x = GetPrivateProfileString("boot", "scrnsave.exe",
"(not found)", buffer, 255, "c:\windows\system.ini")<br>
If buffer = "(not found)" Then<br>
Form1.Print "Screen saver not found."<br>
Else<br>
Form1.Print "The screen saver is "; Left(buffer, x)<br>
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 "kernel32.dll" Alias
"GetProfileIntA" (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 + -