Winflector tips and tricks - do you know...
... how to use Winflector API for file transferToday's article will be for aplication programmers. Apart from Winflector RPC functions that can be used to delegate arbitrary tasks to client-side DLL, Winflector API (gtrmapi.dll) defines many other useful functions. For instance, they can be used to collect environmental data (such as client IP) or for server to/from client file transfer.
Code below shows general Winflector API initialization, then transfers the client file "send_this.txt" to server and saves it under the name "from_client_IP.txt", where IP is client IP address.
Note that the same code can be used in application that is not run remotely. In such a case TApiInitialize() returns TAPI_NOCNETLIB and application can follow "not remoted execution" path.
In order to use Winflector API, access to the application's source is needed. Let's assume, for simplicity, that the application is written in C++.
The execution will proceed as follows:
- The application (running on the server) will initialize Winflector API by calling TApiIntialize()
- The application will call TApiGetFileFromTerminal() specifying name of the client file to get ("send_this.txt") and server name for the file ("from_client_IP.txt").
- TApiGetFileFromTerminal() will synchronously accomplish the transfer - on succesfull return file on the server is stored and ready to use.
What should be added to the application code?
- Interface initialization TApiInitialize()
- Reading client IP by calling TApiGetRemoteIPAddr(), since we want the client IP to be saved in the local filename
- Calling the function which downloads files from the client - TApiGetFileFromTerminal()
This is an example code which can be included in our application:
int aires, ftres;
// Initialize base API functions
aires = TApiInitialize();
if( aires != TAPI_SUCCESS )
switch( aires )
printf( "Application running in non-terminal mode\n");
printf("Cannot initialize API\n");
return 1; // error
ipAddr = TApiGetRemoteIPAddr();
ftres = TApiGetFileFromTerminal( destFileName, L"send_this.txt", &rerr, TAPI_F_FILEOVERWRITE );
if( ftres != TAPI_SUCCESS )
switch( ftres )
printf( "No connection to terminal\n");
printf( "Invalid function parameters\n");
printf( "System error. Error number from server: %d. Error number from terminal: %d.\n", rerr.lastSrvSysError, rerr.lastTrmSysError);
printf("Other error, transferred bytes: %u\n", rerr.nbytes);
return 1; // error
return 0; // file transferred successfully
The program should be linked with gtrmapi.lib. This is the simplest way to use Winflector API.
RPC procedures can be used in a similiar way. It involves more programming, since RPC calls have to be handled on the client side aswell. RPC can be used for a myriad of tasks, such as veryfing remote user's fingerprint, after all, it would be hard to be handle on the server, which can often be hundreds of miles away from the actual user. Therefore, the application running on the server can request the remote computer to handle this functionality.
To be continued.
... that you can see how much data your program sends over the net?
You can easily measure the network traffic (in KB of data) generated by your application running through the Winflector applicaton server. Run the Winflector thin client (wfc), enter login and application parameters. On the Debug tab check option 'Show network statistics'. See:
As usual, application windows will appear. Additionally, you will see a small window with useful information about network traffic. Use the application for some time and see how data in the additional window changes. You can see this way how many KB of data will be sent to perform different operations. The most useful of displayed information are:
- Rcv blocks - how many packets have been sent from the application to wfc client
- Rcv Network - how many kilobytes (KB) have been transferred from the application to wfc client
- Snd blocks - how many packets have been sent from wfc client to the application
- Snd Network - how many kilobytes (KB) have been transferred from wfc client to the application
In our example the application (which works on the server) has transferred 22 packets of data to wfc client. Data sent is 41 KB. The client application has sent to the application 64 packets with total length of 2 KB. In total, both sites sent 43 KB of data (which were uncompressed later, but that's another story). You can close the network statistics window at any time and continue work without collecting and displaying this information.
... how to create a desktop shortcut for frequently used programs
It's realy simple. Let's assume you frequently use mspaint.exe remotely. Instead of entering all application parameters in the Winflector client (wfc) each time, you can immediately create a shortcut on the desktop in three easy steps:
- define the address of the server which shares the application
- define the application name and working directory
- on Other tab press Create button
That's it! Icon with a shortcut to the program has been created on your desktop. Now just click on the shortcut, you do not need to enter the name of the application, the server address or any specific parameters every time. Even a user password can be saved in the shortcut if you checked this option on the Login tab. Then you can run the application by using the shortcut without having to enter any data. All shortcut information may additionally be encrypted so that nobody is able to read them - for this purpose check the Encrypt otion before pressing the Create button.
See the subsequent steps of creating a shortcut: