- Details of different steps
- Step 1: Establishing a connection to a WINDEV RPC or FTP server
- Step 2: Transmitting a file to a WINDEV FTP server
- Step 3: Retrieving a file from a WINDEV FTP server
- Step 4: Closing a connection to a WINDEV RPC or FTP server
Detailed use of WINDEV FTP/RPC
To upload and download files, you must comply with the following rules:
- Connect to a WINDEV FTP server with NetConnect. This function establishes a connection between WINDEV and the server and it provides a connection identifier.
- Upload, download files.
- Close the connection to the server with NetDisconnect.
- The TCP/IP communication protocol must be installed and an IP address must be defined.
- To create a WINDEV FTP/RPC server, all you have to do is use NetStartServer.
Details of different steps
Step 1: Establishing a connection to a WINDEV RPC or FTP server
To transfer files, a connection must be established to a WINDEV RPC or FTP server. The connection is established by NetConnect
. The code for establishing a connection must be found before the first "Net" function. The value returned by NetConnect
must be stored because this one will be used by the other "RPC" and "FTP" functions.
The code used to connect to an RPC server is as follows:
FUNCTION RPCConnection (Address, User, Password)
// Connection to an RPC server
ConnectionNum is int
ConnectionNum = NetConnect(Address, RPCServer, User, Password)
Remark: How to create a WINDEV RPC or FTP server?
To create a WINDEV RPC or FTP server, you must create an application that is using NetStartServer
to start the server. NetEndServer
is used to stop this server.
The WDRPCSRV.INI file that contains the connection rights granted to the users. This text file and the WINDEV RPC/FTP server are found in the same directory. It must contain a "password" section in which each entry point is a user name:
- The server must be accessible by all the client computers (via TCP/IP).
- To be accessible, the server must be started.
Step 2: Transmitting a file to a WINDEV FTP server
In the following example, a file is transmitted to the WINDEV FTP server (NetSendFile
). A progress bar is used to follow the progress of the transfer.
// Initialization code of "RPCClient" window
Transfer_Completed is boolean = False
Transfer_InProgress is boolean = False
Event("ProgBar_Transfer", "RPCClient", "SendFile")
ConnectFTP is int = NetConnect("18.104.22.168", FTPServer, "GUEST", "")
// -- Button for sending the transfer
IF Transfer_InProgress = True THEN
Error("A file transfer is in progress")
Transfer_Completed = False
Transfer_InProgress = True
IF NetSendFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", ...
"SendFile", 10) = False THEN
Info("The transfer failed")
// -- ProgBar_Transfer procedure: managing the current transfer
Message("Transfer in progress")
IF _EVE.wParam = _EVE.lParam THEN
Transfer_InProgress = False
Transfer_Completed = True
Step 3: Retrieving a file from a WINDEV FTP server
is used to retrieve a file found on the WINDEV FTP/RPC server.
: you can easily find out the list of directories and files found on a WINDEV FTP server. An example is available in the description of NetDirList
// -- Opening code of window
// Request a message from Windows
WM_MYMESSAGE is int
lpString is string fixed on 20 = "ProgBar_Main"
ConnectFTP is int
ConnectFTP = NetConnect("22.214.171.124", FTPServer, "GUEST", "")
WM_MYMESSAGE = CallDLL32("USER32", "RegisterWindowMessageA", &lpString)
// Branch the ProgBar procedure on this message
Event("UPDProgBar", "MAIN", WM_MYMESSAGE)
// -- Code of button for file retrieval
IF not NetGetFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", WM_MYMESSAGE, 10) THEN
Error("Error while transferring the file")
// -- UPDProgBar() procedure
// Display the progress bar
// If the entire file is transferred, reinitialize the progress bar
IF _EVE.wParam = _EVE.lParam THEN
// Transfer completed
// Transfer in progress
ProgressBar(_EVE.wParam, _EVE.lParam, "Transfer in progress")
Step 4: Closing a connection to a WINDEV RPC or FTP server
Once the files have been transferred, you must disconnect from the WINDEV RPC or FTP server. The disconnection is performed by NetDisconnect
. The disconnection code must be found after the last "Net" statement. The "ConnectionNum" variable, required for the disconnection, contains the value returned by NetConnect
The code used to disconnect from a WINDEV RPC server is as follows:
// Disconnection from a WINDEV RPC server
// ConnectionNum contains the value returned by NetConnect