How can I send a Navision OutStream to a DLL?

Hello experts,

I'm trying to write a DLL to process a stream from Navision, but I just can't get it to work when I try to receive the stream from Navision.

I think it is up to the VarType wrong, but how can I convert it?

NAV Code:
IF ISCLEAR(Viewer) THEN BEGIN
  IF NOT CREATE(Viewer) THEN BEGIN
    EXIT(FALSE);
  END;
  CALCFIELDS(Item.Picture);
  IF Item.Picture.HASVALUE THEN BEGIN
    Item.Picture.CREATEOUTSTREAM(outStream);
    Viewer.LoadPicture(outStream);
  END;
END;

Delphi Code:
// VARIANT_BOOL _stdcall LoadPicture([in] VARIANT objStream);
function TNavisionImageView.LoadPicture(objStream: OleVariant): WordBool;
var
  Stream: TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  OleVariantToMemoryStream(objStream, Stream ) <== function/procedure I'am looking for
end;

Thanks and regards.
scholzfreeAsked:
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.

Geert GOracle dbaCommented:
i don't think you can create a stream like this towards another application.
Why not write this picture to file and then process that file ?

or have you seen this stream mechanism being used directly over applications ?

i would more think in the direction of pipes ...
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
scholzfreeAuthor Commented:
Yes, I can do with files, but that is too easy. ;)

I've seen a demo, but without code and presumably witten with .NET.
0
Geert GOracle dbaCommented:
i think you need to look in this direction a bit more:

http://en.wikipedia.org/wiki/Named_pipe#Named_pipes_in_Windows
0
scholzfreeAuthor Commented:
I have found this C# function, how can I translate this into Delphi?

public bool LoadFromNavision([In, MarshalAs(UnmanagedType.AsAny)] object COMStream, string fileName)
{
      bool flag1 = true;
      byte[] buffer1 = new byte[0xafc8];
      this.rwBytes = Marshal.AllocHGlobal(4);
      IStream COMStream1 = COMStream as IStream;
      FileStream writer = new FileStream(fileName, FileMode.CreateNew);
      int _rwBytes = 0;
      do
      {
            COMStream1.Read(buffer1, 0xafc8, this.rwBytes);
            _rwBytes = Marshal.ReadInt32(this.rwBytes);
            writer.Write(buffer1, 0, _rwBytes);
      }
      while (_rwBytes > 0);
      Marshal.FreeHGlobal(this.rwBytes);
      writer.Close();
      writer.Dispose();
      return flag1;
}
0
Geert GOracle dbaCommented:
huh, all the links relating to comstream i find in google are in russian
you'll need some translator i guess
i googled
delphi "comstream" -free
i first added -.com
but then nearly all sites ending with .com didn't show
i'll have a look on my delphi laptop tomorrow, i don't have delphi here atm
0
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.