Hello,
dont know what's wrong with this code, I get always error 424 when I compile exe, but when I start it from vbproject, it run's without any problem?

Here is code:

Code:
Private hOpen As Long
Private hConnection As Long
Private hFile As Long
Private dwType As Long
Private dwSeman As Long
Private Sub Command1_Click()
    
    'Variables
    sServer = txtServer.Text
    sUser = txtUser.Text
    sPassword = txtPassword.Text
    sDir = txtDir.Text
    sLocal = App.Path & "\" & TxtFile.Text
    sRemote = TxtFileR.Text
    
    'Save values to remember
    SaveSetting "PutGet FTP", "Values", "Server", txtServer.Text
    SaveSetting "PutGet FTP", "Values", "User", txtUser.Text
    SaveSetting "PutGet FTP", "Values", "Password", txtPassword.Text
    SaveSetting "PutGet FTP", "Values", "Directory", txtDir.Text
    
'Open INTERNET
    hOpen = InternetOpen("PutGet FTP", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    If hOpen = 0 Then 'ZERO means Internet Coudn't Open
        MsgBox "Error: " & Err.LastDllError, 32, "Internet Conection Error"
        Status.Caption = "Disconnected..."
        Exit Sub
    End If
    Status.Caption = "Internet Open..."
    
    dwType = FTP_TRANSFER_TYPE_BINARY 'SET TO BINARY
    dwSeman = 0 'Set Conection Active
    hConnection = 0 'Reset Conection
    
'Connect to server
    hConnection = InternetConnect(hOpen, sServer, INTERNET_INVALID_PORT_NUMBER, sUser, sPassword, INTERNET_SERVICE_FTP, dwSeman, 0)
    If hConnection = 0 Then 'ZERO means can't connect to Server
        MsgBox "Error: " & Err.LastDllError, 32, "Server Conection Error"
        Status.Caption = "Disconnected..."
        Exit Sub
    End If
    Status.Caption = "Connected to Server..."

'Specify Initial Directory
    OpenDir = FtpSetCurrentDirectory(hConnection, sDir)
    If OpenDir = False Then 'False means specified directory is wrong
        MsgBox "Error: " & Err.LastDllError, 32, "Initial Directory Error"
        Status.Caption = "Disconnected..."
        If hConnection <> 0 Then 'Disconnect if is still conected
            Cerrar = InternetCloseHandle(hConnection)
        End If
        Exit Sub
    End If
    Status.Caption = "Directory Ready..."

'Put File
    Subir = FTPPutFile(hConnection, sLocal, sRemote, dwType, 0)
    If Subir = False Then 'False means couldn't send the file
        MsgBox "Error: " & Err.LastDllError, 32, "File Transfer Error"
        Status.Caption = "Disconnected..."
        If hConnection <> 0 Then 'Disconnect if is still conected
            Cerrar = InternetCloseHandle(hConnection)
        End If
        Exit Sub
    End If
    Status.Caption = "Sending File..."
    
'Close conection
    If hConnection <> 0 Then
        Cerrar = InternetCloseHandle(hConnection)
        Status.Caption = "Disconnected..."
    End If
    
End Sub

Private Sub Command2_Click()
    'Variables
    sServer = txtServer.Text
    sUser = txtUser.Text
    sPassword = txtPassword.Text
    sDir = txtDir.Text
    sLocal = App.Path & "\" & TxtFile.Text
    sRemote = TxtFileR.Text
    
    'Save values to remember
    SaveSetting "PutGet FTP", "Values", "Server", txtServer.Text
    SaveSetting "PutGet FTP", "Values", "User", txtUser.Text
    SaveSetting "PutGet FTP", "Values", "Password", txtPassword.Text
    SaveSetting "PutGet FTP", "Values", "Directory", txtDir.Text
    
'Open INTERNET
    hOpen = InternetOpen("CYSM FTP", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    If hOpen = 0 Then 'ZERO means Internet Coudn't Open
        MsgBox "Error: " & Err.LastDllError, 32, "Internet Conection Error"
        Status.Caption = "Disconnected..."
        Exit Sub
    End If
    Status.Caption = "Internet Open..."
    
    dwType = FTP_TRANSFER_TYPE_BINARY 'SET TO BINARY
    dwSeman = 0 'Set Conection Active
    hConnection = 0 'Reset Conection

'Connect to server
    hConnection = InternetConnect(hOpen, sServer, INTERNET_INVALID_PORT_NUMBER, sUser, sPassword, INTERNET_SERVICE_FTP, dwSeman, 0)
    If hConnection = 0 Then 'ZERO means can't connect to Server
        MsgBox "Error: " & Err.LastDllError, 32, "Server Conection Error"
        Status.Caption = "Disconnected..."
        Exit Sub
    End If
    Status.Caption = "Connected to Server..."

'Specify Initial Directory
    OpenDir = FtpSetCurrentDirectory(hConnection, sDir)
    If OpenDir = False Then 'False means specified directory is wrong
        MsgBox "Error: " & Err.LastDllError, 32, "Error de Directorio Inicial"
        Status.Caption = "Disconnected..."
        If hConnection <> 0 Then 'Disconnect if is still conected
            Cerrar = InternetCloseHandle(hConnection)
        End If
        Exit Sub
    End If
    Status.Caption = "Directory Ready..."

'Get File
    Bajar = FTPGetFile(hConnection, sRemote, sLocal, False, FILE_ATTRIBUTE_NORMAL, dwType Or INTERNET_FLAG_RELOAD, 0)
    If Bajar = False Then 'False means couldn't get the file
        MsgBox "Error: " & Err.LastDllError, 32, "File Transfer Error"
        Status.Caption = "Disconnected..."
        If hConnection <> 0 Then 'Disconnect if is still conected
            Cerrar = InternetCloseHandle(hConnection)
        End If
        Exit Sub
    End If
    Status.Caption = "Downloading File..."
    
'Close conection
    If hConnection <> 0 Then
        Cerrar = InternetCloseHandle(hConnection)
        Status.Caption = "Disconnected..."
    End If
    

End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
'Values to remember

    txtServer.Text = GetSetting("PutGet FTP", "Values", "Server")
    txtUser.Text = GetSetting("PutGet FTP", "Values", "User")
    txtPassword.Text = GetSetting("PutGet FTP", "Values", "Password")
    txtDir.Text = GetSetting("PutGet FTP", "Values", "Directory")
    TxtFile.Text = "Text.txt"
    TxtFileR.Text = "Text.txt"
    
End Sub
here is module:

Code:
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const FTP_TRANSFER_TYPE_BINARY = &H2
Public Const FTP_TRANSFER_TYPE_ASCII = &H1
Public Const INTERNET_INVALID_PORT_NUMBER = 0
Public Const INTERNET_SERVICE_FTP = 1
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const FILE_ATTRIBUTE_NORMAL = &H80

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Public Declare Function FTPPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Long
Public Declare Function FTPGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Afther compile code, not working ( error 424 ) ?