📄 g.html
字号:
<td WIDTH="20%"><code>lpAppName</code></td>
<td WIDTH="80%">The header of the WINDOWS.INI 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
WIN.INI. </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>
</table>
<b>
<p>Example:</b><br>
<code> 'Read the value for "WallpaperStyle" under the [Desktop]
section of WIN.INI<br>
returned = GetProfileInt("Desktop", "WallpaperStyle", -1)<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="#getprivateprofileint">GetPrivateProfileInt</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="getprofilestring"></a></p>
<h3 ALIGN="center">GetProfileString Function</h3>
<code>
<p align="center">Declare Function GetProfileString Lib "kernel32.dll" Alias
"GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal
lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long</code><br>
GetProfileString reads a string value from the WIN.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 WIN.INI. If it failed
(because the specified file and/or section and/or value doesn't exist), the given default
string is used. This function is basically a watered-down version of
GetPrivateProfileString becuae, unlike that function, GetProfileString only works with
WIN.INI.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpAppName</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>
</table>
<b>
<p>Example:</b><br>
<code> 'This example reads the "Wallpaper" value from the [Desktop]
section of WIN.INI.<br>
Dim buffer As String * 255<br>
x = GetProfileString("Desktop", "Wallpaper", "(not
found)", buffer, 255)<br>
If buffer = "(not found)" Then<br>
Form1.Print "Wallpaper not found."<br>
Else<br>
Form1.Print "The wallpaper is "; Left(buffer, x)<br>
End If</code><br>
<br>
<b>Related Calls:</b> <a HREF="#getprivateprofilestring">GetPrivateProfileString</a>, <a
HREF="w.html#writeprofilestring">WriteProfileString</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="getsavefilename"></a></p>
<h3 ALIGN="center">GetSaveFileName Function</h3>
<code>
<p align="center">Declare Function GetSaveFileName Lib "comdlg32.dll" Alias
"GetSaveFileNameA" (pOPENFILENAME As <a HREF="appa.html#openfilename">OPENFILENAME</a>)
As Long</code><br>
GetSaveFileName uses the standard Windows 95 Save 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
save the file or do anything with it, but merely gives you the filename.<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 save the dialog box. Also holds the
returned filename. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Call the Save 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 = "Save File As" '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>
file.lpstrDefExt = "txt" 'Default file extension<br>
'Only existing paths, warn if already exists, and hide read-only check box<br>
file.flags = OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY<br>
file.lStructSize = Len(file) 'Variable's size<br>
x = GetSaveFileName(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="#getopenfilename">GetOpenFileName</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="getshortpathname"></a></p>
<h3 ALIGN="center">GetShortPathName</h3>
<code>
<p align="center">Declare Function GetShortPathName Lib "kernel32.dll" Alias
"GetShortPathNameA" (ByVal lpszLongPath As String, lpszShortPath As String,
ByVal cchBuffer As Long) As Long</code><br>
GetShortPathName converts a long filename into the old-style 8.3 filenames. Although
Windows 95 allows the use of long filenames, DOS programs, not to mention 16-bit Windows
programs, must use the 8.3 equivalent. For example, the equivalent of ReallyLongFile.txt
could be REALLY~1.TXT. The short filename is stored in the second string variable passed.
The function returns the length of the returned string.<br>
</p>
<table WIDTH="95%" CELLSPACING="0" BORDER="2">
<tr>
<td WIDTH="20%"><code>lpszLongPath</code></td>
<td WIDTH="80%">The complete long path and filename of the filename to convert. </td>
</tr>
<tr>
<td><code>lpszShortPath</code></td>
<td>A fixed-length string which receives the short filename equivalent. </td>
</tr>
<tr>
<td><code>cchBuffer</code></td>
<td>The size of <code>lpszShortPath</code>. </td>
</tr>
</table>
<b>
<p>Example:</b><br>
<code> 'Convert C:\My Documents\richtextone.rtf to its short equivalent<br>
Dim buffer As String * 255<br>
x = GetShortPathName("C:\My Documents\richtextone.rtf", buffer, 255)<br>
Form1.Print Left(buffer, x) 'could be C:\MYDOCU~1\RICHTE~1.RTF</code><br>
<br>
<b>Related Call:</b> <a HREF="#getfullpathname">GetFullPathName</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="getsystemdirectory"></a></p>
<h3 ALIGN="center">GetSystemDirectory Function</h3>
<code>
<p align="center">Declare Function GetSystemDirectory Lib "kernel32.dll" Alias
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long</code><br>
GetSystemDirectory returns the path of Windows's System directory. This is where many
important files for Windows are stored, including the API DLL's! Never assume this is
"C:\Windows\System" 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 system directory and extract it to a variable<br>
Dim buffer As String * 255, syspath As String<br>
n = GetSystemDirectory(buffer, Len(buffer))<br>
syspath = Left(buffer, n)</code><br>
<br>
<b>Related Call:</b> <a HREF="#getwindowsdirectory">GetWindowsDirectory</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="getsystemtime"></a></p>
<h3 ALIGN="center">GetSystemTime Sub</h3>
<code>
<p align="center">Declare Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As <a
HREF="appa.html#systemtime">SYSTEMTIME</a>)</code><br>
GetSystemTime returns you system's time and date, but with an unexpected twist -- it does
so in Coordinated Universal Time (UTC, formerly Greenwich Mean Time (GMT))! 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!
Basically, "system time" is the current time at the Prime Meridian (assuming
your system's clock and time zone are properly set). This would be helpful if your program
needs an absolute reference 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>
'(Since this is UTC time, the date may be different!!!)<br>
Dim systime As SYSTEMTIME<br>
GetSystemTime systime<br>
Debug.Print systime.wMonth; "-"; systime.wDay; "-";
systime.wYear</code><br>
<br>
<b>Related Calls:</b> <a HREF="#getlocaltime">GetLocalTime</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="gettempfilename"></a></p>
<h3 ALIGN="center">GetTempFileName Function</h3>
<code>
<p align="center">Declare Function GetTempFileName Lib "kernel32.dll" Alias
"GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String,
ByVal wUnique As Long, ByVal lpTempFileName As String) As Long</code><br>
GetTempFileName generates a filename for a temporary file and (sort of) optionally creates
it. Temporary files are used to temporarily store data to the hard drive. The full
filename, including the path, is put into <code>lpTempFileName</code>. Yes, you actually
don't need to pass the length of the string like you normally do! The format of the
generated filename is <code>path\xxxuuuu.TMP</code>. path is the path specified. You
should use the default Temp directory, gotten from the GetTempPath() API function. xxx is
a specified three-character string. uuuu is a hexadecimal number that depends on <code>wUnique</code>.
If <code>wUnique</code> is non-zero, uuuu is the rightmost four digits of that number in
hexadecimal, and the file is not created. Note that this will work even if a file with
that name already exists. If it is zero, Windows generates a hex-string for it guaranteed
not to be already used. In this case, Windows also creates the file for you. The file
always has a .TMP extension. The function returns the value used for uuuu, in decimal. The
example demonstrates how to extract the data from <code>lpTempFileName</code>. One final
note: please remember to delete the temporary file when your program is done using it. The
Temp directory is always clogged with outdated files left behind by programs.<br>
</p>
<table WIDTH="95%" BORDER="2" CELLSPACING="0">
<tr>
<td WIDTH="20%"><code>lpszPath</code></td>
<td WIDTH="80%">The path to put the file into. You should use the path gotten from
GetTempPath(). </td>
</tr>
<tr>
<td><code>lpPrefixString</code></td>
<td>The first three characters of this string are used as the first three characters of
the filename. </td>
</tr>
<tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -