Autor
|
Tema: [APORTE] ReadIni Memoria (Leído 2,430 veces)
|
Miseryk
Desconectado
Mensajes: 225
SI.NU.SA U.GU.DE (2NE1 - D-Unit)
|
Bueno, estaba trabajando con archivos en memoria, y no quería guardarlos en directorios temporales o cosas así, así que hice una función que simula a GetPrivateProfileString. PD: solamente hice en modo lectura, ya que des-en-crip-to un archivo y ni me interesa modifcarlo desde ahí. Public Function MiseryReadKey(Cadena As String, Section As String, Key As String) As String 'BreakLine = Enter o ; Dim FirstPos As Long, LastPos As Long, FitPos As Long Dim FinalStr As String Section = UCase(Section) Key = UCase(Key) '[Section] FirstPos = InStr(1, UCase(Cadena), "[" & Section & "]") If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If FirstPos = FirstPos + Len("[" & Section & "]") LastPos = InStr(FirstPos, UCase(Cadena), "[") - 1 'Patch, si está al final no ván a haber más "[" If LastPos < 1 Then LastPos = Len(Cadena) + 1 End If FinalStr = Mid(Cadena, FirstPos, LastPos - FirstPos) 'Key FirstPos = InStr(1, UCase(FinalStr), Key) If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If LastPos = InStr(FirstPos, FinalStr, Chr(13)) - 1 'Patch 07/07/2014 'Patch, lo mismo acá, no ván a haber más enters si lée el último If LastPos < 1 Then LastPos = Len(FinalStr) + 1 End If 'Hay un comentario FitPos = InStr(FirstPos, FinalStr, ";") If FitPos > 0 Then If FitPos < LastPos Then LastPos = FitPos - 1 End If End If '= FirstPos = InStr(FirstPos, FinalStr, "=") If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If MiseryReadKey = Trim(Mid(FinalStr, FirstPos + 1, LastPos - FirstPos)) End Function
MsgBox MiseryReadKey(txtFile.Text, "NUMERO1", "Val1")
El FitPos es para el enter o ; Archivo: [NUMERO1] Val1=333 ;asd Val2=666;asd
Saludos!
|
|
« Última modificación: 7 Julio 2014, 22:04 pm por Miseryk »
|
En línea
|
Can you see it? The worst is over The monsters in my head are scared of love Fallen people listen up! It’s never too late to change our luck So, don’t let them steal your light Don’t let them break your stride There is light on the other side And you’ll see all the raindrops falling behind Make it out tonight it’s a revolution
CL!!!
|
|
|
79137913
Desconectado
Mensajes: 1.169
4 Esquinas
|
HOLA!!!
Soporta Unicode?
P.D: muy buen aporte!
GRACIAS POR LEER!!!
|
|
|
En línea
|
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!" "La peor de las ignorancias es no saber corregirlas"
79137913 *Shadow Scouts Team*
|
|
|
engel lex
|
des-en-crip-to
descifro* el foro está forzado para que la gente use la palabra correcta XD
|
|
|
En línea
|
El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
|
|
|
Miseryk
Desconectado
Mensajes: 225
SI.NU.SA U.GU.DE (2NE1 - D-Unit)
|
HOLA!!!
Soporta Unicode?
P.D: muy buen aporte!
GRACIAS POR LEER!!!
Gracias (Y) No, solamente soporta texto en string, textbox y cosas así, los cuales usan ANSI, estoy en lo correcto o estoy hablando boludeces? descifro* el foro está forzado para que la gente use la palabra correcta XD Ah, no sabía, pensé que era para que google u otras páginas no tomen a foro.elhacker como spam o con virus. Edit: Aunque busca hasta enters o ; y lo guarda a string, desconozco si realmente guarda bien los bytes ahí, pero debería probarlo.
|
|
« Última modificación: 3 Julio 2014, 20:57 pm por Miseryk »
|
En línea
|
Can you see it? The worst is over The monsters in my head are scared of love Fallen people listen up! It’s never too late to change our luck So, don’t let them steal your light Don’t let them break your stride There is light on the other side And you’ll see all the raindrops falling behind Make it out tonight it’s a revolution
CL!!!
|
|
|
79137913
Desconectado
Mensajes: 1.169
4 Esquinas
|
HOLA!!!
Me imagino, supongo que no debe soportar, intenta meter un archivo binario en memoria y volver a volcarlo, si funciona soporta unicode sino no.
GRACIAS POR LEER!!!
|
|
|
En línea
|
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!" "La peor de las ignorancias es no saber corregirlas"
79137913 *Shadow Scouts Team*
|
|
|
Miseryk
Desconectado
Mensajes: 225
SI.NU.SA U.GU.DE (2NE1 - D-Unit)
|
Patch: Public Function MiseryReadKey(Cadena As String, Section As String, key As String) As String 'BreakLine = Enter o ; Dim FirstPos As Long, LastPos As Long, FitPos As Long Dim FinalStr As String Section = UCase(Section) key = UCase(key & "=") 'Patch 08/07/2014 '[Section] FirstPos = InStr(1, UCase(Cadena), "[" & Section & "]") If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If FirstPos = FirstPos + Len("[" & Section & "]") LastPos = InStr(FirstPos, UCase(Cadena), "[") - 1 'Patch, si está al final no ván a haber más "[" If LastPos < 1 Then LastPos = Len(Cadena) + 1 End If FinalStr = mid(Cadena, FirstPos, LastPos - FirstPos) 'Key FirstPos = InStr(1, UCase(FinalStr), key) If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If LastPos = InStr(FirstPos, FinalStr, Chr(13)) - 1 'Patch 07/07/2014 'Patch, lo mismo acá, no ván a haber más enters si lée el último If LastPos < 1 Then LastPos = Len(FinalStr) + 1 End If 'Hay un comentario FitPos = InStr(FirstPos, FinalStr, ";") If FitPos > 0 Then If FitPos < LastPos Then LastPos = FitPos - 1 End If End If '= FirstPos = InStr(FirstPos, FinalStr, "=") If FirstPos < 1 Then MiseryReadKey = "" Exit Function End If MiseryReadKey = Trim(mid(FinalStr, FirstPos + 1, LastPos - FirstPos)) End Function
|
|
|
En línea
|
Can you see it? The worst is over The monsters in my head are scared of love Fallen people listen up! It’s never too late to change our luck So, don’t let them steal your light Don’t let them break your stride There is light on the other side And you’ll see all the raindrops falling behind Make it out tonight it’s a revolution
CL!!!
|
|
|
|
Mensajes similares |
|
Asunto |
Iniciado por |
Respuestas |
Vistas |
Último mensaje |
|
|
pequeño aporte(proxy),pero aporte al fin.:D
Programación Visual Basic
|
Tengu
|
0
|
2,370
|
22 Julio 2007, 17:33 pm
por Tengu
|
|
|
cambiar memoria de un juego y escribir en memoria By Sacha
Ingeniería Inversa
|
EL PRINTERO
|
0
|
3,656
|
24 Agosto 2007, 23:36 pm
por EL PRINTERO
|
|
|
Desarrollan una memoria flexible que podría almacenar más datos que la memoria..
Noticias
|
wolfbcn
|
0
|
2,545
|
23 Octubre 2010, 18:08 pm
por wolfbcn
|
|
|
[DUDA] Acerca de Memoria Virtual Y Memoria Fisica Entre otros...
Programación C/C++
|
x64core
|
9
|
6,756
|
28 Noviembre 2011, 17:20 pm
por x64core
|
|
|
Duda registros,memoria principal y memoria caché
Hardware
|
Senior++
|
2
|
3,027
|
9 Mayo 2014, 10:16 am
por Senior++
|
|