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 - extreme69

#151
ahhh, me pasé de newbie :E

ya lo hice xD

Gracias a todos !!! unos genios como siempre!
#152
Jeje, te agradezco el intento de explicarme, pero me estoy mareando más aún con ese código...  :rolleyes:

Hago una pregunta más concreta usando el ejemplo de API-GUIDE que se me hace más fácil de entender.

'This program needs 3 buttons
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_BINARY = 3 ' Free form binary
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
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
Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String) As String
   Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long
   'retrieve nformation about the key
   lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize)
   If lResult = 0 Then
       If lValueType = REG_SZ Then
           'Create a buffer
           strBuf = String(lDataBufSize, Chr$(0))
           'retrieve the key's content
           lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal strBuf, lDataBufSize)
           If lResult = 0 Then
               'Remove the unnecessary chr$(0)'s
               RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1)
           End If
       ElseIf lValueType = REG_BINARY Then
           Dim strData As Integer
           'retrieve the key's value
           lResult = RegQueryValueEx(hKey, strValueName, 0, 0, strData, lDataBufSize)
           If lResult = 0 Then
               RegQueryStringValue = strData
           End If
       End If
   End If
End Function
Function GetString(hKey As Long, strPath As String, strValue As String)
   Dim Ret
   'Open the key
   RegOpenKey hKey, strPath, Ret
   'Get the key's content
   GetString = RegQueryStringValue(Ret, strValue)
   'Close the key
   RegCloseKey Ret
End Function
Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
   Dim Ret
   'Create a new key
   RegCreateKey hKey, strPath, Ret
   'Save a string to the key
   RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
   'close the key
   RegCloseKey Ret
End Sub
Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String)
   Dim Ret
   'Create a new key
   RegCreateKey hKey, strPath, Ret
   'Set the key's value
   RegSetValueEx Ret, strValue, 0, REG_BINARY, CByte(strData), 4
   'close the key
   RegCloseKey Ret
End Sub
Sub DelSetting(hKey As Long, strPath As String, strValue As String)
   Dim Ret
   'Create a new key
   RegCreateKey hKey, strPath, Ret
   'Delete the key's value
   RegDeleteValue Ret, strValue
   'close the key
   RegCloseKey Ret
End Sub
Private Sub Command1_Click()
   Dim strString As String
   'Ask for a value
   strString = InputBox("Please enter a value between 0 and 255 to be saved as a binary value in the registry.", App.Title)
   If strString = "" Or Val(strString) > 255 Or Val(strString) < 0 Then
       MsgBox "Invalid value entered ...", vbExclamation + vbOKOnly, App.Title
       Exit Sub
   End If
   'Save the value to the registry
   SaveStringLong HKEY_CURRENT_USER, "KPD-Team", "BinaryValue", CByte(strString)
End Sub
Private Sub Command2_Click()
   'Get a string from the registry
   Ret = GetString(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NMap", "BinaryValue")
   If Ret = "" Then MsgBox "No value found !", vbExclamation + vbOKOnly, App.Title: Exit Sub
   MsgBox "The value is " + Ret, vbOKOnly + vbInformation, App.Title
End Sub
Private Sub Command3_Click()
   'Delete the setting from the registry
   DelSetting HKEY_CURRENT_USER, "KPD-Team", "BinaryValue"
   MsgBox "The value was deleted ...", vbInformation + vbOKOnly, App.Title
End Sub
Private Sub Form_Load()
   'KPD-Team 1998
   'URL: http://www.allapi.net/
   'E-Mail: KPDTeam@Allapi.net
   Command1.Caption = "Set Value"
   Command2.Caption = "Get Value"
   Command3.Caption = "Delete Value"
End Sub



No le des importancia al código que no necesito, es sacar los botones y declaraciones que no uso... el objetivo es que el botón 2 me devuelva el valor del registro que quiero.

Supongamos que esta es la ruta:



Y que esta es la key que quiero ver el valor:



La pregunta es... ¿donde pongo el "DisplayName"? y ¿porqué me sigue diciendo "No value found!" cuando la ruta es la correcta? :/


Disculpen si molesto con tanta pregunta, pero realmente quiero comprender que es lo que estoy haciendo y como hacerlo.

#153
Ahi intento, repondi sin haber leido tu respuesta >:E
#154
A ver si tengo bien el concepto, voy a basarme en en el ejemplo de api guide.

Primero las declaraciones y funciones:

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long


Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String) As String
   Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long
   'retrieve nformation about the key
   lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize)
   If lResult = 0 Then
       If lValueType = REG_SZ Then
           'Create a buffer
           strBuf = String(lDataBufSize, Chr$(0))
           'retrieve the key's content
           lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal strBuf, lDataBufSize)
           If lResult = 0 Then
               'Remove the unnecessary chr$(0)'s
               RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1)
           End If
       ElseIf lValueType = REG_BINARY Then
           Dim strData As Integer
           'retrieve the key's value
           lResult = RegQueryValueEx(hKey, strValueName, 0, 0, strData, lDataBufSize)
           If lResult = 0 Then
               RegQueryStringValue = strData
           End If
       End If
   End If
