elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 128
51  Programación / Programación Visual Basic / Re: No consigo que mi app se ejecute al inicio en: 4 Diciembre 2012, 18:16 pm
Mirad, hice unas pruebas con esta función:

Código
  1. Option Explicit
  2.  
  3. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  4. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
  5. Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
  6.  
  7. Private Const HKEY_CURRENT_USER     As Long = &H80000001
  8. Private Const KEY_WRITE             As Long = &H20006
  9. Private Const REG_SZ                As Long = &H1
  10.  
  11. Public Function PutOnStartUp(ByVal sPath As String) As Boolean
  12. Dim hRegkey                         As Long
  13.  
  14.    If RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE, hRegkey) = 0 Then
  15.        sPath = sPath & vbNullChar
  16.        PutOnStartUp = RegSetValueEx(hRegkey, "My App", 0, REG_SZ, ByVal sPath, Len(sPath)) = 0
  17.        RegCloseKey hRegkey
  18.    End If
  19. End Function



PRUEBA UNO:

Código
  1. Private Sub Form_Load()
  2. Dim sPath      As String
  3.  
  4.    sPath = App.Path & "\" & App.EXEName & ".exe"
  5.  
  6.    If PutOnStartUp(sPath) Then
  7.        Me.BackColor = vbGreen
  8.    Else
  9.        Me.BackColor = vbRed
  10.    End If
  11.  
  12.    Me.AutoRedraw = True
  13.    Me.Print sPath
  14. End Sub

  • Compilo en el escritorio.
  • Lo ejecuto.
  • Reinicio y efectivamente, se ha ejecutado correctamente desde mi escritorio ;-)





PRUEBA DOS:

Código
  1. Private Sub Form_Load()
  2. Dim sPath      As String
  3. Dim sDest      As String
  4.  
  5.    sPath = App.Path & "\" & App.EXEName & ".exe"
  6.    sDest = Environ("tmp") & "\Test.exe"
  7.  
  8.    FileCopy sPath, sDest
  9.  
  10.    If PutOnStartUp(sDest) Then
  11.        Me.BackColor = vbGreen
  12.    Else
  13.        Me.BackColor = vbRed
  14.    End If
  15.  
  16.    Me.AutoRedraw = True
  17.    Me.Print sPath
  18. End Sub

  • Compilo en el escritorio.
  • Lo ejecuto.
  • Compruebo que se ha copiado en la carpeta temporal
  • Borro el del escritorio por si las moscas.
  • Reinicio y... ¡CRASH!

Citar
Error 70: Permiso denegado

¿Qué pasa aquí? :o

DoEvents! :P
52  Programación / Programación Visual Basic / No consigo que mi app se ejecute al inicio en: 4 Diciembre 2012, 10:25 am
Tengo Windows 7.

Copio mi exe en la carpeta de inicio, reinicio, pero no se ejecuta.
También he probado a añadir una clave en el registro y nada...
Puede ser porque mi exe requiere permisos de administrador pues si creo un programa que tan sólo te muestre un MsgBox funciona con cualquiera de los métodos anteriores... :P

¿Alguna solución? ???

DoEvents! :P
53  Programación / Programación Visual Basic / Re: Error 424 en tiempo de ejecución. Se requiere un objeto. [Ayuda] en: 3 Diciembre 2012, 17:50 pm
o quizas el error esta dentro de la funcion RC4 que llamas.
No creo, en ese caso le saltaría en dicha función. :P

Y si es:
Código:
Error 424 en tiempo de ejecución. Se requiere un objeto.

Lo más seguro es que haya hecho C&P y se haya olvidado de cambiar el nombre del Textbox. :silbar:

DoEvents! :P
54  Programación / Programación Visual Basic / Re: Error 424 en tiempo de ejecución. Se requiere un objeto. [Ayuda] en: 2 Diciembre 2012, 17:38 pm
Seguramente no tienes un TextBox llamado txtkey... :¬¬

