锁定鼠标我会
var ls:Trect;//ls为鼠标运动范围
begin
...
clipcursor(@ls);//clipcursor(nil)为解锁
end;
var ls:Trect;//ls为鼠标运动范围
begin
...
clipcursor(@ls);//clipcursor(nil)为解锁
end;
解决方案 »
- 新建DLL组件,有几个存在的接口,请问有什么用处!删除有什么大碍?
- 请问哪个朋友能推荐个winsockAPI编程的书(Delphi的)?
- 求助. dlephi调用子函数出错.提示是参数类型不一致.
- Access数据库我设置了密码,但是我的程序无法使用了。
- 100分有关线程数组创建和终止的高难问题!Delphi高手请进!
- 非OLE的Excel导出的问题(up有分!)
- delphi DLL开发模式,共享全局变量问题
- 请问,C/S作远程数据库.必须要用MSSQL一类吗?用ACCESS可以作吗?例如局域网中的.
- WINDOWS窗口问题
- 呼吁中国的安全教育,同意的踢上一脚!
- 创建Form的问题
- 如何用delphi编写dos下带参数执行的命令。如: aa.exe 参数1 参数2
by Barry Brannan, September 1997
([email protected])
Usage: 1. Drop TWinReboot component on a form.
2. Call WinReboot1.WinExit(flags) Where flags must be one of the following: EWX_LOGOFF - Shuts down processes and logs user off
EWX_REBOOT - Shuts down the restarts the system
EWX_SHUTDOWN - Shuts down system The following attributes may be combined (OR'd) with above flags EWX_POWEROFF - shuts down system and turns off the power.
EWX_FORCE - forces processes to terminate.
Example:
WinReboot1.WinExit(EWX_REBOOT or EWX_FORCE);
*)interfaceuses
Windows, Classes;type
TWinReboot = class(TComponent)
private
function SetPrivilege(privilegeName: string; enable: boolean): boolean;
public
function WinExit(flags: integer): boolean;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TWinReboot]);
end;function TWinReboot.SetPrivilege(privilegeName: string; enable: boolean): boolean;
var
tpPrev,
tp : TTokenPrivileges;
token : THandle;
dwRetLen : DWord;
begin
result := False; OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, token); tp.PrivilegeCount := 1;
if LookupPrivilegeValue(nil, pchar(privilegeName), tp.Privileges[0].LUID) then
begin
if enable then
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
tp.Privileges[0].Attributes := 0; dwRetLen := 0;
result := AdjustTokenPrivileges(token, False, tp, SizeOf(tpPrev), tpPrev, dwRetLen);
end;
CloseHandle(token);
end;
function TWinReboot.WinExit(flags: integer): boolean;
begin
Result := True;
SetPrivilege('SeShutdownPrivilege', true);
if not ExitWindowsEx(flags, 0) then
Result := False;
SetPrivilege('SeShutdownPrivilege', False);
end;end.
function SetPrivilege(privilegeName: string; enable: boolean): boolean;
var
tpPrev,
tp : TTokenPrivileges;
token : THandle;
dwRetLen : DWord;
begin
result := False; OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, token); tp.PrivilegeCount := 1;
if LookupPrivilegeValue(nil, pchar(privilegeName), tp.Privileges[0].LUID) then
begin
if enable then
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
tp.Privileges[0].Attributes := 0; dwRetLen := 0;
result := AdjustTokenPrivileges(token, False, tp, SizeOf(tpPrev), tpPrev, dwRetLen);
end;
CloseHandle(token);
end;
function WinExit(flags: integer): boolean;
begin
Result := True;
SetPrivilege('SeShutdownPrivilege', true);
if not ExitWindowsEx(flags, 0) then
Result := False;
SetPrivilege('SeShutdownPrivilege', False);
end;