Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Psyke1

#301
En primer lugar gracias a todos por participar! :D
En segundo lugar perdón por haber puesto códigos que no funcionaban, andaba con prisa... :¬¬
Este es mi último código:

Código (vb) [Seleccionar]
Public Static Function MrFrogGetFileFast(ByRef sPath As String) As String
Dim L                                               As Long
Dim lngPos                                          As Long
   
    L = LenB(sPath) \ 2
    lngPos = L - InStrRev(sPath, "\", L, vbBinaryCompare)
    MrFrogGetFileFast = RightB$(sPath, lngPos + lngPos)
End Function


Test:
Option Explicit

Private cFC As New cFrogContest

Private Declare Sub PathStripPath Lib "shlwapi.dll" Alias "PathStripPathA" (ByVal pszPath As String)
Private Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (ByVal lpszFile As String, ByVal lpszTitle As String, ByVal cbBuf As Integer) As Integer

Public Static Function MrFrogGetFileFast(ByRef sPath As String) As String
Dim L                                               As Long
Dim lngPos                                          As Long
   
    L = LenB(sPath) \ 2
    lngPos = L - InStrRev(sPath, "\", L, vbBinaryCompare)
    MrFrogGetFileFast = RightB$(sPath, lngPos + lngPos)
End Function

Public Function SacarFilenameE_Cv2(ByRef sPath As String) As String
    SacarFilenameE_Cv2 = Right$(sPath, Len(sPath) - InStrRev(sPath, "\", Len(sPath), vbBinaryCompare))
End Function

Public Function SacarFilenameE_C(ByRef sPath As String) As String
SacarFilenameE_C = StrReverse$(Left$(StrReverse$(sPath), InStr(1, StrReverse(sPath), "\", vbBinaryCompare) - 1))
End Function

Public Function getFileNameIgnorante(ByVal path As String) As String
    Dim cM As Integer
    cM = InStrRev(path, "\") + 1
    If cM = 0 Then Exit Function
    getFileNameIgnorante = Mid(path, cM)
End Function

Public Function StripPathSeba(ByVal sPath As String) As String
   Call PathStripPath(sPath)
   StripPathSeba = sPath
End Function

Public Function getFileNameIgnoranteMODSeba(ByVal path As String) As String
    getFileNameIgnoranteMODSeba = Mid$(path, InStrRev(path, "\") + 1)
End Function

Public Function nombre_archivoGrester(ByVal Ruta As String) As String
Dim partes() As String
partes = Split(Ruta, "\")
nombre_archivoGrester = partes(UBound(partes))
End Function

Public Function Fn7913(ByVal sPath As String) As String
    Dim Buffer As String
    Buffer = String(255, 0)
    GetFileTitle sPath, Buffer, Len(Buffer)
    Fn7913 = Left$(Buffer, InStr(1, Buffer, Chr$(0)) - 1)
End Function

Public Function GetFileName123(ByRef vPath As String) As String
    GetFileName123 = Right$(vPath, Len(vPath) - InStrRev(vPath, "\"))
End Function

Private Sub Form_Load()
    With cFC
        .ContestName = "ObtenerNombreArchivo"
        .Explanation = "Mas claro, hechale agua"
        .SaveDirectory = App.path
        .ReplaceFile = True
        .Functions "Fn7913,MrFrogGetFileFast,GetFilename123,getFileNameIgnorante,getFileNameIgnoranteMODSeba,nombre_archivoGrester,SacarFilenameE_C,SacarFilenameE_Cv2,StripPathSeba"
        .Arguments "C:\Documents and Settings\Llamazares\Mis documentos\Downloads\SexoDeRanas.avi"
        .NumberOfLoops = 10000
        .Result = "SexoDeRanas.avi"
        .SetObject Me
        .TestIt
        .ShowTest
    End With
   
    End
End Sub


Resultado :
================================================================================
º Contest Name : ObtenerNombreArchivo
º Explanation  : Mas claro, hechale agua
º Arguments    : C:\Documents and Settings\Llamazares\Mis documentos\Downloads\SexoDeRanas.avi
º Loops        : 10000
º Date & Hour  : 02-14-2011 <-> 02:54:08
================================================================================
Results [compiled] :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.- MrFrogGetFileFast                                   -> 66,783268 msec
2.- SacarFilenameE_Cv2                                  -> 70,190216 msec
3.- MrFrogGetFileFast                                   -> 74,492314 msec
4.- SacarFilenameE_C                                    -> 78,365336 msec
5.- getFileNameIgnorante                                -> 79,100052 msec
6.- getFileNameIgnoranteMODSeba                         -> 88,191208 msec
7.- GetFilename123                                      -> 91,506807 msec
8.- nombre_archivoGrester                               -> 129,792677 msec
9.- Fn7913                                -> 2159,992821 msec
================================================================================
º The following functions returns incorrect results :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.- StripPathSeba
================================================================================
>>> Test made by cFrogContest.cls <-> Visit foro.elhacker.net <<<
================================================================================


Pd: Me alegra ver que usais mi clase :-*

DoEvents! :P
#302
Código (vb) [Seleccionar]
Public Static Function GetFileMrFrog(ByRef sFile As String) As String
   GetFileMrFrog = RightB$(sFile, InStrRev(sFile, "\") * 2 - 2)
End Function


Esta si! :P
Despues testeo ahora no tengo tiempo.
@Seba123neo
Jajajaj hice la clase precisamente para ahorrarte el trabajo! :xD

DoEvents! :P
#303
La mía:
Código (vb) [Seleccionar]

Public Static Function GetFileMrFrog(ByRef sFile As String) As String
    GetFileMrFrog = RightB$(sFile, LenB(sFile) - InStrB(sFile, "\") - 1)
End Function


@ignorantev1.1
http://foro.elhacker.net/programacion_visual_basic/src_cfrogcontestcls_by_mr_frog_copy-t318871.0.html

DoEvents! :P
#304
Un reto fácil, en el que creo que puede participar mucha gente. :)
Consiste en obtener el nombre de archivo a partir de una ruta, así:

C:\Documents and Settings\Llamazares\Mis documentos\Downloads\SexoDeRanas.avi
Deberia devolver la función:
SexoDeRanas.avi

Quien sea más rápido, gana. ;)
Se testeará con cFrogContest.cls :P

DoEvents! :P
#305
Cita de: seba123neo en 13 Febrero 2011, 19:38 PM
que yo sepa un nombre de archivo no puede tener comillas dobles...
Oops :-X
Fallo mio... :xD
No me di cuenta, aún así mi manera es correcta :silbar:
Lo que queria decir es que si haces Split() para sacar los nombres usando " " como delimitador, te cortará el la ruta en trozos suponiendo que este lleve espacios dentro. :)

DoEvents! :P
#306
Ya seba123neo, pero si el archivo lleva comillas? :rolleyes:
A mi se me ocurre algo así:

Código (vb) [Seleccionar]

Public Function GetFiles(ByVal strText As String) As Collection
Dim cTemp                       As New Collection
Dim oRegExp                     As Object
Dim oMatch                      As Object
Dim oMatches                    As Object

   Set oRegExp = CreateObject("VBScript.RegExp") 'Evitamos la referencia

   With oRegExp
       '// Sería similar a esta, lo único modificar los [\w\s\.] para que acepten algunos símbolos más... xP
       .Pattern = "\s?([\w\s\.]+\:\\([\w\s\.]+\\?)[\w\s\.]+(\.\w{1,})?)\s?"    '// No incluye verificación de ruta (pero... ¿no hace falta no?)
       .Global = True
       .IgnoreCase = True
   End With

   Set oMatches = oRegExp.Execute(strText)

   For Each oMatch In oMatches
       cTemp.Add oMatch.SubMatches(0)
   Next
   
   Set GetFiles = cTemp
End Function

Private Sub Form_Load()
Dim vItem                       As Variant
Const S                         As String = "C:\Frog\Proyecto1.exe ""C:\reto 123.exe"" C:\imagen.png"
   For Each vItem In GetFiles(S)
       MsgBox vItem
   Next
End Sub


Ojalá te sirva ;)

DoEvents! :P
#307
Aquí tienes un ejemplo usando la función más rápida del minireto. :rolleyes:
http://goo.gl/soolr

Código (vb) [Seleccionar]

'-------------------------------------------------
'Añade 2 ListBox (List1 y List2)
'-------------------------------------------------
Option Explicit
Private Declare Function GetFileAttributesW Lib "KERNEL32" (ByVal lpFileName As Long) As Long

'LeandroA mod Karcrack mod Raul338 mod Mr.Frog
Public Static Function DoFileExistsRII(ByRef sPath As String) As Boolean
   DoFileExistsRII = (GetFileAttributesW(StrPtr(sPath)) > -1)
End Function

Private Sub Form_Load()
Dim lngCount                    As Long
Dim strTmp                      As String
Dim Q                           As Long

   With List1
       .AddItem "c:\hola.txt"
       .AddItem "c:\Text\34543554.jpg"
       .AddItem "c:\La reproducción de las ranas.mpeg"
   
       lngCount = .ListCount - 1           '// Cantidad de Items
       
       '// Guardaré en el List2 sólo los archivos que existen xP
       For Q = 0 To lngCount
           strTmp = .List(Q)               '// El Item actual
           If DoFileExistsRII(strTmp) Then '// Si existe... (¿Aquí estaba el fallo de lógica? xD)
               List2.AddItem strTmp        '// Lo añado a List2
           End If
       Next Q
   End With
End Sub


Resultado en el 2º ListBox (List2):

c:\hola.txt
c:\La reproducción de las ranas.mpeg


DoEvents! :P
#308
#309
Codigo actualizado, corregido y mejorado... :)

DoEvents! :P
#310
@BlackZer0x
Cita de: BlackZeroX▓▓▒▒░░ en  7 Febrero 2011, 21:06 PM
* Las propiedades deberias bloquearlas si es que ya se llamo a el proceso TestIt()
¿Por qué?

DoEvents! :P