这是 MIDAS 三层中的客户端应用程序。
点 Button1,再点 Button2,或先 Button2,再 Button1 后,Windows 关闭/注销时,此程序不能终止。
服务端程序启动或不启动都无所谓,结果都一样。高手快来帮忙啊。unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBClient, MConnect, SConnect;type
TForm1 = class(TForm)
Button1: TButton;
SocketConnection1: TSocketConnection;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
try
SocketConnection1.Open;
except
SocketConnection1.Close;
end;
// Application.MessageBox('ddd','ddd');
// MessageBox(Handle,'aaa','ddd',0);
// showmessage('ok');
end;procedure TForm1.Button2Click(Sender: TObject);
begin
// Application.MessageBox('ddd','ddd');
// MessageBox(Handle,'aaa','ddd',0);
showmessage('ok');
end;end.
点 Button1,再点 Button2,或先 Button2,再 Button1 后,Windows 关闭/注销时,此程序不能终止。
服务端程序启动或不启动都无所谓,结果都一样。高手快来帮忙啊。unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBClient, MConnect, SConnect;type
TForm1 = class(TForm)
Button1: TButton;
SocketConnection1: TSocketConnection;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
try
SocketConnection1.Open;
except
SocketConnection1.Close;
end;
// Application.MessageBox('ddd','ddd');
// MessageBox(Handle,'aaa','ddd',0);
// showmessage('ok');
end;procedure TForm1.Button2Click(Sender: TObject);
begin
// Application.MessageBox('ddd','ddd');
// MessageBox(Handle,'aaa','ddd',0);
showmessage('ok');
end;end.
解决方案 »
- 用delphi写个用户注册的程序。
- 求教:fastreport 如何判断是否已经打印?(急用)
- FastReport打印小问题问题,急急急急!!!!!!!!!!!
- 请问,在Delphi里面将生成的文本文件进行压缩,是用什么方法啊?
- 高手进来看看,程序报错了!
- 怎样删除StringGrid中显示的当前记录?
- 我新安装了Delphi7,但没有找到报表的功能,请问怎么回事?
- SQLSERVER里面的字符好像不区分大小写,我在排序时,大小写不能区分开来?高手帮忙?
- 怎样用流的形式把图片存到Access数据库里
- Delphi+WebSphere+Db2作企业级开发技术可行么?
- dword类型相当于VB的什么类型???
- 如何发送消息问题?
如果不手工关闭此程序,Windows 就不能关闭/注销了.
// TSocketConnection的SupportCallbacks 设为False即可,如:
SocketConnection1.SupportCallbacks := False;
----------------------------------------------------
杜克兄的办法确实解决了问题,那么有谁知道原因是什么?
callback[callback [ , function-attr-list] ] type-specifier [ptr-declarator] function-name(
[ [parameter-attribute-list] ] type-specifier [declarator]
, ...
);function-attr-listSpecifies zero or more attributes that apply to the function. Valid function attributes are local; the pointer attribute ref, unique, or ptr; and the usage attributes string, ignore, and context_handle. Separate multiple attributes with commas.type-specifierSpecifies a base_type, struct, union, enum type, or type identifier. An optional storage specification can precede type-specifier.ptr-declaratorSpecifies zero or more pointer declarators. A pointer declarator is the same as the pointer declarator used in C; it is constructed from the * designator, modifiers such as far, and the qualifier const.function-nameSpecifies the name of the remote procedure.parameter-attribute-listSpecifies zero or more directional attributes, field attributes, usage attributes, and pointer attributes appropriate for the specified parameter type. Separate multiple attributes with commas.declaratorSpecifies a standard C declarator such as identifiers, pointer declarators, and array declarators. For more information, see pointers and arrays. The parameter-name identifier is optional.Example[callback] void DisplayString([in, string] char * p1);
ResThe callback attribute declares a static callback function that exists on the client side of the distributed application. Callback functions provide a way for the server to execute code on the client.
The callback function is useful when the server must obtain information from the client. If server applications were supported on Windows 3.x, the server could make a call to a remote procedure on the Windows 3.x server to obtain the needed information. The callback function accomplishes the same purpose. The callback allows the server to query the client for information in the context of the original call.Callbacks are special cases of remote calls that execute as part of a single thread. A callback is issued in the context of a remote call. Any remote procedure defined as part of the same interface as the static callback function can call the callback function.
Handles cannot be used as parameters in callback functions. Because callbacks always execute in the context of a call, the binding handle used by the client to make the call to the server is also used as the binding handle from the server to the client.Callbacks can nest to any depth.
callback 属性声明了一个静态的回调函数,此回调函数存在于分布式应用程序的客户端。回调函数为服务器执行客户端的代码提供了一个途径。
当服务器必须从客户端得到信息时,回调函数是很有用的。如果在 Windows 3.x 上支持服务器应用程序,则服务器能够调用 Windows 3.x 服务器上的一个远程过程来得到需要的信息。回调函数完成同样的目的。回调允许服务器在最初调用的上下文中查询信息。
回调是远程调用的特殊情况,它作为单独的线程执行。回调在一个远程调用的上下文中执行。如同静态回调函数,定义成同一接口一部分的任何远程过程都能够称为回调函数。
在回调函数中,不能用句柄作为参数。因为回调总是在一个调用的上下文中执行,客户端用来进行调用服务器的绑定句柄,也被用作从服务器到客户端的绑定句柄。
回调能嵌套任意次数。
==========================================
从中看不出有什么问题。
按理说,我的服务端其实并未开(就连 ScktSrvr.exe 也未运行)。
难道说,允许了 SocketConnection 的 Callback 机制,就会产生问题吗?
怪的是,它还与 ShowMessage, MessageBox 有关系啊!