End Function


Function GetString(hKey As Long, strPath As String, strValue As String)
   Dim Ret
   'Open the key
   RegOpenKey hKey, strPath, Ret
   'Get the key's content
   GetString = RegQueryStringValue(Ret, strValue)
   'Close the key
   RegCloseKey Ret
End Function


Ahora un boton que tome el valor y lo muestre en un msg box:

Private Sub Command1_Click()
   'Get a string from the registry
   Ret = GetString(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Programa", "BinaryValue")
   If Ret = "" Then MsgBox "No value found !", vbExclamation + vbOKOnly, App.Title: Exit Sub
   MsgBox "The value is " + Ret, vbOKOnly + vbInformation, App.Title
End Sub




Que estoy haciendo mal? :/
#155
Seré medio bolúdo pero con ese código estoy peor que con el que tenía :S

Ese código es para modificar cierto valor en el registro, pero no veo en que parte toma el valor de la key  :-[
#156
Si, yo me quedé desilusionado, la luz en la cueva, la huevada del bien y el mal y los cuidadores de la isla, yo esperaba algo que me atara todos los cabos, y nunca los ataron, incluso me quedé con la intriga de porqué los osos polares en la isla y porqué la revista con el oso polar, eso tendría q haber tenido un significado... luego sacaron 10-15 minutos que nunca habían mostrado, donde explican lo de los osos (lamentable).

Tengo otro problema, y acá si me gustaría que me pongan el código entero porque me voy a volver loco sino.

Necesito leer el valor de una key del registro de windows y mostrarla en un msgbox.

Me está volviendo loco :$

Gracias de antemano ^^
#157
Cita de: 79137913 en 10 Diciembre 2010, 12:17 PM
HOLA!!!

Código (vb) [Seleccionar]
Private Function RestaChrs(NUMERO As Variant, RESTAR As Integer)

   If Not RESTAR < Len(Str(NUMERO)) Then
       MsgBox "LOS CARACTERES A RESTAR NO PUEDEN SER MAYORES A LOS CARACTERES DE LA VARIABLE", , "ERROR"
       Exit Function
   End If
   
   RestaChrs = Mid(Str(NUMERO), 1, Len(Str(NUMERO)) - RESTAR)
End Function

Private Sub Form_Load()
    'AL NUMERO 1234567 LE RESTA 3 CIFRAS
    Debug.Print RestaChrs(1234567, 3)
End Sub


GRACIAS POR LEER!!!

Uhhh, es como que me contaste el final de LOST antes de verlo más o menos.

jajajaj, gracias!
#158
Graciasssss, ahí pruebo :)
#159
Agradezco de antemano si alguien me puede ayudar con esto ^^ parece fácil para alguien que ande en esto.

Supongamos que tengo la variable:

X=123456789

y quiero restarle 3 caracteres para que quede:

X=123456

no me interesa limitar la cantidad de caracteres, esa variable va a ser siempre de distinta longitud, puede que a veces sean 6 caracteres, a veces 8, etc...

Gracias!!!  ;-)
#160
¿Será posible crear un sistema de autentificación para leer un texto de manera que sólo ese usuario habilitado pueda abrir ese texto?

Se me ocurrió que podría hacer un sistema de autentificación tomando el numero del HID, de esta manera sólo abriría el texto si el HID coincide con la persona habilitada a abrirlo.

¿Me ayudan a redondear la idea?

No me queda claro como podría hacerlo... debería primero saber el HID de cada persona habilitada a abrirlo y guardarlo de alguna manera en la web, luego la persona al abrir el ejecutable se conecta a la web, revisa que el HID coincida y recién en ese monento estaría habilitada a abrir el texto.

Por otro lado ¿el texto debería ir cifrado verdad?

Mmmm, todavía no empecé y ya me está dando dolor de cabeza :/