📄 win32funcs.bas
字号:
Attribute VB_Name = "Win32Funcs"
'AwardMod BIOS Manipulation Tool
'Copyright (C) 2001 Josef Hill
'
'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
'
'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Private Declare Function GetSaveFileNameA Lib "comdlg32.dll" (lpofn As tagOFN) As Long
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As tagOFN) As Long
Private Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
Private Type tagOFN
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Function GetShortPath(strFileName As String) As String
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim lngRes As Long, strPath As String
'Create a buffer
strPath = String$(165, 0)
'retrieve the short pathname
lngRes = GetShortPathName(strFileName, strPath, 164)
'remove all unnecessary chr$(0)'s
GetShortPath = Left$(strPath, lngRes)
End Function
Public Function Trim2Path(iStr As String) As String
Trim2Path = Left(iStr, FindSplit(iStr))
End Function
Public Function Trim2File(iStr As String) As String
Trim2File = Right(iStr, Len(iStr) - FindSplit(iStr))
End Function
Private Function FindSplit(iStr As String) As Long
Dim lS As String
For FindSplit = Len(iStr) To 1 Step -1
If Mid(iStr, FindSplit, 1) = "\" Then Exit For
Next FindSplit
End Function
Public Function OpenDialogBox(DefExtension As String, ByVal strCaption As String, ByVal strFilter As String) As String
Const OFNLStructSize = 76 'Required by Win95
'Const OFNCustomFilter = Chr(0) 'We don't really care to save custom filters
Const OFNFilterIndex = 0 'show the first one in the box
'Const OFNFile = Chr(0) 'don't need to initialize the filename edit control
Const OFNMaxFile = 256 'the minimum maximum length
'Const OFNFileName = Chr(0) 'we want the whole deal so this is ignored
Dim ofn As tagOFN
Dim FName As String
Dim lRet As Long
' Fill ofn structure which is passed to wlib_GetFileName
ofn.lStructSize = Len(ofn)
'NT is Picky about this stuff being right
ofn.hwndOwner = fMain.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = strFilter 'passed in from the outside
'ofn.lpstrCustomFilter = Chr(0)
'ofn.nMaxCustFilter 'we arent' using this one
ofn.nFilterIndex = 0
ofn.lpstrFile = String(257, 0)
ofn.nMaxFile = Len(ofn.lpstrFile) - 1
ofn.lpstrFileTitle = ofn.lpstrFile 'the filename without path
ofn.nMaxFileTitle = Len(ofn.lpstrFileTitle) - 1
ofn.lpstrInitialDir = Chr(0) 'just leave it where it starts
ofn.lpstrTitle = strCaption 'import from the program
ofn.Flags = 0
'ofn.nFileOffset
'ofn.nFileExtension
ofn.lpstrDefExt = DefExtension & Chr(0)
'OFN.lCustData
'ofn.lpfnHook
'ofn.lpTemplateName
lRet = GetOpenFileName(ofn)
If lRet = 0 Then
lRet = CommDlgExtendedError
End If
OpenDialogBox = Left(ofn.lpstrFile, InStr(ofn.lpstrFile, Chr(0)) - 1)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -