|
You last visited: Today at 18:00
Advertisement
[Question] Überprüfen ob Datei in Benutzung ist?
Discussion on [Question] Überprüfen ob Datei in Benutzung ist? within the AutoIt forum part of the Coders Den category.
08/08/2011, 08:35
|
#1
|
elite*gold: 0
Join Date: Jan 2008
Posts: 539
Received Thanks: 46
|
[Question] Überprüfen ob Datei in Benutzung ist?
Moin,
Gibt es in AutoIT irgendeine Möglichkeit zu überprüfen, ob die Datei 'xyz.xyz' in irgendeinem Programm geöffnet ist ? Habe bisher leider keine guten Lösungen dazu finden können.
MfG
|
|
|
08/08/2011, 09:11
|
#2
|
elite*gold: 1826
Join Date: Mar 2009
Posts: 4,310
Received Thanks: 6,287
|
Code:
private bool IsFileInUse(string fileName)
{
bool inUse = false;
SafeFileHandle fileHandle =
CreateFile(fileName, FileSystemRights.Modify,
FileShare.Write, IntPtr.Zero,
FileMode.OpenOrCreate, FileOptions.None, IntPtr.Zero);
if (fileHandle.IsInvalid)
{
if (Marshal.GetLastWin32Error() ==
ERROR_SHARING_VIOLATION)
{
inUse = true;
}
}
fileHandle.Close();
return inUse;
}
hf beim portieren ^^
|
|
|
08/08/2011, 09:35
|
#3
|
elite*gold: 0
Join Date: Jun 2011
Posts: 30
Received Thanks: 4
|
Hi,
probier mal das:
PHP Code:
;===============================================================================
;
; Function Name: _FileInUse()
; Description: Checks if file is in use
; Syntax.........: _FileInUse($sFilename, $iAccess = 1)
; Parameter(s): $sFilename = File name
; Parameter(s): $iAccess = 0 = GENERIC_READ - other apps can have file open in readonly mode
; $iAccess = 1 = GENERIC_READ|GENERIC_WRITE - exclusive access to file,
; fails if file open in readonly mode by app
; Return Value(s): 1 - file in use (@error contains system error code)
; 0 - file not in use
; -1 dllcall error (@error contains dllcall error code)
; Author: Siao
; Modified rover - added some additional error handling, access mode
; Remarks _WinAPI_CreateFile() WinAPI.au3
;===============================================================================
Func _FileInUse($sFilename, $iAccess = 0)
Local $aRet, $hFile, $iError, $iDA
Local Const $GENERIC_WRITE = 0x40000000
Local Const $GENERIC_READ = 0x80000000
Local Const $FILE_ATTRIBUTE_NORMAL = 0x80
Local Const $OPEN_EXISTING = 3
$iDA = $GENERIC_READ
If BitAND($iAccess, 1) <> 0 Then $iDA = BitOR($GENERIC_READ, $GENERIC_WRITE)
$aRet = DllCall("Kernel32.dll", "hwnd", "CreateFile", _
"str", $sFilename, _ ;lpFileName
"dword", $iDA, _ ;dwDesiredAccess
"dword", 0x00000000, _ ;dwShareMode = DO NOT SHARE
"dword", 0x00000000, _ ;lpSecurityAttributes = NULL
"dword", $OPEN_EXISTING, _ ;dwCreationDisposition = OPEN_EXISTING
"dword", $FILE_ATTRIBUTE_NORMAL, _ ;dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL
"hwnd", 0) ;hTemplateFile = NULL
$iError = @error
If @error Or IsArray($aRet) = 0 Then Return SetError($iError, 0, -1)
$hFile = $aRet[0]
If $hFile = -1 Then ;INVALID_HANDLE_VALUE = -1
$aRet = DllCall("Kernel32.dll", "int", "GetLastError")
;ERROR_SHARING_VIOLATION = 32 0x20
;The process cannot access the file because it is being used by another process.
If @error Or IsArray($aRet) = 0 Then Return SetError($iError, 0, 1)
Return SetError($aRet[0], 0, 1)
Else
;close file handle
DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hFile)
Return SetError(@error, 0, 0)
EndIf
EndFunc
oder FileOpen und die Errors überprüfen
Edit: bei dll's funktionieren glaube ich beide Methoden nicht.
First Chaos
|
|
|
08/08/2011, 10:00
|
#4
|
elite*gold: 1826
Join Date: Mar 2009
Posts: 4,310
Received Thanks: 6,287
|
bei dlls gibts auch keinen grund das zu prüfen
|
|
|
 |
Similar Threads
|
[Question] Datei erstellen
08/08/2011 - AutoIt - 4 Replies
Henge in nem Script und wollte rein schreiben , dass eine *.exe* auf dem Desktop erstellt wird mit einem bestimmtem script drinne aus dem anderem script (*.exe*)
HILFE :( WIE SCRIPTE ICH DAS ?
|
Benutzung von Hacks etc.
02/04/2011 - 4Story - 9 Replies
Ein Hallöchen erst mal an alle die das hier lesen ...
wie ihr an meiner Beitragszahl liest bin ich neu und hab noch fragen zu den hacks von 4S.
Ich hab es immer so gemacht:
1. WinRar runter laden.
2. Hack runter laden.
3. Öffnen und anklicken
4. in 4Story einsetzen
und nun das problem ... ich schaff es nie, dass der funktioniert ... kann jemand vl. erläutern wie man das so macht mit der Reihenfolge und den Datei, die man dafür benötigt. :confused:
|
Glider Benutzung
03/02/2008 - WoW Bots - 5 Replies
Hallo,
Ich wollte mal fragen wann man sich sicher sein kann das man für die GLider benutzung nich gebannt wird. Ich hab nur ein paar Level mitm Glider gemacht und jemand möchte meinen Acc kaufen doch ich möchte nich das er im nachhinein dafür gebannt wird. Ab wann kann man sich sicher sein das da nix passiert????
MFG
|
All times are GMT +1. The time now is 18:00.
|
|