Samples


IXFile installation package contains several sample programs and scripts to demonstrate how to use IXFile components in various programming environments and for distinct purposes. Samples are organized in three thematic groups: Introduction, MultiLock and ZIP Manager; each grup contains samples for one or more of the following programming languages: Visual C++, Visual Basic, Visual Basic .NET and Visual Basic Script (Active Server Pages and Windows Scripting Host). All samples are installed with complete project files, sources, headers, libraries, resources and executables to allow developers experiment without limits. IXFile objects used in samples are licensed with trial license key that expires 15 days after installation. When product is purchased, you can make samples to work without limitations by replacing trial license key in 'SetLicenseKey' calls with permanent key supplied by publisher. Samples are located in SAMPLES directory of the installation, groupped by programming language in subdirectories.

Introduction Sample (C++, VB, .NET, ASP)

This sample is an introduction to IXFile programming and demonstrates how to read and write data of various types - individual bits, integral values, floating point numbers, dates and currencies, decimal numbers, ANSI and Unicode texts in several formats and structured variants. It also illustrates how to use automatic file locking on shared files and demonstrates typical error handling. Please note that some data types are not available to all programming languages; 'decimal' is not available in Visual Basic Script and 'currency' is not available in .NET environment - file format, however, is maintained correctly. Application operates on file 'intro.dat' that must be located in the same directory as executable. Sample data file is copied during installation to allow quick start - just select data set from combo-box and click 'Load'. To add new data set use 'Save New' command which appends current data set (can be empty) at the end of file.

MultiLock Sample (C++, .NET)

This sample demonstrates how to use IXFile in multithreaded environment. Application creates three threads that operate on the same image file and perform independent transformations on the image: horizontal flip, vertical flip and color change. On completion resulting image is flipped horizontally and vertically and has false colors. Each thread creates its own IXFile object, opens image file for shared access and uses unbuffered transfer and manual locking to perform image operations without interference of other threads. 'Test with locking' should always generate correct image, without any distortions. 'Test without locking', which performs the same operations but does not lock image file, can introduce distortions as shown on screenshot below - intensity depends on your system performance. Application operates on file 'test.bmp' that must be located in the same directory as executable. Sample image file is copied during installation to allow quick start - just click 'Test...' button.

ZIP Manager Sample (C++, VB, .NET, ASP, WSH)

ZIP Manager is a sample program that demonstrates what you can do with IXFile in 'real life' applications. It is a simple ZIP manager which allows listing archive contents, adding, deleting and extracting archives. Please note that application operates on archives only and cannot pack or unpack files. This sample makes use of much of the IXFile functionality just to mention reading and writing data of various types, copying, shrinking, expanding and positioning file. Sample archive file 'test.zip' is copied during installation into application directory to allow quick start - just click 'Load' button and select file. Application can operate on any ZIP archives of your choice - for convenience a working copy of selected archive is made and all operations are performed on that copy to avoid overwriting your valuable data. Visual Basic Script samples (ASP and WSH) are limited in their functionality and allows only listing contents of archives.

Installation Notes

C++
C++ samples are built with all required libraries linked statically and do not depend on any other files. No external components or libraries are used and there are no additional system requirements. Samples are ready to run and do not require any configuration.
Visual Basic
Visual Basic samples require additional system components (VB runtime, Windows Common Controls, Automation components) which are contained in distribution package and installed along with IXFile if necessary. Samples are ready to run and do not require any configuration.
Visual Basic .NET
Visual Basic .NET samples require .NET Framework 1.1 or higher which is not included in distribution package and must be installed separately. Samples are ready to run and do not require any configuration.
Active Server Pages
ASP samples require server computer with Internet Information Services 4.0 or higher and client computer with Internet Explorer 5.0 or higher. Client must be able to connect to server through HTTP protocol with Internet Explorer, exactly the same way 'regular' web pages are accessed. Server and client can be located on the same machine for simplicity. Client does not require any additional configuration. Server requires configuration in order to IXFile samples be visible to client. First, install IXFile on server with COM component and ASP samples selected (other components are not required). Then, ensure that IIS is running correctly and default web site is available to client. Finally create virtual directory for IXFile samples and point it to physical directory where ASP samples are installed as shown below:
  1. open Internet Service Manager,
  2. right-click on 'Default Web Site' and select 'New -> Virtual Directory',
  3. when Virtual Directory Wizard opens, click 'Next',
  4. in 'Alias' box enter 'IXFile', click 'Next',
  5. browse to the folder when ASP samples are located ('...\SAMPLES\ASP'), click 'Ok', click 'Next',
  6. check permissions 'Read' and 'Run Scripts', click 'Next', click 'Finish',
  7. when wizard completes expand newly created 'IXFile' directory on left pane; 'Intro' and 'ZIP' subdirectories should appear,
  8. right-click on 'Intro' and select 'Properties',
  9. select 'Document' tab,
  10. check 'Enable Default Document',
  11. click 'Add',
  12. in 'Default Document Name' box enter 'intro.htm', click 'Ok',
  13. click 'Ok' to finish,
  14. right-click on 'ZIP' and select 'Properties',
  15. select 'Document' tab,
  16. check 'Enable Default Document',
  17. click 'Add',
  18. in 'Default Document Name' box enter 'ZIP.htm', click 'Ok',
  19. click 'Ok' to finish,
  20. close Internet Service Manager.
Server is now configured and you can view samples on client machine.

Start Internet Explorer and enter one of the following addresses to see relevant sample:

http://yourserver/IXFile/intro
http://yourserver/IXFile/ZIP

'yourserver' is the DNS name (or IP address) of the server on which previously configured IIS is running.

In order to run samples correctly on server some security requirements should be taken into consideration. When COM object is used in IIS application, the security context (access rights to files and directories) of this object is inherited directly from IIS login account. All anonymous access to an IIS web server is logged in under an anonymous login account. This account is created during IIS installation and has the name IUSR_SERVER, where SERVER is the computer name of the server, and specifies the rights for anonymous users accessing the server. In order to IIS load the object, it must be registered in a directory which security context has read and execute access. By default IXFile is installed in 'Program Files' directory which has appropriate access rights by default. Similarily 'SAMPLES\ASP' directory security context must have read access to allow IIS read ASP files. In addition, 'Intro' sample requires write access to its data file 'intro.dat' because user can change data set and save it. To avoid likely problem with it, 'Intro' application initially copies 'intro.dat' data file to Windows temporary directory which has appropriate rights by default. All user activities on client machine result in operations performed on this copy of data file. To start with original file just delete 'intro.dat' from Windows temporary directory.
Windows Scripting Host
WSH samples only require Windows Script 5.0 or higher which is installed along with Internet Explorer 5.0 or higher. Samples are ready to run and do not require any configuration.