DoEvents! :P
55  Foros Generales / Sugerencias y dudas sobre el Foro / Re: Añadir numeración de líneas a GeSHi en: 27 Noviembre 2012, 20:33 pm
Es que casi necesito un ábaco para contar las líneas que quiero destacar.  :xD

DoEvents! :P
56  Programación / Programación Visual Basic / Re: Autoclick de Pixeles en: 26 Noviembre 2012, 20:45 pm
¿Dónde se localiza ese objeto que se mueve?, ¿es de un juego?, ¿está en tu navegador? ...

DoEvents! :P
57  Programación / Programación Visual Basic / Re: [SRC] getShareSubFolders en: 26 Noviembre 2012, 20:43 pm
Me ha dado dolores de cabeza porque hay muy poca documentación.
La idea de la primera función fue de LeandroA... (tiene solución para todo)

DoEvents! :P
58  Programación / Programación Visual Basic / Re: Enumerar carpetas de una carpeta compartida en: 26 Noviembre 2012, 18:57 pm
Lo solucioné y comparto el código porque soy buena persona. :silbar:
Código:
http://foro.elhacker.net/programacion_visual_basic/src_getsharesubfolders-t377004.0.html

DoEvents! :P
59  Programación / Programación Visual Basic / [SRC] getShareSubFolders en: 26 Noviembre 2012, 18:55 pm
Bueno, estos códigos los he sacado para un proyecto en curso.
Devuelven un array con las subcarpetas de un servidor local.

OPCIÓN 1:

Código
  1. Option Explicit
  2. '===========================================================================
  3. ' º Name        : GetSharedSubFolders
  4. ' º Author      : Psyke1
  5. ' º Mail        : vbpsyke1@mixmail.com
  6. ' º Explanation : Returns an array with the subfolders of a shared folder.
  7. ' º Date        : 26/11/12
  8. ' º Reference   : http://goo.gl/sgDVX
  9. ' º Greets      : LeandroA
  10. ' º Visit       :
  11. '    * http://foro.h-sec.org
  12. '    * http://infrangelux.sytes.net
  13. '===========================================================================
  14.  
  15. Public Function getSharedSubFolders(ByVal sServer As String) As Collection
  16. Dim oShell                  As Object
  17. Dim oItem                   As Variant
  18.  
  19.    If PathIsNetworkPath(sServer) Then
  20.       Set oShell = CreateObject("Shell.Application")
  21.  
  22.       If Not oShell.NameSpace(CVar(sServer)) Is Nothing Then
  23.          Set getSharedSubFolders = New Collection
  24.  
  25.          For Each oItem In oShell.NameSpace(CVar(sServer)).Items
  26.              getSharedSubFolders.Add oItem.Path
  27.          Next oItem
  28.       End If
  29.    End If
  30. End Function
  31.  

Ejemplo de uso:
Código
  1. Private Sub Form_Load()
  2. Dim vFolder                 As Variant
  3. Dim cTmp                    As Collection
  4.  
  5.    Set cTmp = getSharedSubFolders("\\CARLOS-PC")
  6.    If cTmp Is Nothing Then
  7.        MsgBox "El servidor local no existe"
  8.    Else
  9.        For Each vFolder In cTmp
  10.            Debug.Print vFolder
  11.        Next
  12.    End If
  13. End Sub



OPCIÓN 2:

