¿En que linea te da el error?
¿Tenes permiso para leer el registro?
El codigo esta provado y funciona =S Uso WindowsXP SP2.
¿Tenes permiso para leer el registro?
El codigo esta provado y funciona =S Uso WindowsXP SP2.
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ú
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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Function RegLeerClave(Key As String, SubKey As String) As Boolean 'Devuelve TRUE si existe, FALSE si no existe
Dim regRes As Long
Key = LLave(Key)
RegOpenKey Key, SubKey, regRes
If regRes = 0 Then
RegLeerClave = False
Else
RegLeerClave = True
End If
RegCloseKey regRes
End Function
If RegLeerClave("HKLM", "Software\Prueba") = True then 'Prueba seria la clave a comprobar...
End 'Terminamos el programa
end if
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, ByRef lpData As NOTIFYICONDATA) As Long
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1 'Borrar si no se quiere animar la imagen
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_RBUTTONUP = &H205
Dim IC As NOTIFYICONDATA
Public Sub Iconito(Tip As String, Foto As PictureBox)
IC.cbSize = Len(IC)
IC.hwnd = Foto.hwnd
IC.uID = 1&
IC.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
IC.uCallbackMessage = WM_LBUTTONDOWN
IC.hIcon = Foto.Picture
IC.szTip = Tip & Chr(0)
Shell_NotifyIcon NIM_ADD, IC
End Sub
Public Sub BorrarIconito()
Shell_NotifyIcon NIM_DELETE, IC
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim msg As Integer
msg = X / Screen.TwipsPerPixelX
If msg = WM_LBUTTONDBLCLK Then
MsgBox "Boton Izquierdo doble click."
ElseIf msg = WM_RBUTTONUP Then
MsgBox "Boton Derecho un click."
End If
End Sub
Iconito "Texto", Picture1
[/cide]
Y para quitarlo pones:
Es importante que al cerrar el programa se borre el icono ya que sino va a quedar visible (al pasar el mouse desaparece, pero es mejor borrarlo).
Espero que te sirva, saludos.-
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Timer1_Timer()
Dim lnghWnd As Long, Texto As String
lnghWnd = GetForegroundWindow
Texto = String(255, Chr(0))
GetWindowText GetForegroundWindow, Texto, 255
Me.Caption = Texto
End Sub
Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Sub Form_Load()
iResult = mciExecute("Play c:\carpeta~1\setup0.wav")
End Sub