Código:
Option Explicit
'---------------------------------------------------------------------------------------
' Function : Suicide
' DateTime : 26.07.2009 12:23AM
' Author : Mi4night
' Mail : mi4night@hotmail.com
'Credits : Counterstrikewi
' Purpose : A Simple Melt function that i ported from delphi,call it on the form unload event.
' Usage : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'
'---------------------------------------------------------------------------------------
Const SW_HIDE = 0
Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Public Function Suicide() As Boolean
Dim FilePath As String * 255
Dim CMD As String * 255
Dim Lng As Long
Suicide = False
If GetModuleFileName(0, FilePath, 256) <> 0 Then
Lng = lstrlen(FilePath)
GetShortPathName FilePath, FilePath, Lng
lstrcpy CMD, "/c del "
lstrcat CMD, FilePath
lstrcat CMD, " >> NUL"
If (GetEnvironmentVariable("ComSpec", FilePath, 256) <> 0) And (ShellExecute(Me.hwnd, vbNullString, FilePath, CMD, 0, SW_HIDE) > 32) Then
Suicide = True
End If
End If
End Function