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

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Ayuda por favor;)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda por favor;)  (Leído 1,540 veces)
BlessCity

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Ayuda por favor;)
« en: 27 Marzo 2016, 23:32 pm »

Hola, estoy desarrollando un programa en visual basic..

Pero hay algo que quiero hacer osea..

Cambiar el fondo de la pantalla principal del escritorio por un fondo que yo quiera al momento de dar aceptar



alguien me ayuda?

Gracias..


En línea

79137913


Desconectado Desconectado

Mensajes: 1.169


4 Esquinas


Ver Perfil WWW
Re: Ayuda por favor;)
« Respuesta #1 en: 29 Marzo 2016, 16:37 pm »

HOLA!!!

Espero que te sirva...

Forma de siempre:
Código
  1. Private Const SPIF_UPDATEINIFILE = &H1
  2. Private Const SPI_SETDESKWALLPAPER = 20
  3. Private Const SPIF_SENDWININICHANGE = &H2
  4.  
  5. Private Declare Function SystemParametersInfo Lib "user32" Alias _
  6. "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
  7. ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
  8.  
  9.  
  10. Public Enum REG_TOPLEVEL_KEYS
  11. HKEY_CLASSES_ROOT = &H80000000
  12. HKEY_CURRENT_CONFIG = &H80000005
  13. HKEY_CURRENT_USER = &H80000001
  14. HKEY_DYN_DATA = &H80000006
  15. HKEY_LOCAL_MACHINE = &H80000002
  16. HKEY_PERFORMANCE_DATA = &H80000004
  17. HKEY_USERS = &H80000003
  18. End Enum
  19.  
  20.  
  21. Private Declare Function RegCreateKey Lib _
  22.   "advapi32.dll" Alias "RegCreateKeyA" _
  23.   (ByVal Hkey As Long, ByVal lpSubKey As _
  24.   String, phkResult As Long) As Long
  25.  
  26. Private Declare Function RegCloseKey Lib _
  27.   "advapi32.dll" (ByVal Hkey As Long) As Long
  28.  
  29. Private Declare Function RegSetValueEx Lib _
  30.   "advapi32.dll" Alias "RegSetValueExA" _
  31.   (ByVal Hkey As Long, ByVal _
  32.   lpValueName As String, ByVal _
  33.   Reserved As Long, ByVal dwType _
  34.   As Long, lpData As Any, ByVal _
  35.   cbData As Long) As Long
  36.  
  37. Private Const REG_SZ = 1
  38.  
  39.  
  40. Public Function ChangeWallPaper(ImageFile As String, Tile As Boolean)
  41.  
  42. 'Pass Full Path of .BMP to this function
  43. 'Returns true if successful, false otherwise
  44. 'If you want to tile, set Tile to True
  45.  
  46. Dim lRet As Long
  47. On Error Resume Next
  48.  
  49. If Tile Then WriteStringToRegistry HKEY_CURRENT_USER, _
  50.  "Control Panel\desktop", "TileWallpaper", "1"
  51.  
  52. lRet = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ImageFile, _
  53.   SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
  54. ChangeWallPaper = lRet <> 0 And Err.LastDllError = 0
  55. End Function
  56.  
  57. Private Function WriteStringToRegistry(Hkey As _
  58.  REG_TOPLEVEL_KEYS, strPath As String, strValue As String, _
  59.  strdata As String) As Boolean
  60.  
  61.  
  62. Dim bAns As Boolean
  63.  
  64. On Error GoTo ErrorHandler
  65.   Dim keyhand As Long
  66.   Dim r As Long
  67.   r = RegCreateKey(Hkey, strPath, keyhand)
  68.   If r = 0 Then
  69. r = RegSetValueEx(keyhand, strValue, 0, _
  70.   REG_SZ, ByVal strdata, Len(strdata))
  71. r = RegCloseKey(keyhand)
  72. End If
  73.  
  74.   WriteStringToRegistry = (r = 0)
  75.  
  76. Exit Function
  77.  
  78. ErrorHandler:
  79. WriteStringToRegistry = False
  80. Exit Function
  81.  
  82. End Function
  83.  
  84.  
  85.  
  86.  
  87. Private Sub Form_Load()
  88. Dim x, sourcef
  89. sourcef = "c:\tuimagen.bmp" 'PATH DE LA IMAGEN PARA EL FONDO DE PANTALLA
  90. x = ChangeWallPaper(sourcef, False)
  91. Unload Me
  92. End Sub
  93.  

Forma reducida con otro metodo no tan usado:
Código
  1. 'general declaration in the module or change scope to Private if you declare this in the form
  2. Option Explicit
  3.  
  4. Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
  5.                        (ByVal uAction As Long, ByVal uParam As Long, _
  6.                         ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
  7.  
  8. Public Const SPI_SETDESKWALLPAPER = 20
  9. Public Const SPIF_SENDWININICHANGE = &H2
  10. Public Const SPIF_UPDATEINIFILE = &H1
  11.  
  12. 'typical usage
  13. Dim strImagePath As String
  14.  
  15. strImagePath = "c:\tuimagen.bmp"
  16. Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, strImagePath, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

GRACIAS POR LEER!!!


« Última modificación: 29 Marzo 2016, 16:39 pm por 79137913 » 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*
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
SOS:AYUDA POR FAVOR!!!
Juegos y Consolas
wennam 2 3,167 Último mensaje 5 Enero 2004, 04:01 am
por FeRmO
AYUDA -.- ahora no entro más en 4chan (tengo una duda, ayuda por favor)
Foro Libre
Draklit 6 8,727 Último mensaje 15 Octubre 2010, 03:14 am
por Draklit
creo que dañe mi router por favor ayuda no c que hacer por favor ayuda
Redes
ddiego84 2 2,902 Último mensaje 2 Febrero 2016, 23:05 pm
por IBE
[AYUDA] Por favor ayuda con imagenes en html
Desarrollo Web
gramsch 3 2,402 Último mensaje 24 Febrero 2016, 21:35 pm
por Pantera80
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines