Function FileCreate [VB6]

Iniciado por The Swash, 22 Enero 2010, 17:53 PM

0 Miembros y 1 Visitante están viendo este tema.

The Swash

'Coded By The Swash at 22/01/2010
'Web: http://Infrangelux.sytes.net & www.Indetectables.net
'Function to create file, replace Open,Put,Close
'Thx to BlackZeroX
Option Explicit
Public Function FileCreate(ByVal sPath As String, ByVal sInfo As String) As Long
Dim sObj      As Object
Dim sCreate   As Object

If Len(sInfo) > 0 Then
MsgBox Len(sInfo)
  Set sObj = CreateObject("Scripting.FileSystemObject")
  If Not sObj Is Nothing Then
   Set sCreate = sObj.CreateTextFile(sPath, True)
   sCreate.Write sInfo
   sCreate.Close
  End If
  Set sObj = Nothing
FileCreate = 1
End If

End Function


Uso:

Private Sub Command1_Click()
Dim sFile As String

Open "C:\x.exe" For Binary Access Read As #1
  sFile = String(FileLen("C:\x.exe"), " ")
  Get #1, , sFile
Close #1

If FileCreate("c:\xd.exe", sFile) = 1 Then MsgBox "Done"
 
End Sub


Salu2  :smile: