BoxedApp Blog

BoxedApp: Tips'n'Tricks, Examples, Use Cases etc.

Delphi: why TStreamAdapter is not suitable for IStream-based virtual files?


Hello,

One delphi programmer wrote me that he tried to create a IStream-based virtual file using a TStreamAdapter. But it doesn’t work. Why?

The reason is quite simple: TStreamAdapter doesn’t provide a correct implementation of IStream.Clone. Check Classes.pas:

function TStreamAdapter.Clone(out stm: IStream): HResult;
begin
  Result := E_NOTIMPL;
end;

IStream.Clone is important method, BoxedApp SDK uses it. But TStreamAdapter just returns E_NOTIMPL. OK, but what’s the solution?

The solution is to create a new class derived from TStreamAdapter and implement IStream.Clone.

For example, if you need a TStreamAdapter based on TFileStream, the implementation would be the following:

type
  TCloneSA = class(TStreamAdapter)
  public
    Path: String;
  public
    function Clone(out stm: IStream): HResult; override; stdcall;
    destructor Destroy; override;
  end;

  { TCloneSA }

function TCloneSA.Clone(out stm: IStream): HResult;
var
  FS: TFileStream;
  S: TCloneSA;
begin
  FS := TFileStream.Create(Path, fmOpenReadWrite or fmShareDenyNone);
  S := TCloneSA.Create(FS, soOwned);
  S.Path := Path;

  result := S.QueryInterface(IStream, stm);
end;

BoxedApp SDK 2.1, BoxedApp Packer 2.2


Released new versions of products of the BoxedApp series: BoxedApp SDK 2.1, BoxedApp Packer 2.2.
[ Download demo versions ]

What’s new?


Packing Entire MS PowerPoint Presentation into a Single EXE


MS PowerPoint allows creating presentations viewable on any computer, even those that do not have the PowerPoint application installed. But what makes it really inconvenient is the necessity to click on the “Accept” button every time you open a file; besides, the number of files is so great… How nice would it be to turn this whole set into a single executable file! Let’s see how we can do that.


Launching .NET Applications From Memory


We’ve issued new update of the BoxedApp SDK and BoxedApp Packer, which includes new function BoxedAppSDK_ExecuteDotNetApplication


BoxedApp SDK 2.0.1, BoxedApp Packer 2.1.1


We’ve tested BoxedApp under new Windows from MS, Windows 7. A few issues found and fixed.

[FIXED] ShellExecute doesn’t run virtual EXE under Windows 7
[FIXED] ActiveX registering in a virtual registry may not work properly under Windows 7

A small fix for all Windows:

[FIXED] Launching a lot of child processes cause memory and handles leak

New feature of the BoxedApp Packer:

[NEW] Environment variables are supported in a virtual path.

[ Download demo version ]


BoxedApp SDK 2.0, BoxedApp Packer 2.1


Finally, we have made available the new releases with two extremely interesting features:

Let’s take a closer look at them


A virtual file based on IStream


Briefly

A new function, BoxedAppSDK_CreateVirtualFileBasedOnIStream, has been added to BoxedApp SDK.

What For?

To provide even greater flexibility, BoxedApp SDK now allows creating virtual files based upon IStream, the standard COM interface. A programmer can now solely define the behavior of a virtual file.


C++ / CLI – How To Use Managed C++ DLL when Microsoft Visual C++ Redistributable is not installed?


If your .NET application uses components written in Managed C++, you face the necessity to distribute Microsoft Visual C++ Redistributable with it. If one attempts to launch such application in a system that doesn’t have the corresponding Microsoft Visual C++ Redistributable installed, the user will get a warning “This application has failed to start because the application configuration is incorrect”. Why this happens, and can that be done without installing Microsoft Visual C++ Redistributable?


Use ActiveX components without registration


Many applications use ActiveX and COM components. But all ActiveXs should be registered in the system registry to be used properly. This is a problem:

  • registration in the registry requires admin rights
  • sometimes registration influences to other applications
    for example, your application uses Flash 7, but another application requires Flash 9
  • your application should register an ActiveX at startup and unregister it when ActiveX is not needed anymore
    for example, your application is so-called portable application

How to solve the task using BoxedApp?


.NET Runtime Embedding


If you are into developing .NET applications, you are likely to know that it requires .NET Runtime to have the success running them. If the runtime suite is not installed, whenever the program attempts to launch, it shows an ugly messagebox notifying you that mscoree.dll could not be found… (click to read more)