<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Problem in Exporting a function from DLL' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Problem in Exporting a function from DLL' posted on the 'Delphi and Kylix' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 20:54:09 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 20:54:09 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Problem in Exporting a function from DLL</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/342353/342353/problem-in-exporting-a-function-from-dll/</link>
      <description>Hi,&lt;br /&gt;
      I am using Delphi5. I have made a DLL. In DLL there is a unit (with form i.e. GUI) named uExport. As you know that any form in the Delphi is itself a class. I have written a public function in this Form class.&lt;br /&gt;
      Now I want to import the same. To do so I had written Export and stdcall at the end of function declaration and definition.&lt;br /&gt;
The DLL is getting built properly. I also have a stand alone EXE to test DLL. &lt;br /&gt;
      When I use the exported function of DLL in said exe, it (exe) does not give any problem or error but at the same time it doesnot produce any result.&lt;br /&gt;
      To know the reason I debugged the DLL code but the control does not ever enter in the exported function of form class.&lt;br /&gt;
&lt;br /&gt;
      At the same time the control does enter in the exported function if it is global and not in the class.&lt;br /&gt;
&lt;br /&gt;
Please tell me how to export a function of any class from Delphi DLL?&lt;br /&gt;
 &lt;br /&gt;
Bye.&lt;br /&gt;
Chaitanya.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/342353/342353/problem-in-exporting-a-function-from-dll/</guid>
      <pubDate>Thu, 03 Aug 2006 03:43:15 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: Problem in Exporting a function from DLL</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/342353/342357/re-problem-in-exporting-a-function-from-dll/#342357</link>
      <description>: Hi,&lt;br /&gt;
:       I am using Delphi5. I have made a DLL. In DLL there is a unit (with form i.e. GUI) named uExport. As you know that any form in the Delphi is itself a class. I have written a public function in this Form class.&lt;br /&gt;
:       Now I want to import the same. To do so I had written Export and stdcall at the end of function declaration and definition.&lt;br /&gt;
: The DLL is getting built properly. I also have a stand alone EXE to test DLL. &lt;br /&gt;
:       When I use the exported function of DLL in said exe, it (exe) does not give any problem or error but at the same time it doesnot produce any result.&lt;br /&gt;
:       To know the reason I debugged the DLL code but the control does not ever enter in the exported function of form class.&lt;br /&gt;
: &lt;br /&gt;
:       At the same time the control does enter in the exported function if it is global and not in the class.&lt;br /&gt;
: &lt;br /&gt;
: Please tell me how to export a function of any class from Delphi DLL?&lt;br /&gt;
:  &lt;br /&gt;
: Bye.&lt;br /&gt;
: Chaitanya.&lt;br /&gt;
: &lt;br /&gt;
Perhaps you forgot the exports clause in the DLL. For any Win32 DLL, the export directive is ignored, only the exports clause in the DLL determines if a routine is exported.&lt;br /&gt;
Also you cannot export methods directly, because they consist of 2 pointers: the procedure pointer and the object pointer.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/342353/342357/re-problem-in-exporting-a-function-from-dll/#342357</guid>
      <pubDate>Thu, 03 Aug 2006 04:16:18 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: Problem in Exporting a function from DLL</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/342353/342486/re-problem-in-exporting-a-function-from-dll/#342486</link>
      <description>: : Hi,&lt;br /&gt;
: :       I am using Delphi5. I have made a DLL. In DLL there is a unit (with form i.e. GUI) named uExport. As you know that any form in the Delphi is itself a class. I have written a public function in this Form class.&lt;br /&gt;
: :       Now I want to import the same. To do so I had written Export and stdcall at the end of function declaration and definition.&lt;br /&gt;
: : The DLL is getting built properly. I also have a stand alone EXE to test DLL. &lt;br /&gt;
: :       When I use the exported function of DLL in said exe, it (exe) does not give any problem or error but at the same time it doesnot produce any result.&lt;br /&gt;
: :       To know the reason I debugged the DLL code but the control does not ever enter in the exported function of form class.&lt;br /&gt;
: : &lt;br /&gt;
: :       At the same time the control does enter in the exported function if it is global and not in the class.&lt;br /&gt;
: : &lt;br /&gt;
: : Please tell me how to export a function of any class from Delphi DLL?&lt;br /&gt;
: :  &lt;br /&gt;
: : Bye.&lt;br /&gt;
: : Chaitanya.&lt;br /&gt;
: : &lt;br /&gt;
: Perhaps you forgot the exports clause in the DLL. For any Win32 DLL, the export directive is ignored, only the exports clause in the DLL determines if a routine is exported.&lt;br /&gt;
: Also you cannot export methods directly, because they consist of 2 pointers: the procedure pointer and the object pointer.&lt;br /&gt;
: &lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Hi thanks for reply.&lt;br /&gt;
                      I have not forgotten to add Export clause in DLL.&lt;br /&gt;
