Marook-Online
* 06.Feb.2012, 14:57 UTC+1
Welcome, Guest. Please login or register.
Username:
Password:

News: Back again Wink
Main Menu
  Navigation
   Downloads
     Tools
     Music Discs
     SMF Mods
     Trainer & Patches
     EgoShare Uploader
   Guestbook
   NoPaste
   User Map
   Gallery
  
   Malware Scan
   Hacker Blacklist
   Find Abusemail
Top Downloads
Support Me !
Help me by donating a small amount!



Advanced search

Google


Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read
10-Dec-2007 03:37
Marook
Administrator
*****
Offline Offline

Joined: 01-Jan-2005
Posts: 224


If your program deletes any files, you should always try to use the SHFileOperation API in order to move the file to the recycle bin. The use has an option to restore the file if neccessary !

Code
GeSHi (vbnet):
  1. Private Const FO_DELETE As Integer = 3
  2. Private Const FOF_ALLOWUNDO As Integer = &H40
  3. Private Const FOF_NOCONFIRMATION As Integer = &H10
  4.  
  5. Private Structure SHFILEOPSTRUCT
  6.    Dim hWnd As IntPtr
  7.    Dim wFunc As Integer
  8.    Dim pFrom As String
  9.    Dim pTo As String
  10.    Dim fFlags As Short
  11.    Dim fAborted As Boolean
  12.    Dim hNameMaps As IntPtr
  13.    Dim sProgress As String
  14. End Structure
  15.  
  16. Private Declare Auto Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer
  17.  
  18. Private Function DeleteToBin(ByVal sFile As String) As Boolean
  19.    Dim SHFileOp As SHFILEOPSTRUCT = New SHFILEOPSTRUCT()
  20.  
  21.    SHFileOp.wFunc = FO_DELETE
  22.    SHFileOp.pFrom = sFile & Chr(0) & Chr(0)
  23.    SHFileOp.fFlags = FOF_ALLOWUNDO Or FOF_NOCONFIRMATION
  24.  
  25.    Try
  26.        If SHFileOperation(SHFileOp) = 0 Then
  27.            Return True
  28.            Exit Function
  29.        End If
  30.    Catch
  31.        Return False
  32.    End Try
  33. End Function
Created by GeSHI 1.0.7.20

Usage :

Code
GeSHi (vbnet):
  1. If DeleteToBin("c:\windows\testfile.exe") = True Then
  2.    MsgBox("File deleted to recycle bin!", MsgBoxStyle.Information, "Done...")
  3. End If
Created by GeSHI 1.0.7.20
Logged
 

Pages: [1]   Go Up
Jump to:  

Theme by webtechnica.net

MHD v2.1 © 2oo8 by Marook
32116 hacking attempts defended!