Código
  1. Option Explicit
  2. '===========================================================================
  3. ' º Name        : mGetSharedSubFolders.bas
  4. ' º Author      : Psyke1
  5. ' º Mail        : vbpsyke1@mixmail.com
  6. ' º Explanation : Returns an array with the subfolders of a shared folder.
  7. ' º Date        : 26/11/12
  8. ' º Visit       :
  9. '    * http://foro.h-sec.org
  10. '    * http://infrangelux.sytes.net
  11. '===========================================================================
  12.  
  13. 'Type
  14. Private Type NETRESOURCE
  15.  dwScope       As Long
  16.  dwType        As Long
  17.  dwDisplayType As Long
  18.  dwUsage       As Long
  19.  lpLocalName   As Long
  20.  lpRemoteName  As Long
  21.  lpComment     As Long
  22.  lpProvider    As Long
  23. End Type
  24.  
  25. 'kernel32.dll
  26. Private Declare Function lstrlenA Lib "kernel32.dll" (ByVal pString As Long) As Long
  27. Private Declare Function lstrcpyA Lib "kernel32.dll" (ByVal lpString1 As String, ByVal pString As Long) As Long
  28.  
  29. 'mpr.dll
  30. Private Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, lpNetResource As NETRESOURCE, lphEnum As Long) As Long
  31. Private Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
  32. Private Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Long, lpcCount As Long, lpBuffer As NETRESOURCE, lpBufferSize As Long) As Long
  33.  
  34. 'shlwapi.dll
  35. Private Declare Function PathIsNetworkPath Lib "shlwapi.dll" Alias "PathIsNetworkPathA" (ByVal pszPath As String) As Long
  36.  
  37. 'Consts
  38. Private Const RESOURCE_GLOBALNET        As Long = &H2
  39. Private Const RESOURCETYPE_DISK         As Long = &H1
  40. Private Const MAX_RESOURCES             As Long = &H100
  41.  
  42. 'Function
  43. Public Function getShareSubFolders(ByVal sNameServer As String) As String()
  44. Dim hEnum                               As Long
  45. Dim lLen                                As Long
  46. Dim lTotal                              As Long
  47. Dim lpRName                             As Long
  48. Dim sRet()                              As String
  49. Dim tNet(0 To MAX_RESOURCES)            As NETRESOURCE
  50.  
  51.    If PathIsNetworkPath(sNameServer) Then
  52.        lTotal = -1
  53.        lLen = &H1000 '(UBound(tNet) * Len(tNet(0))) / 2
  54.  
  55.        tNet(0).lpRemoteName = StrPtr(StrConv(sNameServer, vbFromUnicode))
  56.  
  57.        If Not WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, tNet(0), hEnum) Then
  58.            If Not WNetEnumResource(hEnum, lTotal, tNet(0), lLen) Then
  59.                If lTotal > 0 Then
  60.                    lTotal = lTotal - 1
  61.                    ReDim sRet(0 To lTotal) As String
  62.  
  63.                    For lLen = 0 To lTotal
  64.                        lpRName = tNet(lLen).lpRemoteName
  65.  
  66.                        sRet(lLen) = Space(lstrlenA(lpRName))
  67.                        lstrcpyA sRet(lLen), lpRName
  68.                    Next lLen
  69.                End If
  70.            End If
  71.  
  72.            WNetCloseEnum hEnum
  73.        End If
  74.    End If
  75.  
  76.    getShareSubFolders = sRet()
  77. End Function

Ejemplo de uso:
Código
  1. Private Sub Form_Load()
  2. Dim vSubFolder                          As Variant
  3. Dim sSF()                               As String
  4.  
  5.    sSF = getShareSubFolders("\\CARLOS-PC")
  6.  
  7.    If Not Not sSF Then
  8.  
  9.        For Each vSubFolder In sSF
  10.            Debug.Print vSubFolder
  11.        Next vSubFolder
  12.    End If
  13.  
  14.    'fix NotNot hack :)
  15.    Debug.Assert App.hInstance
  16. End Sub

DoEvents! :P
60  Foros Generales / Sugerencias y dudas sobre el Foro / Añadir numeración de líneas a GeSHi en: 26 Noviembre 2012, 13:14 pm
Pues eso... me es muy cómodo a la hora de buscar una sección concreta en un código.
¿Qué opináis?

DoEvents! :P
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 128
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines