确定文件是否为可执行(.exe)文件,如果是,则子系统运行这个可执行文件.
#Include <WinAPIEx.au3>
_WinAPI_GetBinaryType ( $sPath )
$sPath | 文件的完整路径. |
成功: | 返回 1 - 文件为可执行文件, |
@extended 标志包含文件为可执行文件类型的 $SCS_* 常数 | |
返回 0 - 不是. | |
失败: | 返回 0,并设置@error标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $Text, $Path = @MyDocumentsDir & '\'
While 1
$Path = FileOpenDialog('Select File', _WinAPI_PathRemoveFileSpec($Path), 'All Files (*.*)', 1 + 2)
If $Path Then
If _WinAPI_GetBinaryType($Path) Then
Switch @extended
Case $SCS_32BIT_BINARY
$Text = ' is 32-bit Windows-based application.'
Case $SCS_64BIT_BINARY
$Text = ' is 64-bit Windows-based application.'
Case $SCS_DOS_BINARY
$Text = ' is MS-DOS朾ased application.'
Case $SCS_OS216_BINARY
$Text = ' is 16-bit OS/2-based application.'
Case $SCS_PIF_BINARY
$Text = ' is PIF file that executes an MS-DOS朾ased application.'
Case $SCS_POSIX_BINARY
$Text = ' is POSIX朾ased application.'
Case $SCS_WOW_BINARY
$Text = ' is 16-bit Windows-based application.'
Case Else
$Text = ' is unknown executable type.'
EndSwitch
Else
$Text = ' is not executable file.'
EndIf
MsgBox(64, '_WinAPI_GetBinaryType()', '"' & _WinAPI_PathStripPath($Path) & '"' & $Text)
Else
ExitLoop
EndIf
WEnd