DECLARE FUNCTION - DLL

DECLARE FUNCTION - DLL

am 04.01.2008 17:43:47 von zzzxtreme

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?

Re: DECLARE FUNCTION - DLL

am 04.01.2008 18:01:26 von nomailreplies

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:35d8e10e-3bb6-4d36-a379-21562d0745d4@u10g2000prn.google groups.com...
> 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?

Re: DECLARE FUNCTION - DLL

am 04.01.2008 18:41:09 von zzzxtreme

thanks i found out the problem

delphi WideString is actually OLE-String.

I just changed to PAnsiChar


On Jan 5, 1:01=A0am, "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=F1ol :http://asp.net.do/foros/
> ==================== =====
==============
>
> wrote in messagenews:35d8e10e-3bb6-4d36-a379-21562d0=
745d4@u10g2000prn.googlegroups.com...
> > hi i built a very simple dll with delphi
>
> > library Printing;
> > uses
> > =A0SysUtils, =A0Classes, Dialogs;
> > {$R *.res}
> > function Hello: WideString; stdcall;
> > begin
> > =A0 ShowMessage('test');
> > =A0result :=3D '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?