所谓有程序,是指分公司设立需要按照法定程序设立。
无实体,则是指分公司不享有法律上的独立人格,其法律虚拟的人格权,在总公司身上。
所以,有这么一句话。
(注:这个问题,一般为法学本科生纠结,非法学专业,就别研究这个了。看似简单,实际涉及整个公司人格制度,甚至公司的起源,一点儿都不好玩)
写一个类,给类分配一个窗口句柄,然后在窗口过程里查询关机或注销消息,然后再显示;不明白可以参考TTimer类给你个例子吧,两个单元,拿回去保存编译一下就行了:
program NoFormMsg
uses
SysUtils,
Windows,
Messages,
Classes,
NoFormMsgCls in 'NoFormMsgCls.pas'
var
MyNoForm: TNoFormMsgCls
msg:tagMsg
begin
{ TODO -oUser -cConsole Main : Insert code here }
MyNoForm := TNoFormMsgCls.Crerte
try
while True do begin
PeekMessage(msg, MyNoForm.Handle, 0, 0, PM_NOREMOVE)
if msg.message = WM_CLOSE then break
TranslateMessage(msg)
DispatchMessage(msg)
Sleep(1)
end
finally
MyNoForm.Free
end
end.
unit NoFormMsgCls
interface
uses
Windows, Classes, Messages, SysUtils
type
TNoFormMsgCls = class
private
FHandle:THandle
procedure WndProc(var msg: TMessage)
public
constructor Crerte()
destructor Destroy()override
property Handle: THandle read FHandle
end
implementation
{ TNoFormMsgCls }
constructor TNoFormMsgCls.Crerte
begin
FHandle := Classes.AllocateHWnd(WndProc)
end
destructor TNoFormMsgCls.Destroy
begin
Classes.DeallocateHWnd(FHandle)
inherited
end
procedure TNoFormMsgCls.WndProc(var msg: TMessage)
begin
with Msg do
if Msg = WM_QUERYENDSESSION then begin
if (LParam and ENDSESSION_LOGOFF) >0 then begin
Result := 0
MessageBox(FHandle, '注销啦!', '结束任务', MB_OK)
//PostMessage(FHandle, WM_CLOSE, 0, 0)
end
else begin
Result := 0
MessageBox(FHandle, '关机啦!', '结束任务', MB_OK)
//PostMessage(FHandle, WM_CLOSE, 0, 0)
end
end
else
Result := DefWindowProc(FHandle, Msg, wParam, lParam)
end
end.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)