Hey@all
Ich herausfinden ob eine Datei eine KonsolenAnwendung ist.
Thx4Help
Hey@all
Ich herausfinden ob eine Datei eine KonsolenAnwendung ist.
Thx4Help
Hey@all
Ich herausfinden ob eine Datei eine KonsolenAnwendung ist.Thx4Help
äääh... Welche Datei???
zB. Die Copy.exe aus der System32 oder die cmd.exe selber.
Hab mal schnell was gebastelt, nur kann ich leider Win32 und Win64 nicht unterscheiden.
[autoit]ConsoleWrite(_IsWin32(@SystemDir & "\cmd.exe") & @CR)
ConsoleWrite(_IsWin32(@WindowsDir & "\twunk_32.exe") & @CR)
ConsoleWrite(_IsWin32(@WindowsDir & "\twunk_16.exe") & @CR)
Func _IsWin32($sExePath)
Local $hFile = FileOpen($sExePath, 0)
Local $sFile = FileRead($hFile, 117)
FileClose($hFile)
$sFile = StringTrimLeft($sFile, 78)
;~ ConsoleWrite($sFile & @CR)
If $sFile = "This program cannot be run in DOS mode." Then Return 1 ;Win32 and Win64
If $sFile = "This program requires Microsoft Windows" Then Return 0 ;Win16
EndFunc
Konsolenprogramm und DOS-Programm ist nicht das selbe.
Auch wenn die Kommandozeile von Windows so aussieht wie die alte DOS-Shell - mit DOS hat das nichts zu tun.
64Bit-Programme können genauso Kommandozeilenbasiert sein.
Hier eine Funktion von KaFu von diesem Thread :
Func _GetBinaryType($file)
;http://msdn.microsoft.com/en-us/library/aa364819(VS.85).aspx
;Local Const $ERROR_BAD_EXE_FORMAT = 193
If Not FileExists($file) Then Return SetError(1, 0, 0)
[/autoit] [autoit][/autoit] [autoit]Local $stType = DllStructCreate("dword;")
[/autoit] [autoit][/autoit] [autoit]$aRet = DllCall("kernel32.dll", "hwnd", "GetBinaryTypeW", "wstr", $file, "ptr", DllStructGetPtr($stType))
; http://msdn.microsoft.com/en-us/library/…28VS.85%29.aspx
If $aRet[0] = 0 Then Return "Not an executable file"
#cs
If $aRet[0] = 0 Then
ConsoleWrite($file & @TAB & _WinAPI_GetLastError() & @CRLF)
If _WinAPI_GetLastError() = 193 Then
Return "DLL file"
Else
Return "Not an executable file"
EndIf
EndIf
#ce
; Local Const $SCS_32BIT_BINARY = 0 ; A 32-bit Windows-based application
; Local Const $SCS_DOS_BINARY = 1 ; An MS-DOS – based application
; Local Const $SCS_WOW_BINARY = 2 ; A 16-bit Windows-based application
; Local Const $SCS_PIF_BINARY = 3 ; A PIF file that executes an MS-DOS – based application
; Local Const $SCS_POSIX_BINARY = 4 ; A POSIX – based application
; Local Const $SCS_OS216_BINARY = 5 ; A 16-bit OS/2-based application
; Local Const $SCS_64BIT_BINARY = 6 ; A 64-bit Windows-based application
Switch DllStructGetData($stType, 1)
Case 0
Return "32-bit Windows-based application"
Case 1
Return "MS-DOS – based application"
Case 2
Return "16-bit Windows-based application"
Case 3
Return "PIF file that executes an MS-DOS – based application"
Case 4
Return "POSIX – based application"
Case 5
Return "16-bit OS/2-based application"
Case 6
Return "64-bit Windows-based application"
EndSwitch
EndFunc ;==>_GetBinaryType
Gruß,
UEZ
Super funkey. Genau das brauchte ich .