Convert from C++ to Delphi

Can anyone help me convert the 50-line method EnumerateEncoders() from C++ to Delphi. Listing here: http://www.leadtools.com/Help/LEADTOOLS/v15/DH/Wpf/TO/Tutorial_Save.htm.

It returns a list of WIC encoders and their extensions that are currently available.

It uses some Delphi 2010-specific WIC libraries, starting with TWICImage.ImagingFactory.CreateComponentEnumerator() as documented here: http://msdn.microsoft.com/en-us/library/ee690301%28v=VS.85%29.aspx.
tfield98Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

8080_DiverCommented:
No offense intended but this is the sort of request that most of us usually charge for. ;-)
0
tfield98Author Commented:
No offense taken.


I know!

But it seemed simple enough that I figured maybe someone was interested in the points and learning what I know about WIC.  If not, they can contact me to see if I'm interested in a consultant!  This is a hobby project, so I don't have a corporate budget!

Tom
0
aikimarkCommented:
According to one of the Leadtools engineers, they are working on updating the VCL interface for version 17.
http://support.leadtools.com/CS/forums/27047/ShowPost.aspx

Are you generating a .Net executable?  If so, there are some name spaces that might be a work-around.

You can subscribe to a notification thread, so you'll know when the VCL is updated:
http://www.leadtools.com/subscription/
0
tfield98Author Commented:
No solutoin, but aikimark's suggestion was helpful.
0
tfield98Author Commented:
Here's how to traverse the registry:


unit Raw;

interface

uses
  Classes,  Generics.Collections;

type
  TRawCodec  = class(TObject)
    private
      fFriendlyName: String;
      fFileExtensions: String;
    public
      Property FriendlyName: String read fFriendlyName write fFriendlyName;
      Property FileExtensions: String read fFileExtensions write fFileExtensions;
  end;

  TRawCodecs = class(TObject)
    private
      fListOfRawCodecs : TList<TRawCodec>;
    procedure AddRawCodecToList(aGUID: String);
    function GetRawCodec(aGUID: String): TRawCodec;
    function RAWGetListOfGUIDs(out aListOfGUIDs: TStringList): Boolean;
    public
      Property ListOfRawCodecs: TList<TRawCodec> read fListOfRawCodecs;
      constructor Create;
      destructor Destroy; override;
  end;

implementation

uses
  Windows,
  SysUtils,
  Registry;

function TRawCodecs.RAWGetListOfGUIDs( out aListOfGUIDs: TStringList):Boolean;
var
  regInstance: TRegistry;
begin
  regInstance := TRegistry.Create(KEY_ALL_ACCESS);
  regInstance.RootKey := WINDOWS.HKEY_LOCAL_MACHINE;
  try
    regInstance.OpenKeyReadOnly('SOFTWARE\Classes\CLSID\{7ED96837-96F0-4812-B211-F13C24117ED3}\Instance');
    regInstance.GetKeyNames(aListOfGUIDS);
    regInstance.CloseKey;
  except
    // eat it. List length will be zero for caller
  end;
  FreeAndNil(regInstance);
  Result :=(aListOfGUIDs.Count > 0);
end; { GetListOfGUIDs }

constructor TRawCodecs.Create;
var
  GUIDList: TStringList;
  KeyName: String;
begin
  GUIDList := TStringList.Create;
  RAWGetListOfGUIDs( GUIDList);
  fListOfRawCodecs := TList<TRawCodec>.Create;
  for KeyName in GUIDList do
    AddRawCodecToList(KeyName);
  FreeAndNil(GUIDList);
end; { Create }

function TRawCodecs.GetRawCodec( aGUID: String): TRawCodec;
var
  RegistryEntryForCodec: TRegistry;
begin
  RegistryEntryForCodec := TRegistry.Create(KEY_ALL_ACCESS);
  RegistryEntryForCodec.RootKey := WINDOWS.HKEY_LOCAL_MACHINE;
  RegistryEntryForCodec.OpenKeyReadOnly('SOFTWARE\Classes\CLSID\' + aGUID);
  Result := TRawCodec.Create;
  Result.FriendlyName := RegistryEntryForCodec.ReadString('FriendlyName');
  Result.FileExtensions := RegistryEntryForCodec.ReadString('FileExtensions');
  RegistryEntryForCodec.CloseKey;
  FreeAndNil(RegistryEntryForCodec);
end; { GetRawCodec }

procedure TRawCodecs.AddRawCodecToList( aGUID: String);
var
  RawCodec: TRawCodec;
begin
  RawCodec := GetRawCodec( aGUID);
  if Assigned(RawCodec) then
    fListOfRawCodecs.Add(RawCodec);
end; { AddRawCodecToList }

destructor TRawCodecs.Destroy;
begin
  FreeAndNil(fListOfRawCodecs);
  inherited;
end;  { Destroy}

end.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.