|
-
Oct 4th, 2000, 04:04 PM
#1
Thread Starter
New Member
Bonjour,
Ma fiche a trois objets : un drivelistbox , un dirlistbox et un filelistbox. Le filelistbox doit contenir seulement des fichiers temporaires. Le hic c'est que je doit supprimer seulement les fichiers temporaires qui ne sont pas ouvert par le système en cours. Comment peut-on faire cela ? Je procède déjà avec une boucle for qui tourne jusqu'au nombre de fichiers temporaires contenus dans le dossier,
ex: For i = 0 To File_FichTemp.ListCount
Il me reste qu'à trouver un indice qui démontre qu'un fichier est ouvert. Merci! Pomhappy
-
Oct 4th, 2000, 04:30 PM
#2
Voulez vous se coucher avec moi se soir?
That's all the French I know... We're all speaking E N G L I S H here... Why be such an ass and post in French?
Now, try me again... in English please
-
Oct 4th, 2000, 04:37 PM
#3
Monday Morning Lunatic
RobIII - va niquer poulet.
PomHappy - donnez-moi une demi-heure et je faisais une petit solution (je crois!)...ma Francaise ne pas tres bien
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 4th, 2000, 04:53 PM
#4
Oooh, I looooooove the internet, and especially Babelfish. This is what it translated for me:
RobIII **time-out** go niquer chicken.
PomHappy - give me half an hour and I made small a solution (I crois!)... my French woman not very well
So, parksie... I should go **** a chicken? 
Pomhappy / parksie : I didn't mean to be rude... It just annoys me when people even don't try to speak the "same language" as the "rest of us"...
I'm Dutch... I could post in Dutch... But I don't...
-
Oct 4th, 2000, 04:55 PM
#5
For the rest of us:
also by Babelfish:
Hello, My card has three objects: a drivelistbox, a dirlistbox and a filelistbox. The filelistbox must contain only temporary files. The difficulty it is that I must remove only the temporary files which are not opened by the system in progress. How can one do that? I proceed already with a loop for which turns until the number of temporary files contained in the file, ex: For I = 0 To File_FichTemp.ListCount It remains me that to find an index which shows that a file is open. Thank you! Pomhappy
-
Oct 4th, 2000, 05:01 PM
#6
Monday Morning Lunatic
You weren't being rude...(although I was)...I didn't mean, that, by the way (just kidding!).
I think it's good that we have people who speak different languages round here. And I partly agree - they should make some effort to make it in our language!
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 4th, 2000, 05:08 PM
#7
Fanatic Member
I would be PRACTICAL if we all spoke the same language, and it would probably be easier if we all ran the same operating system. Maybe, if we all were the same color, racism wouldn't be an issue.
But honestly, all being the same, wouldn't that be dead boring? And to Roblll:
Why answer the person if you don't know what he/she is saying?
-
Oct 4th, 2000, 05:12 PM
#8
Monday Morning Lunatic
PomHappy - ouvrez-vous la fichier, et si il ne marche pas, la fichier est ouvert.
In English - try and open the file. If it doesn't work, then the file is already open.
HaxSoft - Careful dude...your cynicysm's showing
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 4th, 2000, 07:57 PM
#9
PomHappy, Si vous utilisez un DriveListBox, un DirListBox, et un FileListBox, vous pouvez juste placer la propriété de configuration *.tmp fichiers et la boucle par la liste et effacent tous les fichiers temporaires qui sont là.
ASSUREZ-VOUS que C'CEst un fichier de TMP! Ceci effacera n'importe quoi, même fichiers importants!
Code:
Private Sub Form_Load()
File1.Pattern = "*.tmp"
End Sub
Private Sub Command1_Click()
On Error Resume Next
For i = 0 To File1.ListCount - 1
Kill File1.List(i)
Next i
End Sub
Espérez qui répond à votre question.
-
Oct 4th, 2000, 08:02 PM
#10
Oh ouais, pour découvrir s' il fonctionne...
Code:
'Author: Serge
'Origin: http://forums.vb-world.net/showthrea...threadid=16450
'Purpose: Determine if an app is running
'Version: VB5+
Determine if exe is running
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function Process32First Lib "kernel32" ( _
ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Public Declare Function Process32Next Lib "kernel32" ( _
ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Public Declare Function CloseHandle Lib "Kernel32.dll" _
(ByVal Handle As Long) As Long
Public Declare Function OpenProcess Lib "Kernel32.dll" _
(ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, _
ByVal dwProcId As Long) As Long
Public Declare Function EnumProcesses Lib "psapi.dll" _
(ByRef lpidProcess As Long, ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Public Declare Function GetModuleFileNameExA Lib "psapi.dll" _
(ByVal hProcess As Long, ByVal hModule As Long, _
ByVal strModuleName As String, ByVal nSize As Long) As Long
Public Declare Function EnumProcessModules Lib "psapi.dll" _
(ByVal hProcess As Long, ByRef lphModule As Long, _
ByVal cb As Long, ByRef cbNeeded As Long) As Long
Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" ( _
ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Public Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
Public Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long ' This process
th32DefaultHeapID As Long
th32ModuleID As Long ' Associated exe
cntThreads As Long
th32ParentProcessID As Long ' This process's parent process
pcPriClassBase As Long ' Base priority of process threads
dwFlags As Long
szExeFile As String * 260 ' MAX_PATH
End Type
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long '1 = Windows 95.
'2 = Windows NT
szCSDVersion As String * 128
End Type
Public Const PROCESS_QUERY_INFORMATION = 1024
Public Const PROCESS_VM_READ = 16
Public Const MAX_PATH = 260
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
Public Const SYNCHRONIZE = &H100000
'STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Const TH32CS_SNAPPROCESS = &H2&
Public Const hNull = 0
Public Enum ePlatform
eWin95_98 = 1
eWinNT = 2
End Enum
Public gDBType As String
Public Function IsApplicationRunning(pEXEName As String) As Boolean
On Error Resume Next
Select Case getVersion()
Case eWin95_98
Dim lProc As Long, strName As String
Dim hSnap As Long, proc As PROCESSENTRY32
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If hSnap = hNull Then Exit Function
proc.dwSize = Len(proc)
' Iterate through the processes
lProc = Process32First(hSnap, proc)
Do While lProc
strName = StrZToStr(proc.szExeFile)
If InStr(UCase(strName), UCase(pEXEName)) Then
IsApplicationRunning = True
Exit Function
End If
lProc = Process32Next(hSnap, proc)
Loop
Case eWinNT
Dim cb As Long
Dim cbNeeded As Long
Dim NumElements As Long
Dim lProcessIDs() As Long
Dim cbNeeded2 As Long
Dim lNumElements2 As Long
Dim lModules(1 To 200) As Long
Dim lRet As Long
Dim strModuleName As String
Dim nSize As Long
Dim hProcess As Long
Dim i As Long
'Get the array containing the process id's for each process object
cb = 8
cbNeeded = 96
Do While cb <= cbNeeded
cb = cb * 2
ReDim lProcessIDs(cb / 4) As Long
lRet = EnumProcesses(lProcessIDs(1), cb, cbNeeded)
Loop
NumElements = cbNeeded / 4
For i = 1 To NumElements
'Get a handle to the Process
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION _
Or PROCESS_VM_READ, 0, lProcessIDs(i))
'Got a Process handle
If hProcess <> 0 Then
'Get an array of the module handles for the specified
'process
lRet = EnumProcessModules(hProcess, lModules(1), 200, _
cbNeeded2)
'If the Module Array is retrieved, Get the ModuleFileName
If lRet <> 0 Then
strModuleName = Space(MAX_PATH)
nSize = 500
lRet = GetModuleFileNameExA(hProcess, lModules(1), _
strModuleName, nSize)
strModuleName = Left(strModuleName, lRet)
'Check for the client application running
If InStr(UCase(strModuleName), UCase(pEXEName)) Then
IsApplicationRunning = True
Exit Function
End If
'List1.AddItem Left(strModuleName, lRet)
End If
End If
'Close the handle to the process
lRet = CloseHandle(hProcess)
Next
End Select
End Function
Function StrZToStr(pString As String) As String
StrZToStr = Left$(pString, Len(pString) - 1)
End Function
Public Function getVersion() As ePlatform
Dim osinfo As OSVERSIONINFO
Dim lRetVal As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
lRetVal = GetVersionExA(osinfo)
getVersion = osinfo.dwPlatformId
End Function
'Utilisation:
Private Sub Command1_Click()
On Error Resume Next
For i = 0 To File1.ListCount - 1
If IsApplicationRunning(File1.List(i)) Then
Debug.Print "Running!"
Else
Debug.Print "not running!"
End If
Next i
End Sub
-
Oct 5th, 2000, 08:37 AM
#11
Thread Starter
New Member
Originally posted by PomHappy
Bonjour,
Ma fiche a trois objets : un drivelistbox , un dirlistbox et un filelistbox. Le filelistbox doit contenir seulement des fichiers temporaires. Le hic c'est que je doit supprimer seulement les fichiers temporaires qui ne sont pas ouvert par le système en cours. Comment peut-on faire cela ? Je procède déjà avec une boucle for qui tourne jusqu'au nombre de fichiers temporaires contenus dans le dossier,
ex: For i = 0 To File_FichTemp.ListCount
Il me reste qu'à trouver un indice qui démontre qu'un fichier est ouvert. Merci! Pomhappy
Thanks to you for answering so nicely!
I thought that it will be easier for me to write it in french and people who speak french could answer it. But I'm seeing that it's making a big problem. All Right !
I didn't expect that effect because I just wrote it without a willing to bother anyone.
I don't mean to be rude !
-
Oct 5th, 2000, 09:33 AM
#12
Addicted Member
PomHappy:
(English version further down)
Be inte om ursäkt!
Det är aldrig fel att använda sitt eget språk, bara opraktiskt ibland.
De som inte kan språket får väl gå vidare till nästa post.
Det enda du riskerar är färre svar, men om du vill ta den risken, skriv på franska!
(Jag är ledsen att jag inte skriver *detta* på franska, men jag vill inte förolämpa ditt språk med mina misstag).
Leve skillnaderna!
For those who do not understans Swedish:
Don't apologize!
It's never wrong to use your own language, only a bit unpractical sometimes.
Those who don't understand just have to go to the next post.
The only thing you risk is that you'll get fewer answers, but if you're willing to take the risk, write in French.
(I'm sorry for not writing *this* in French, but I don't want to insult your language with my misstakes).
Long live the differences
Vive les différences!
Pentax (Swede, mostly writing in English)
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|