Then what should be the reason? Please explain in detail.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/342353/342486/re-problem-in-exporting-a-function-from-dll/#342486</guid>
      <pubDate>Sat, 05 Aug 2006 03:39:57 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: Problem in Exporting a function from DLL</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/342353/342487/re-problem-in-exporting-a-function-from-dll/#342487</link>
      <description>: : : Hi,&lt;br /&gt;
: : :       I am using Delphi5. I have made a DLL. In DLL there is a unit (with form i.e. GUI) named uExport. As you know that any form in the Delphi is itself a class. I have written a public function in this Form class.&lt;br /&gt;
: : :       Now I want to import the same. To do so I had written Export and stdcall at the end of function declaration and definition.&lt;br /&gt;
: : : The DLL is getting built properly. I also have a stand alone EXE to test DLL. &lt;br /&gt;
: : :       When I use the exported function of DLL in said exe, it (exe) does not give any problem or error but at the same time it doesnot produce any result.&lt;br /&gt;
: : :       To know the reason I debugged the DLL code but the control does not ever enter in the exported function of form class.&lt;br /&gt;
: : : &lt;br /&gt;
: : :       At the same time the control does enter in the exported function if it is global and not in the class.&lt;br /&gt;
: : : &lt;br /&gt;
: : : Please tell me how to export a function of any class from Delphi DLL?&lt;br /&gt;
: : :  &lt;br /&gt;
: : : Bye.&lt;br /&gt;
: : : Chaitanya.&lt;br /&gt;
: : : &lt;br /&gt;
: : Perhaps you forgot the exports clause in the DLL. For any Win32 DLL, the export directive is ignored, only the exports clause in the DLL determines if a routine is exported.&lt;br /&gt;
: : Also you cannot export methods directly, because they consist of 2 pointers: the procedure pointer and the object pointer.&lt;br /&gt;
: : &lt;br /&gt;
: ------------------------------------------------------------------------&lt;br /&gt;
: &lt;br /&gt;
: Hi thanks for reply.&lt;br /&gt;
:                       I have not forgotten to add Export clause in DLL.&lt;br /&gt;
: Then what should be the reason? Please explain in detail.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
Without seeing the relevant parts of the code, there can be several reasons:&lt;br /&gt;
- exported name and imported name are different.&lt;br /&gt;
- parameter lists are not compatible (ie number, order and types are different)&lt;br /&gt;
- routine call is different (ie pascal vs c vs StdCall vs SafeCall)&lt;br /&gt;
- routine is not listed in exports clause (which is different from the export directive).&lt;br /&gt;
- routine is a method instead of a procedure or a function (methods consist of 2 pointers)&lt;br /&gt;
&lt;br /&gt;
Example of working DLL export:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
library ExampleDLL;

uses
  Dialogs; 

procedure ShowText(Text: PChar); StdCall;
begin
  ShowMessage(Text);
end;

exports
  ShowText;
end.
&lt;/pre&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

procedure ShowText(Text: PChar); StdCall; external 'ExampleDLL.dll';

implementation

{$R *.DFM}

procedure TForm2.Button1Click(Sender: TObject);
begin
  ShowText('Hello World');
end;

end.
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/342353/342487/re-problem-in-exporting-a-function-from-dll/#342487</guid>
      <pubDate>Sat, 05 Aug 2006 04:09:37 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
  </channel>
</rss>