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


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?


.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)


.NET Applications: How to Hide Assemblies And Unmanaged DLLs


One interesting task I’ve heard from one of our first customers is hidding assemblies and unmanaged DLLs. The target language is C#. Let’s explore how to solve this task with BoxedApp SDK…(click to read more)


How to embed Flash Player ActiveX using BoxedApp SDK


OK, let’s get started.

One of the most important features is embedding ActiveX into an application. BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry registers a virtual file in a virtual registry. In detail, it loads a specified file (LoadLibrary) and calls DllRegisterServer (exported from the DLL). All changes made by DllRegisterServer are saved in the virtual registry; the system registry remains unchanged… (click to read more)