USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  Visual Basic    (Windows)

Título da Dica:  Auto-Run no Windows
Postada em 23/7/2003 por Juninho         
Num modulo

'Registry Related API's and Functions

'''The RegOpenKeyEx function opens the specified key.
Public 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

'''The RegCloseKey function releases a handle to the specified key.
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

''''The RegSetValueEx function sets the data and type of a specified value under a registry key.
Public 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

Public Const HKEY_CURRENT_USER = &H80000001
Public Const KEY_WRITE = &H20006
Public Const REG_SZ = 1

num form

Option Explicit
Dim HREGKEY As Long
Dim SUBKEY As String
Dim STRINGBUFFER As String
Dim RETVAL As String
Private Sub CmdConfig_Click()
' Write to Registry.
SUBKEY = "Software\Microsoft\Windows\CurrentVersion\Run"

RETVAL = RegOpenKeyEx(HKEY_CURRENT_USER, SUBKEY, 0, KEY_WRITE, HREGKEY)
If RETVAL <> 0 Then
Debug.Print "Can't open the subkey"
MsgBox "Can't open the subkey", vbInformation
Exit Sub
End If
STRINGBUFFER = App.Path & "\" & App.EXEName & ".exe" & vbNullChar
RETVAL = RegSetValueEx(HREGKEY, "MyRun", 0, REG_SZ, ByVal STRINGBUFFER, Len(STRINGBUFFER))

RegCloseKey HREGKEY
End Sub
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página