Autor
|
Tema: [Source] CopyNew VB (Leído 2,284 veces)
|
The Swash
Desconectado
Mensajes: 194
Programmer
|
Gracias a todos por sus comentarios. @ BlackZeroX que mensajes subliminales XD En base a lo que un dia me dijiste.. el comando Kill depende de que el archivo sea normal para poder eliminarlo asi que decidi verificar con GetFileAttributes y eliminar con DeleteFile. Codigo Actualizado:'*************************************************************** '* Coded By BlackZeroX & The Swash Updated 21/01/2010. * '* Function copy using Other method. * '* Web: http://Infrangelux.sytes.net & www.indetectables.Net * '* |-> Pueden Distribuir Este Código siempre y cuando * '* no se eliminen los créditos originales de este código * '* No importando que sea modificado/editado o engrandecido * '* o achicado, si es en base a este código * '*************************************************************** Option Explicit
Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const CREATE_NEW = 1 Const OPEN_EXISTING = 3 Const GENERIC_READ = &H80000000 Const GENERIC_WRITE = &H40000000 Const INVALID_HANDLE_VALUE = -1 Const FILE_ATTRIBUTE_ARCHIVE = &H20 Const FILE_ATTRIBUTE_DIRECTORY = &H10 Const FILE_ATTRIBUTE_HIDDEN = &H2 Const FILE_ATTRIBUTE_NORMAL = &H80 Const FILE_ATTRIBUTE_READONLY = &H1 Const FILE_ATTRIBUTE_SYSTEM = &H4 Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long Private Declare Function FExist Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Public Function CopyNew(OldPath As String, NewPath As String) As Long
Dim hFile As Long Dim vBuffer() As Byte Dim Filesize As Long Dim vReadBytes As Long Dim res As Long Dim sFile As Long If FExist(OldPath) = 0 Then Exit Function If FExist(NewPath) <> 0 Then If GetFileAttributes(NewPath) = INVALID_HANDLE_VALUE Then Exit Function If GetFileAttributes("C:\x.exe") = FILE_ATTRIBUTE_ARCHIVE Then DeleteFile NewPath End If hFile = CreateFile(OldPath, GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, 0, 0) If hFile > 0 Then Filesize = GetFileSize(hFile, 0) ReDim vBuffer(1 To Filesize) res = ReadFile(hFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0&) sFile = CreateFile(NewPath, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, CREATE_NEW, 0, 0) WriteFile sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0& Call CloseHandle(hFile) Call CloseHandle(sFile) End If If FExist(NewPath) <> 0 Then CopyNew = 1
End Function Reprovad0: Private Sub Command1_Click() If CopyNew("C:\x.exe", "C:\cd.exe") = 1 Then MsgBox "File copied" Else MsgBox "File not copied" End If End Sub Scan: File InfoReport generated: 20.1.2010 at 22.51.51 (GMT 1) Filename: Project1.exeFile size: 20480 bytes MD5 hash: dcfa8f35af6857a0d676315c66a68673 SHA1 hash: 4C45C41DC07FCB99212CDE9E805382F6A9A436F8 Detection rate: 0 on 24 Status: CLEANDetectionsa-squared - - Nothing Found!Avira AntiVir - - Nothing Found!Avast - - Nothing Found!AVG - - Nothing Found!BitDefender - - Nothing Found!ClamAV - - Nothing Found!Comodo - - Nothing Found!Dr.Web - - Nothing Found!Ewido - - Nothing Found!F-PROT6 - - Nothing Found!G-Data - - Nothing Found!Ikarus T3 - - Nothing Found!Kaspersky - - Nothing Found!McAfee - - Nothing Found!NOD32 v3 - - Nothing Found!Norman - - Nothing Found!Panda - - Nothing Found!QuickHeal - - Nothing Found!Solo Antivirus - - Nothing Found!Sophos - - Nothing Found!TrendMicro - - Nothing Found!VBA32 - - Nothing Found!VirusBuster - - Nothing Found!ZonerAntivirus - - Nothing Found!Scan report generated by NoVirusThanks.org[/quote]
|
|
|
En línea
|
|
|
|
cobein
|
En mi opinion necesita un poco mas de trabajo la funcion. If FExist(NewPath) <> 0 Then If GetFileAttributes(NewPath) = INVALID_HANDLE_VALUE Then Exit Function If GetFileAttributes("C:\x.exe") = FILE_ATTRIBUTE_ARCHIVE Then DeleteFile NewPath End If
Aca aparenetemente se te quedo algo del codigo de testeo. hFile = CreateFile(OldPath, GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, 0, 0) If hFile > 0 Then Filesize = GetFileSize(hFile, 0) ReDim vBuffer(1 To Filesize) res = ReadFile(hFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0&) sFile = CreateFile(NewPath, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, CREATE_NEW, 0, 0) WriteFile sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0& Call CloseHandle(hFile) Call CloseHandle(sFile) End If If FExist(NewPath) <> 0 Then CopyNew = 1 Esta necesita un poco de organizacion, el segundo handle por ejemplo (archivo de destino) nunca se verifica el valor de retorno y algunas cositas como en vez de verificar que el archivo de destino existe, podrias ver que writefile haya escrito la cantidad de bytes que se leyeron (en mi opinion tiene mas logica) y una cosa mas que podrias hacer es copiar los atributos.
|
|
|
En línea
|
|
|
|
The Swash
Desconectado
Mensajes: 194
Programmer
|
'*************************************************************** '* Coded By BlackZeroX & The Swash Updated 21/01/2010. * '* Function copy using Other method. * '* Web: http://Infrangelux.sytes.net & www.indetectables.Net * '* |-> Pueden Distribuir Este Código siempre y cuando * '* no se eliminen los créditos originales de este código * '* No importando que sea modificado/editado o engrandecido * '* o achicado, si es en base a este código * '*************************************************************** Option Explicit
Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const CREATE_NEW = 1 Const OPEN_EXISTING = 3 Const GENERIC_READ = &H80000000 Const GENERIC_WRITE = &H40000000 Const INVALID_HANDLE_VALUE = -1 Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long Private Declare Function PathFileExistsA Lib "shlwapi.dll" (ByVal pszPath As String) As Long Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Public Function CopyNew(aPath As String, nPath As String) As Long
Dim vBuffer() As Byte Dim Filesize As Long Dim vReadBytes As Long Dim res As Long Dim sFile As Long Dim RetDel As Long If Not PathFileExistsA(aPath) = 0 Then If GetFileAttributes(nPath) = FILE_ATTRIBUTE_ARCHIVE Then RetDel = 1 Call DeleteFile(nPath) If RetDel > 0 Then sFile = CreateFile(aPath, GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, ByVal 0&, ByVal 0&) Filesize = GetFileSize(sFile, 0) ReDim vBuffer(1 To Filesize) res = ReadFile(sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0&) sFile = CreateFile(nPath, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, CREATE_NEW, 0, 0) WriteFile sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0& If Len(res) = Len(sFile) Then SetFileAttributes nPath, GetFileAttributes(aPath) CopyNew = 1 End If Call CloseHandle(sFile) End If End If End Function Uso:Private Sub cmdTest_Click() If CopyNew("C:\z.exe", "C:\xd.exe") = 1 Then MsgBox "done" Else MsgBox "fail" End If End Sub Otro uso:Private Sub cmdTest_Click() MsgBox IIf(CopyNew("C:\z.exe", "C:\xd.exe") = 1,"Done","Fail") End Sub @BlackZeroX Gracias por tus ideas para la optimizacion cada una sirvio! @Cobein es un capo! xD, gracias por tus recomendaciones cada una fue aplicada, el code trabaja en cualquier situacion ^^.
|
|
|
En línea
|
|
|
|
BlackZeroX
Wiki
Desconectado
Mensajes: 3.158
I'Love...!¡.
|
. Sigue estando mal xP El archivo Source JAMAS LO CIERRAS La logica de si existe y borrar esta mal xS, mas enconcreto la linea I f RetDel > 0 ThenAqui esta algo que hice (Aun que ya te lo había enseñado pongo): ' ' //////////////////////////////////////////////////////////////// ' // Autores: BlackZeroX ( Ortega Avila Miguel Angel ) // ' // The Swash ( Idea Principal ) // ' // // ' // Web: http://InfrAngeluX.Sytes.Net/ // ' // // ' // |-> Pueden Distribuir Este Código siempre y cuando // ' // no se eliminen los créditos originales de este código // ' // No importando que sea modificado/editado o engrandecido // ' // o achicado, si es en base a este código // ' // |-> Si usas el codigo para algun fin da los Creditos // ' // repectivos asi seguiremos liberando Source // ' //////////////////////////////////////////////////////////////// Option Explicit ' // Globales Const INVALID_HANDLE_VALUE = -1 ' // Para Archivos y similares Const FILE_ATTRIBUTE_ARCHIVE = &H20 Const FILE_ATTRIBUTE_DIRECTORY = &H10 Const FILE_ATTRIBUTE_HIDDEN = &H2 Const FILE_ATTRIBUTE_NORMAL = &H80 Const FILE_ATTRIBUTE_READONLY = &H1 Const FILE_ATTRIBUTE_SYSTEM = &H4 Const FILE_ATTRIBUTE_TEMPORARY = &H100 ' // Tratadod de Archivos Const FILE_BEGIN = 0 Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const CREATE_NEW = 1 Const OPEN_EXISTING = 3 Const GENERIC_READ = &H80000000 Const GENERIC_WRITE = &H40000000 ' // Declaracion de Apis Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateFileA Lib "kernel32" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long Private Declare Function DeleteFileA Lib "kernel32" (ByVal lpFileName As String) As Long Private Declare Function PathFileExistsA Lib "shlwapi.dll" (ByVal pszPath As String) As Long Private Declare Function GetFileAttributesA Lib "kernel32" (ByVal lpFileName As String) As Long Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long Public Function XCopyFile(ByVal strSource As String, ByVal strDest As String, Optional ByVal ReplaceFile As Boolean = False, Optional CopyAttributes As Boolean = True) As Long Dim FileDestAttributes As Long If GetFileAttributesA(strSource) And FILE_ATTRIBUTE_ARCHIVE Then FileDestAttributes = GetFileAttributesA(strDest) If ReplaceFile And (Not FileDestAttributes = INVALID_HANDLE_VALUE) Then If FileDestAttributes And FILE_ATTRIBUTE_ARCHIVE Then SetFileAttributes strDest, FILE_ATTRIBUTE_NORMAL ' // Por si las Moscas xP FileDestAttributes = DeleteFileA(strDest) End If If Not FileDestAttributes > 0 And ReplaceFile Then Exit Function End If XCopyFile = XWriteFileByte(strDest, XReadFileByte(strSource), , ReplaceFile, True) If XCopyFile And CopyAttributes Then SetFileAttributes strDest, GetFileAttributesA(strSource) End If End Function Public Function XReadFile(strSource As String, Optional ByteIni As Long = 1, Optional LenBuffer As Long = -1) As String On Error Resume Next XReadFile = StrConv(XReadFileByte(strSource, ByteIni, LenBuffer), vbUnicode) End Function Public Function XReadFileByte(strSource As String, Optional ByteIni As Long = 1, Optional LenBuffer As Long = 0) As Byte() Dim hFile As Long Dim vBuffer() As Byte Dim LFilesize As Long Dim vReadBytes As Long Dim ResPointerFile As Long If GetFileAttributesA(strSource) And FILE_ATTRIBUTE_ARCHIVE Then hFile = CreateFileA(strSource, GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, 0, 0) If Not hFile = INVALID_HANDLE_VALUE Then ResPointerFile = 1 If ByteIni > 1 Then ResPointerFile = SetFilePointer(hFile, ByteIni - 1, 0, FILE_BEGIN) End If If ResPointerFile Then LFilesize = GetFileSize(hFile, 0) If LenBuffer > 0 And LenBuffer < LFilesize Then LFilesize = LFilesize - ByteIni + 1 If LenBuffer + ByteIni < LFilesize Then LFilesize = LenBuffer End If End If ReDim vBuffer(LFilesize) If ReadFile(hFile, vBuffer(LBound(vBuffer)), UBound(vBuffer), vReadBytes, ByVal 0&) Then XReadFileByte = vBuffer End If End If Call CloseHandle(hFile) End If End If End Function Public Function XWriteFile(srtSource As String, vDataWrite As String, Optional ByteIni As Long = 1, Optional RemplaceData As Boolean = False, Optional CreateFile As Boolean = True) As Long On Error Resume Next Dim vArray() As Byte vArray = StrConv(vDataWrite, vbFromUnicode) ReDim Preserve vArray(UBound(vArray) + 1) XWriteFile = XWriteFileByte(srtSource, vArray, ByteIni, RemplaceData, CreateFile) End Function Public Function XWriteFileByte(srtSource As String, vDataWrite() As Byte, Optional ByteIni As Long = 1, Optional RemplaceData As Boolean = False, Optional CreateFile As Boolean = True) As Long Dim hFile As Long Dim LDataSize As Long Dim vWriteBytes As Long Dim FileSize As Long If Not ((Not vDataWrite) = -1) Then LDataSize = UBound(vDataWrite) - LBound(vDataWrite) If LDataSize >= 0 And ByteIni > 0 Then If CreateFile And (PathFileExistsA(srtSource) = False) Then hFile = CreateFileA(srtSource, GENERIC_WRITE, FILE_SHARE_WRITE, ByVal 0&, CREATE_NEW, 0, 0) ElseIf GetFileAttributesA(srtSource) And FILE_ATTRIBUTE_ARCHIVE And (RemplaceData Or ByteIni > 0) Then hFile = CreateFileA(srtSource, GENERIC_WRITE, FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0) Else hFile = INVALID_HANDLE_VALUE End If If Not hFile = INVALID_HANDLE_VALUE Then FileSize = GetFileSize(hFile, ByVal 0&) If ByteIni >= FileSize Then ByteIni = FileSize + 1 End If If ByteIni > 1 Then SetFilePointer hFile, ByteIni - 1, 0, FILE_BEGIN End If XWriteFileByte = WriteFile(hFile, vDataWrite(LBound(vDataWrite)), UBound(vDataWrite), vWriteBytes, ByVal 0&) Call CloseHandle(hFile) End If End If End If End Function
Forma de uso: Sub main() Dim Datos As String Dim ResXCopy As Boolean Const StrFile1 As String = "c:\archivox.txt" Const StrFile2 As String = "c:\archivoY.txt" Const MSG As String = "Hola" ResXCopy = XCopyFile(StrFile1, StrFile2, True, True) ' // Copiamos, reemplazamos y pegamos atributos al destino Debug.Print "Copy " & IIf(ResXCopy, "Ok", "Fail") ' // Presentamos Datos = XReadFile(StrFile1) ' // leemos todo el archivo Debug.Print "ReadALlFile " & Datos Datos = XReadFile(StrFile1, , 5) ' // leemos Solo los 5 primeros bytes Debug.Print "ReadALlFile " & Datos Datos = XReadFile(StrFile1, 7) ' // leemos desde la posicion numero 7 Debug.Print "ReadALlFile " & Datos Datos = XReadFile(StrFile1, 7, 2) ' // leemos dos datos Debug.Print "ReadALlFile " & Datos If XWriteFile(StrFile2, MSG, 5, , True) Then Debug.Print "WriteFileOk" End Sub
Ojo en la funciones Read el ultimo caracter es un byte 0 o caracter NUll (se debe a que use un array desde Index 0 xP y no desde 1, uan que el XCopyFile trabaja bien, sin agregar nada) P.D.: Estoy trabajando en un modulo de clase para mejorarlo (cuando lo termine lo posteo), mientras el código de arriba funciona para lo que se desea. Temible Lunas!¡. .
|
|
« Última modificación: 22 Enero 2010, 02:53 am por ░▒▓BlackZeroҖ▓▒░ »
|
En línea
|
The Dark Shadow is my passion.
|
|
|
The Swash
Desconectado
Mensajes: 194
Programmer
|
'*************************************************************** '* Coded By BlackZeroX & The Swash Updated 21/01/2010. * '* Function copy using Other method. * '* Web: http://Infrangelux.sytes.net & www.indetectables.Net * '* |-> Pueden Distribuir Este Código siempre y cuando * '* no se eliminen los créditos originales de este código * '* No importando que sea modificado/editado o engrandecido * '* o achicado, si es en base a este código * '*************************************************************** Option Explicit
Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const CREATE_NEW = 1 Const OPEN_EXISTING = 3 Const GENERIC_READ = &H80000000 Const GENERIC_WRITE = &H40000000 Const INVALID_HANDLE_VALUE = -1 Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long Private Declare Function PathFileExistsA Lib "shlwapi.dll" (ByVal pszPath As String) As Long Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Public Function CopyNew(aPath As String, nPath As String) As Long
Dim vBuffer() As Byte Dim Filesize As Long Dim vReadBytes As Long Dim res As Long Dim sFile As Long Dim RetDel As Long If Not PathFileExistsA(aPath) = 0 Then If GetFileAttributes(nPath) = FILE_ATTRIBUTE_ARCHIVE Then RetDel = DeleteFile(nPath) If RetDel = 0 Then Exit Function End If sFile = CreateFile(aPath, GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, ByVal 0&, ByVal 0&) Filesize = GetFileSize(sFile, 0) ReDim vBuffer(1 To Filesize) res = ReadFile(sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0&) CloseHandle sFile
sFile = CreateFile(nPath, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, CREATE_NEW, 0, 0) WriteFile sFile, vBuffer(1), UBound(vBuffer), vReadBytes, ByVal 0& If Len(res) = Len(sFile) Then SetFileAttributes nPath, GetFileAttributes(aPath) CopyNew = 1 End If Call CloseHandle(sFile) End If End Function @ BlackZeroX que gay , tenias razon en cuanto a la hora de borrar archivos ahora va de 10!, en cuanto al handle pues lo cierro cuando termina la primera parte y lo cierro cuando termina la segunda.. Haber con que me sales ahora xD ¬¬'' Salu2
|
|
« Última modificación: 22 Enero 2010, 15:40 pm por The Swash »
|
En línea
|
|
|
|
|
|