DECLARE FUNCTION - DLL

Discussion in 'ASP .Net' started by zzzxtreme@gmail.com, Jan 4, 2008.

  1. Guest

    hi i built a very simple dll with delphi

    library Printing;
    uses
    SysUtils, Classes, Dialogs;
    {$R *.res}
    function Hello: WideString; stdcall;
    begin
    ShowMessage('test');
    result := 'blah';
    end;
    exports Hello;
    begin end.



    In VB.Net, i tired calling it. the ShowMessage executes, so that's a
    start. I get this error afterwards, SEHException - "External component
    has thrown an exception."

    this is how i declared it

    Declare Function Hello Lib "Printing.dll" () As String

    It fails on returning a string. Does anyone know why?
     
    , Jan 4, 2008
    #1
    1. Advertising

  2. Are you using Delphi 8 (Delphi.Net) ?

    If not, you'll only get unmanaged assemblies,
    which you'd need to create a wrapper for,
    or use the Source Forge version to enable Delphi 5+ for .Net usage:

    http://sourceforge.net/projects/delphinet

    More info on Delphi 8.0 Basics:
    http://www.delphibasics.co.uk/Net.html




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    <> wrote in message news:...
    > hi i built a very simple dll with delphi
    >
    > library Printing;
    > uses
    > SysUtils, Classes, Dialogs;
    > {$R *.res}
    > function Hello: WideString; stdcall;
    > begin
    > ShowMessage('test');
    > result := 'blah';
    > end;
    > exports Hello;
    > begin end.


    > In VB.Net, i tired calling it. the ShowMessage executes, so that's a
    > start. I get this error afterwards, SEHException - "External component
    > has thrown an exception."
    >
    > this is how i declared it
    >
    > Declare Function Hello Lib "Printing.dll" () As String
    >
    > It fails on returning a string. Does anyone know why?
     
    Juan T. Llibre, Jan 4, 2008
    #2
    1. Advertising

  3. Guest

    thanks i found out the problem

    delphi WideString is actually OLE-String.

    I just changed to PAnsiChar


    On Jan 5, 1:01 am, "Juan T. Llibre" <> wrote:
    > Are you using Delphi 8 (Delphi.Net) ?
    >
    > If not, you'll only get unmanaged assemblies,
    > which you'd need to create a wrapper for,
    > or use the Source Forge version to enable Delphi 5+ for .Net usage:
    >
    > http://sourceforge.net/projects/delphinet
    >
    > More info on Delphi 8.0 Basics:http://www.delphibasics.co.uk/Net.html
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq :http://asp.net.do/faq/
    > foros de asp.net, en español :http://asp.net.do/foros/
    > ======================================
    >
    > <> wrote in messagenews:...
    > > hi i built a very simple dll with delphi

    >
    > > library Printing;
    > > uses
    > >  SysUtils,  Classes, Dialogs;
    > > {$R *.res}
    > > function Hello: WideString; stdcall;
    > > begin
    > >   ShowMessage('test');
    > >  result := 'blah';
    > > end;
    > > exports Hello;
    > > begin end.
    > > In VB.Net, i tired calling it. the ShowMessage executes, so that's a
    > > start. I get this error afterwards, SEHException - "External component
    > > has thrown an exception."

    >
    > > this is how i declared it

    >
    > > Declare Function Hello Lib "Printing.dll" () As String

    >
    > > It fails on returning a string. Does anyone know why?
     
    , Jan 4, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    9,014
  2. classicist
    Replies:
    3
    Views:
    349
  3. Replies:
    1
    Views:
    1,415
    Jim Langston
    Nov 9, 2006
  4. Replies:
    2
    Views:
    701
    Triple-DES
    Feb 26, 2008
  5. H. Simpson
    Replies:
    4
    Views:
    348
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page