INICIAR PROGRAMA COM O WINDOWS VISTA.
Olá Galera!
Fiz este exemplo para iniciar com o windows a minha aplicação, acontece que com o XP ele faz o Registry na máquina tudo certinho e por sua vez o arranque da minha aplicação com o XP fica Blz.
Só que na versão Win Vista ele nem grava o Registry no windows para que o programa possa arrancar com o mesmo, alguém faz ideia como contornar este problema.?
Grato pela vossa atenção.
Programadorvb6
[ô]======================================================================================================
Código :
[ô]======================================================================================================
Private Declare Function RegDeleteValue Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegDeleteValueA[Ô] (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueExString Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegSetValueExA[Ô] (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData 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 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
Private Declare Function RegQueryValueEx Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegQueryValueExA[Ô] (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Const HKLM As Long = &H80000002
Private Function FArranque(Accao As String) As Integer
Dim lResult As Long
Dim lChave As Long
Dim TipoDados As Long
Dim sValor As String
Dim Chave As String
Dim NomeVal As String
Dim temp As String
Dim ProgPath As String
NomeVal = [Ô]ProgTeste[Ô]
ProgPath = App.Path
If (LCase(Right(ProgPath, 1)) <> [Ô]\[Ô]) Then ProgPath = ProgPath & [Ô]\[Ô]
Chave = [Ô]SOFTWARE\Microsoft\Windows\CurrentVersion\Run[Ô]
sValor = ProgPath & App.EXEName
If (LCase(Right(sValor, 4)) <> [Ô].exe[Ô]) Then sValor = sValor & [Ô].exe[Ô]
lResult = RegOpenKey(HKLM, Chave, lChave)
temp = Space(1024)
lResult = RegQueryValueEx(lChave, NomeVal, 0&, TipoDados, temp, Len(temp))
If (lResult = 0) And (Accao = [Ô]del[Ô]) Then
lResult = RegDeleteValue(lChave, NomeVal)
[ô]lResult = RegCloseKey(lChave)
ElseIf (lResult = 2) And (Accao = [Ô]add[Ô]) Then
lResult = RegCreateKey(HKLM, Chave, lChave)
lResult = RegSetValueExString(lChave, NomeVal, 0&, 1&, sValor, Len(sValor))
End If
FArranque = lResult
lResult = RegCloseKey(lChave)
End Function
[ô]======================================================================================================
[ô]===================================================
Para utilizar a função FArranque basta:
FArranque [Ô]add[Ô]
ou
FArranque [Ô]del[Ô]
para adicionar ou apagar os valores, respectivamente.
[ô]===================================================
Fiz este exemplo para iniciar com o windows a minha aplicação, acontece que com o XP ele faz o Registry na máquina tudo certinho e por sua vez o arranque da minha aplicação com o XP fica Blz.
Só que na versão Win Vista ele nem grava o Registry no windows para que o programa possa arrancar com o mesmo, alguém faz ideia como contornar este problema.?
Grato pela vossa atenção.
Programadorvb6
[ô]======================================================================================================
Código :
[ô]======================================================================================================
Private Declare Function RegDeleteValue Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegDeleteValueA[Ô] (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueExString Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegSetValueExA[Ô] (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData 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 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
Private Declare Function RegQueryValueEx Lib [Ô]advapi32.dll[Ô] Alias [Ô]RegQueryValueExA[Ô] (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Const HKLM As Long = &H80000002
Private Function FArranque(Accao As String) As Integer
Dim lResult As Long
Dim lChave As Long
Dim TipoDados As Long
Dim sValor As String
Dim Chave As String
Dim NomeVal As String
Dim temp As String
Dim ProgPath As String
NomeVal = [Ô]ProgTeste[Ô]
ProgPath = App.Path
If (LCase(Right(ProgPath, 1)) <> [Ô]\[Ô]) Then ProgPath = ProgPath & [Ô]\[Ô]
Chave = [Ô]SOFTWARE\Microsoft\Windows\CurrentVersion\Run[Ô]
sValor = ProgPath & App.EXEName
If (LCase(Right(sValor, 4)) <> [Ô].exe[Ô]) Then sValor = sValor & [Ô].exe[Ô]
lResult = RegOpenKey(HKLM, Chave, lChave)
temp = Space(1024)
lResult = RegQueryValueEx(lChave, NomeVal, 0&, TipoDados, temp, Len(temp))
If (lResult = 0) And (Accao = [Ô]del[Ô]) Then
lResult = RegDeleteValue(lChave, NomeVal)
[ô]lResult = RegCloseKey(lChave)
ElseIf (lResult = 2) And (Accao = [Ô]add[Ô]) Then
lResult = RegCreateKey(HKLM, Chave, lChave)
lResult = RegSetValueExString(lChave, NomeVal, 0&, 1&, sValor, Len(sValor))
End If
FArranque = lResult
lResult = RegCloseKey(lChave)
End Function
[ô]======================================================================================================
[ô]===================================================
Para utilizar a função FArranque basta:
FArranque [Ô]add[Ô]
ou
FArranque [Ô]del[Ô]
para adicionar ou apagar os valores, respectivamente.
[ô]===================================================
eu colocaria nesta pasta C:\Documents and Settings\All Users\Menu Iniciar\Programas\Inicializar
.exe ou atalho tenta ai
desculpe pela resposta fora do padrão
.exe ou atalho tenta ai
desculpe pela resposta fora do padrão
Não Deu fiquei com o mesmo problema
Teste esta ferramenta talvez possa te ajudar
http://www.baixaki.com.br/download/autoruns.htm
http://www.baixaki.com.br/download/autoruns.htm
Tópico encerrado , respostas não são mais permitidas