PC Review


Reply
Thread Tools Rate Thread

DECLARE FUNCTION - DLL

 
 
zzzxtreme@gmail.com
Guest
Posts: n/a
 
      4th Jan 2008
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?
 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      4th Jan 2008
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/
======================================
<(E-Mail Removed)> wrote in message news:35d8e10e-3bb6-4d36-a379-(E-Mail Removed)...
> 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?



 
Reply With Quote
 
zzzxtreme@gmail.com
Guest
Posts: n/a
 
      4th Jan 2008
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" <nomailrepl...@nowhere.com> 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/
> ======================================
>
> <zzzxtr...@gmail.com> wrote in messagenews:35d8e10e-3bb6-4d36-a379-(E-Mail Removed)...
> > 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?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declare AUTO function Armin Zingler Microsoft VB .NET 1 26th Feb 2011 06:04 PM
Private Declare Function =?Utf-8?B?RGF2aWQgQS4=?= Microsoft Excel Programming 6 31st Jul 2007 06:38 PM
Lib parameter in Function Declare =?Utf-8?B?b2p2?= Microsoft Excel Programming 4 12th Jun 2007 07:40 AM
Declare and array in a function =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Programming 3 30th Sep 2006 03:41 AM
Declare new function? Duane Hookom Microsoft Access Getting Started 4 30th Nov 2004 06:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 PM.