晕倒,你的dll里的form1都没创建,你show什么啊?当然出错!dll里的form是不会自动创建的!
解决方案 »
- 请问StringReplace是否支持通配符?
- 请教一个简单的DateTimePicker问题:
- 大家来看看这怎么办?灌水也加分。。。。。。。。。。。
- 大家出出主义吧!
- 我用SOCKET在客户端向服务端添加数据。急。。。。
- 在MDI的主窗口放一PageControl控件后,子窗口都被穩在里面看不出來,如何解決這個問題?
- 为什么在FastReport 4.7.3下页码显示错误
- 大侠 Barcode控件 如何在Quickreport上打印 帮帮忙
- 问一下关于内存偏移量的问题,谢谢
- 我需要一个驱动程序,那位大侠有啊
- 为什么可以将一个子类的值赋予一个父类类型的变量?
- 实现双机热备份,是不是还要改动软件结构?
因为初学,不是太会
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
procedure some;stdcall;
begin
showmessage('sdf');
{$R *.dfm}end.
我要在另一个工程里调用它该如何调用:
unit Unit_dll;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
procedure some;external 'project1.dll';
{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
begin
some;
end;end.
请问出什么错
The following example shows a DLL with two exported functions, Min and Max.library MinMax;
function Min(X, Y: Integer): Integer; stdcall;begin
if X < Y then Min := X else Min := Y;
end;function Max(X, Y: Integer): Integer; stdcall;begin
if X > Y then Max := X else Max := Y;
end;exports Min,
Max;beginend.If you want your DLL to be available to applications written in other languages, it抯 safest to specify stdcall in the declarations of exported functions. Other languages may not support Object Pascal抯 default register calling convention.
DLLs can be built from multiple units. In this case, the library source file is frequently reduced to a uses clause, an exports clause, and the DLL抯 initialization code. For example,library Editors;
uses EdInit, EdInOut, EdFormat, EdPrint;
exports InitEditors,
DoneEditors index 17 name Done,
InsertText name Insert,
DeleteSelection name Delete,
FormatSelection,
PrintSelection name Print,
...
SetErrorHandler;begin InitLibrary;
end.You can put exports clauses in the interface or implementation section of a unit. Any library that includes such a unit in its uses clause automatically exports the routines listed the unit抯 exports clauses梬ithout the need for an exports clause of its own.
Only routines that a library explicitly exports are available for importing by other libraries or programs.以上内容可在Delphi IDE下键入library,然后按F1得到.
unit MinMax;
interface
function Min(X, Y: Integer): Integer; stdcall;
function Max(X, Y: Integer): Integer; stdcall;
implementation
const DllName='MinMax.DLL';
function Min; external DllName;
function Min; external DllName;
end.
Dialogs;procedure Test;
begin
ShowMessage('Ok');
end;exports
Test;implementation
end.然后新建一个工程引用这个DLLprocedure Test; external 'DLLTest.dll';另:对于没有参数的过程不必要用stdcall。因为stdcall表示参数以堆栈形式(从右向左)传递,既然没有参数也就没必要用stdcall了