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

 

  Dicas

  Visual Basic    (Windows)

Título da Dica:  Iniciar programa automaticamente se eu programa estiver rodando antes do Shutdown
Postada em 31/8/2003 por Ð@®l@n            
Automatically open your app if it was running when Windows shut down

Want your application to automatically restart if it was running when Windows was shut down (like Explorer, Control Panel,
and other apps)? This involves using the RunOnce key in the Windows Registry. Put this code in the main form of your
application.

Public Const REG_SZ = 1
Public Const HKEY_CURRENT_USER = &H80000001

Private Sub Form_QueryUnload (Cancel as Integer, UnloadMode as Integer)
Dim hKey As Long
Dim strRunCmd As String

   If UnloadMode = vbAppWindows Then
      strRunCmd = App.Path & “\” & App.EXEName & “.EXE”
      Call RegCreateKey(HKEY_CURRENT_USER, “Software\Microsoft\Windows\CurrentVersion\RunOnce”, hKey)
      Call RegSetValueEx(hKey, “MyApp”, 0&, REG_SZ, ByVal strRunCmd, Len(strRunCmd)+1)
      Call RegCloseKey(hKey)
   Endif
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