|
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. | NEI PREFERITI | .:: | RSS Forum | RSS News | NEWS web | NEWS software | |
| PUBBLICITA' | | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | | CERCA nel FORUM » | |
14-07-2003, 16.05.27 | #1 |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
trasferimento file
i pc sono collegati in rete lo devo fare in c++ sono un client ed un server datemi una mano vi prego |
14-07-2003, 16.52.33 | #2 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
La cosa più semplice è quella di interfacciarti con le API di Windows.
L' API in questione è CopyFile Se devi copiare l'intero contenuto di una cartella comprese le sottocartelle è un po più dura perchè devi creare una funzione ricorsiva che ti cerchi tutti i files e tutte le sottocartelle contenute. La cosa non è molto difficile, se cerchi su Internet qualcosa la trovi sicuramente. Ciao |
14-07-2003, 16.54.19 | #3 | |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
Quota:
|
|
14-07-2003, 17.15.37 | #4 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
Trovato qui
http://www.aewnet.com/newsgroups/rne...=97581&group=9 Routine che fa al caso tuo. La dove visualizza il nome ed il percorso del file tu devi aggiungere il codice per copiare il file (Y) |
14-07-2003, 17.19.01 | #5 | |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
Quota:
|
|
14-07-2003, 17.27.27 | #6 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
A beh, adesso le cose sono più chiare.
Avevo capito tutt'altra cosa. |
14-07-2003, 17.31.18 | #7 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
La cosa non cambia poi di molto.
Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean · hConnect [in] Valid handle to an FTP session. · lpszRemoteFile [in] Address of a null-terminated string that contains the name of the file to retrieve from the remote system. · lpszNewFile [in] Address of a null-terminated string that contains the name of the file to create on the local system. · fFailIfExists [in] BOOL that indicates whether the function should proceed if a local file of the specified name already exists. If fFailIfExists is TRUE and the local file exists, FtpGetFile fails. · dwFlagsAndAttributes [in] Unsigned long integer value that contains the file attributes for the new file. This can be any combination of the FILE_ATTRIBUTE_* flags used by the CreateFile function. For more information on FILE_ATTRIBUTE_* attributes, see CreateFile in the Platform SDK. · dwFlags [in] Unsigned long integer value that contains the flags that control how the function will handle the file download. The first set of flag values indicates the conditions under which the transfer occurs. These transfer type flags can be used in combination with the second set of flags that control caching. The application can select one of these transfer type values: FTP_TRANSFER_TYPE_ASCII Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents. FTP_TRANSFER_TYPE_BINARY Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method. FTP_TRANSFER_TYPE_UNKNOWN Defaults to FTP_TRANSFER_TYPE_BINARY. INTERNET_FLAG_TRANSFER_ASCII Transfers the file as ASCII. INTERNET_FLAG_TRANSFER_BINARY Transfers the file as binary. The following flags determine how the caching of this file will be done. Any combination of the following flags can be used with the transfer type flag. The possible values are: INTERNET_FLAG_HYPERLINK Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network. INTERNET_FLAG_NEED_FILE Causes a temporary file to be created if the file cannot be cached. INTERNET_FLAG_RELOAD Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. INTERNET_FLAG_RESYNCHRONIZE Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded. · dwContext [in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This is used only if the application has already called InternetSetStatusCallback to set up a status callback function. |
14-07-2003, 17.46.29 | #8 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
· hConnect
[in] Valid handle to an FTP session Questa te la crei con questa: Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long · lpszAgent Address of a string that contains the name of the application or entity calling the Internet functions (for example, Microsoft Internet Explorer). This name is used as the user agent in the HTTP protocol. · dwAccessType Type of access required. Can be one of these values: INTERNET_OPEN_TYPE_DIRECT Resolve all host names locally. INTERNET_OPEN_TYPE_PROXY Pass requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this case, the function proceeds as for INTERNET_OPEN_TYPE_DIRECT. INTERNET_OPEN_TYPE_PRECONFIG Retrieve the proxy or direct configuration from the registry. · lpszProxyName Address of a string that contains the name of the proxy server (or servers) to use if proxy access was specified. If this parameter is NULL, the function reads proxy information from the registry. For more information about this parameter, see the comments below. · lpszProxyBypass Address of an optional list of host names or IP addresses, or both, that are known locally. Requests to these names are not routed through the proxy. The list can contain wildcards, such as "157.55.* *int*", meaning any IP address starting with 157.55, or any name containing the substring "int", will bypass the proxy. If this parameter specifies the "<local>" macro as the only entry, the function bypasses any host name that does not contain a period. For example, "www.microsoft.com" would be routed to the proxy, whereas "internet" would not. If this parameter is NULL, the function reads the bypass list from the registry. · dwFlags Flag that indicates various options affecting the behavior of the function. Can be a combination of these values: INTERNET_FLAG_OFFLINE Satisfy download operations on this handle through the persistent cache only. If the item does not exist in the cache, the function returns an appropriate error code. INTERNET_FLAG_ASYNC Future operations on this handle may fail with ERROR_IO_PENDING. A status callback will be made with INTERNET_STATUS_REQUEST_COMPLETE. This callback will be on a thread other than the one for the original request. A status callback routine must be registered or the functions will be completed synchronously. BUON LAVORO |
15-07-2003, 09.41.14 | #9 | |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
Quota:
di quelli spiccioli spiccioli p.s nn ho mai programmato questo genere di cose... |
|
15-07-2003, 11.33.08 | #10 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
Non si tratta proprio di programmare, quanto di utilizzare le funzioni API nel modo corretto.
Vi sono dei valori costanti predefiniti da Microsfot che, opportunamente passati come parametro alle API, fanno in modo che queste eseguano una data operazione. Se programmai in C++ molto probabilmente non le devi definire, in quanto già incluse nei .h che devi richiamare per interfacciarti con le API di Windows. Ne riporto alcuni: Const FTP_TRANSFER_TYPE_UNKNOWN = &H0 Const FTP_TRANSFER_TYPE_ASCII = &H1 Const FTP_TRANSFER_TYPE_BINARY = &H2 Const INTERNET_DEFAULT_FTP_PORT = 21 Const INTERNET_SERVICE_FTP = 1 Const INTERNET_FLAG_PASSIVE = &H8000000 Const INTERNET_OPEN_TYPE_PRECONFIG = 0 Const INTERNET_OPEN_TYPE_DIRECT = 1 Const INTERNET_OPEN_TYPE_PROXY = 3 Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 Nel tuo caso hai bisogno di creare due passaggi 1) Aprire una connessione Internet 2) Aprire una connessione FTP 3) Chiudere le connesisoni aperte. In Windows, quando si parla di handles, ci si riferisce ad un valore numerico. Es: ·hConnect [in] Valid handle to an FTP session La funzione che ha come parametro hConnect necessita che prima di essere chiamata sia necessario impostare il suo handle. Il suo handle viene definito da un'altra funzione che deve necessariamente essere richiamata precedentemente, in quanto quella successiva è strettamente legata alla precedente. Veniamo al dunque: Definisciti due variabili ad esempio hConnection ed hOpen Poi creati la connessione ad internet hOpen = InternetOpen("Nome connessione", INTERNET_OPEN_TYPE_PRECONFIG, "", "", 0) InternetOpen è la prima API che si deve richiamare poi creati la connessione ad FTP hConnection = InternetConnect(hOpen, "Il tuo server FTP", INTERNET_DEFAULT_FTP_PORT, "La tua login", "La tua password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) Nota che hOpen viene passato come handle ad InternetConnect, questo perchè non puoi creare una connessione FTP se prima non apri una connessione ad Internet. A questo punto puoi cominciare a scaricare il file FtpGetFile hConnection, "Nome file", "nome file destinazione", False, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0 Anche qui FtpGetFile ha bisogno di un handle valido. Quest' ultimo è fornito dalla chiamata precedente, ossia InternetConnect Ora, poichè hai aperto due connessioni ad operazione conclusa devi chiuderle, come succede con i files, ne più ne meno. Altra API InternetCloseHandle hConnection InternetCloseHandle hOpen Questa è la procedura da adottare. Ora sta a te scriverla in C++ Buon Lavoro |
15-07-2003, 11.47.15 | #11 |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
ok mi hai chiarito molte xò ho ancora alcuni dubbi.
1)io devo trasferire tramite un richiesta http come si fa?? qualche esempio di codice mi verrebbe in aiuto 2)se ho una connessione fra due pc internet o intranet quindi che comunicano tramite http posso usare anche l'ftp per trasferire questi file , ti chiedo questo perchè le funzioni che mi hai dato tu sono relative all'ftp! o sbaglio se è così pardon aspetto risp e grazie ancora (Y) |
15-07-2003, 12.01.08 | #12 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
Mai provata.
Sappimi dire Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long · pCaller Address of the controlling IUnknown interface of the calling Microsoft® ActiveX® component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download. · szURL Address of a string value containing the URL to be downloaded. Cannot be set to NULL. · szFileName Address of a string value containing the name of the file to create for bits that come from the download. · dwReserved Reserved. Must be zero. · lpfnCB Address of the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL. Ciao |
15-07-2003, 12.15.41 | #13 |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
quindi dovrebbe essere questa la funzione che serve a me ora mi informo
|
15-07-2003, 12.18.17 | #14 | |
Hero Member
Registrato: 01-04-2003
Loc.: Sardegna
Messaggi: 685
|
Quota:
|
|
15-07-2003, 13.21.42 | #15 |
Gold Member
WT Expert
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
|
Cosa intendi con "questa è una funzione di vb nn standard di windows" ?
|
Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti) | |
Strumenti discussione | |
|
|
Discussioni simili | ||||
Discussione | Autore discussione | Forum | Risposte | Ultimo messaggio |
Estrattore di file .EXE di setup | juggler | Software applicativo | 0 | 01-04-2007 19.19.43 |
Gestione del trasferimento file (copia,taglia) con windows xp | m16shooter1 | Windows 7/Vista/XP/ 2003 | 15 | 23-02-2007 19.59.32 |
[Windows XP] Problemi con il masterizzatore DVD | Qgino | Hardware e Overclock | 13 | 16-10-2005 20.11.45 |
Imaging e Win Xp | Cico2000 | Windows 7/Vista/XP/ 2003 | 6 | 15-04-2005 19.01.01 |
problema con file .doc rovinato in office xp 2003...poi risolto... | cippico | Office suite | 0 | 30-04-2004 09.12.07 |