如何定义系统热键?

qyc0921 2003-09-03 08:51:19
如何定义系统热键?比如说ctrl+Alt+V实现某种功能
...全文
248 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnssk 2003-09-03
  • 打赏
  • 举报
回复
function THotKeyManager.HotKeyByName(const Name: string): THotKeyItem;
var i: Integer;
begin
for i:= 0 to HotKeys.Count - 1 do
if CompareText(Name, HotKeys[i].Name) = 0 then
begin
Result:= HotKeys[i];
Exit;
end;
Result:= nil;
end;

procedure THotKeyManager.SetHotKeys(HotKeys: THotKeyCollection);
begin
FHotKeys.Assign(HotKeys);
end;

{ THotKeyCollection }

constructor THotKeyCollection.Create(Manager: THotKeyManager);
begin
FOwner:= Manager;
inherited Create(THotKeyItem);
end;

function THotKeyCollection.GetItem(Idx: Integer): THotKeyItem;
begin
Result:= THotKeyItem(inherited Items[Idx]);
end;

function THotKeyCollection.GetOwner: TPersistent;
begin
Result:= FOwner;
end;

procedure THotKeyCollection.SetItem(Idx: Integer; Item: THotKeyItem);
begin
inherited Items[Idx]:= Item;
end;

{ THotKeyItem }

procedure THotKeyItem.RegisterHotKey;
var Shift: Integer;
Key: Integer;
begin
if FHotKeyId <> 0 then
UnRegisterHotKey;
if FHotKey <> 0 then
begin
Shift:= 0;
if ssAlt in ShiftState then
Shift:= Shift + MOD_ALT;
if ssCtrl in ShiftState then
Shift:= Shift + MOD_CONTROL;
if ssShift in ShiftState then
Shift:= Shift + MOD_SHIFT;
Key:= KeyCodes[FHotKey];
FHotKeyId:= $A000 + ID;
Windows.RegisterHotKey(Application.Handle, FHotKeyId, Shift, Key);
end;
end;

procedure THotKeyItem.UnRegisterHotKey;
begin
if FHotKeyId <> 0 then
begin
Windows.UnRegisterHotKey(Application.Handle, FHotKeyId);
FHotKeyId:= 0;
end;
end;

procedure THotKeyItem.Assign(Item: TPersistent);
begin
if Item is THotKeyItem then
begin
HotKey:= THotKeyItem(Item).HotKey;
ShiftState:= THotKeyItem(Item).ShiftState;
end else
inherited Assign(Item);
end;

function THotKeyItem.GetDisplayName: string;
procedure AddShift(const S: string);
begin
if Result <> '' then
Result:= Result + ' + ';
Result:= Result + S;
end;
begin
if HotKey = '' then
Result:= inherited GetDisplayName
else if Name <> '' then
Result:= Name
else begin
if ssAlt in ShiftState then
AddShift('Alt');
if ssCtrl in ShiftState then
AddShift('Ctrl');
if ssShift in ShiftState then
AddShift('Shift');
AddShift(HotKey);
end;
end;

function THotKeyItem.GetNamePath: string;
begin
if Collection <> nil then
begin
if Name <> '' then
Result:= Format('%s[%s]',[Collection.GetNamePath, Name])
else
Result:= Format('%s[%d]',[Collection.GetNamePath, Index]);
end else
Result:= ClassName;
end;

function THotKeyItem.GetHotKey: string;
begin
Result:= KeyLabels[FHotKey];
end;

procedure THotKeyItem.SetHotKey(Key: string);
var i: Integer;
begin
i:= 0;
while i < High(KeyLabels) do
begin
Inc(i);
if CompareText(Key, KeyLabels[i]) = 0 then
Break;
end;
if i > High(KeyLabels) then
i:= 0;
FHotKey:= i;
if not (csDesigning in Manager.ComponentState) then
RegisterHotKey;
end;

procedure THotKeyItem.SetShiftState(State: TShiftState);
begin
FShiftState:= State;
if not (csDesigning in Manager.ComponentState) then
RegisterHotKey;
end;

function THotKeyItem.GetManager: THotKeyManager;
begin
Result:= THotKeyCollection(Collection).FOwner;
end;

{ PropEditors }

type
THotKeyProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;

function THotKeyProperty.GetAttributes: TPropertyAttributes;
begin
Result:= [paValueList, paMultiSelect];
end;

procedure THotKeyProperty.GetValues(Proc: TGetStrProc);
var i: Integer;
begin
for i:= 1 to High(KeyLabels) do
Proc(KeyLabels[i]);
end;

type
THotKeyManagerEditor = class(TComponentEditor)
protected
procedure GetPropEdit(Editor: TPropertyEditor);
public
procedure Edit; override;
end;

procedure THotKeyManagerEditor.GetPropEdit(Editor: TPropertyEditor);
begin
if Editor.GetName = 'HotKeys' then
Editor.Edit;
end;

procedure THotKeyManagerEditor.Edit;
var L: TDesignerSelectionList;
begin
L:= TDesignerSelectionList.Create;
try
L.Add(Component);
GetComponentProperties(L, [tkClass], Designer, GetPropEdit);
finally
L.Free;
end;
end;

procedure Register;
begin
RegisterComponents('ExtComps', [THotKeyManager]);
RegisterPropertyEditor(TypeInfo(string), THotKeyItem, 'HotKey', THotKeyProperty);
RegisterComponentEditor(THotKeyManager, THotKeyManagerEditor);
end;

cnssk 2003-09-03
  • 打赏
  • 举报
回复
一个热键控件的源码
unit HotKeyMgr;

{ Designed by Alexandre Guillien 11/11/1999

This component allows you to easily use hot keys in your project. These hot keys
are active even if your application is not active.

Component use :
Drop it on your Form/DataModule
Dbl click on it or Edit the HotKeys property.
In the editor, select the key and the optional shifts (Shift, Alt or Ctrl)
Give a name to the hot key (optional).
Finally, double click on the OnHotKeyActivation event in the object inspector.
The will create an event where you will be able to make your code.

E-Mail = AGuillien@csi.com
Mail : 12, rue Rhonat 69100 Villeurbanne FRANCE
}

interface

uses
Classes, Windows, Messages, Forms;

type
TShiftState = set of (ssShift, ssAlt, ssCtrl);

THotKeyManager = class;

THotKeyItem = class(TCollectionItem)
private
FHotKeyId: Integer;
FOnHotKey: TNotifyEvent;
FName: string;
{}
FHotKey: Integer;
FShiftState: TShiftState;
procedure SetShiftState(State: TShiftState);
function GetHotKey: string;
procedure SetHotKey(Key: string);
function GetManager: THotKeyManager;
protected
function GetDisplayName: string; override;
{}
procedure RegisterHotKey;
procedure UnRegisterHotKey;
{}
property HotKeyId: Integer read FHotKeyId;
property Manager: THotKeyManager read GetManager;
public
function GetNamePath: string; override;
{}
procedure Assign(Item: TPersistent); override;
published
property Name: string read FName write FName;
property ShiftState: TShiftState read FShiftState write SetShiftState;
property HotKey: string read GetHotKey write SetHotKey;
property OnHotKeyActivation: TNotifyEvent read FOnHotKey write FOnHotKey;
end;

THotKeyCollection = class(TCollection)
private
FOwner: THotKeyManager;
function GetItem(Idx: Integer): THotKeyItem;
procedure SetItem(Idx: Integer; Item: THotKeyItem);
protected
function GetOwner: TPersistent; override;
public
constructor Create(Manager: THotKeyManager);
{}
property Items[Idx: Integer]: THotKeyItem read GetItem write SetItem; default;
end;

THotKeyManager = class(TComponent)
private
FHotKeys: THotKeyCollection;
procedure SetHotKeys(HotKeys: THotKeyCollection);
{}
function WMHotKey(var Msg: TMessage): Boolean;
protected
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{}
function HotKeyByName(const Name: string): THotKeyItem;
published
property HotKeys: THotKeyCollection read FHotKeys write SetHotKeys;
end;

procedure Register;

implementation

uses SysUtils, DsgnIntf, TypInfo;

const
KeyCodes: array[0..60] of Integer =
(0,
Ord('A'), Ord('B'), Ord('C'), Ord('D'), Ord('E'), Ord('F'), Ord('G'), Ord('H'),
Ord('I'), Ord('J'), Ord('K'), Ord('L'), Ord('M'), Ord('N'), Ord('O'), Ord('P'),
Ord('Q'), Ord('R'), Ord('S'), Ord('T'), Ord('U'), Ord('V'), Ord('W'), Ord('X'),
Ord('Y'), Ord('Z'),
Ord('1'), Ord('2'), Ord('3'), Ord('4'), Ord('5'), Ord('6'), Ord('7'), Ord('8'),
Ord('9'), Ord('0'),
VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_ESCAPE, VK_TAB, VK_INSERT, VK_DELETE,
VK_HOME, VK_END, VK_PRIOR, VK_NEXT);

KeyLabels: array[0..60] of string =
('',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12',
'Up', 'Down', 'Left', 'Right', 'Echap', 'Tab', 'Insert', 'Delete',
'Home', 'End', 'Page up', 'Page down');

function THotKeyManager.WMHotKey(var Msg: TMessage): Boolean;
var i: Integer;
begin
for i:= 0 to HotKeys.Count - 1 do
if Msg.wParam = HotKeys[i].HotKeyId then
begin
Result:= True;
if Assigned(HotKeys[i].OnHotKeyActivation) then
HotKeys[i].OnHotKeyActivation(HotKeys[i]);
Exit;
end;
Result:= False;
end;

constructor THotKeyManager.Create(AOwner: TComponent);
begin
FHotKeys:= THotKeyCollection.Create(Self);
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
Application.HookMainWindow(WMHotKey);
end;

destructor THotKeyManager.Destroy;
var i: Integer;
begin
if not (csDesigning in ComponentState) then
Application.UnHookMainWindow(WMHotKey);
for i:= 0 to HotKeys.Count - 1 do
HotKeys[i].UnRegisterHotKey;
FHotKeys.Free; FHotKeys:= nil;
inherited Destroy;
end;

procedure THotKeyManager.Loaded;
var i: Integer;
begin
inherited Loaded;
if not (csDesigning in ComponentState) then
for i:= 0 to HotKeys.Count - 1 do
HotKeys[i].RegisterHotKey;
end;

cnssk 2003-09-03
  • 打赏
  • 举报
回复
一个热键控件的源码
unit HotKeyMgr;

{ Designed by Alexandre Guillien 11/11/1999

This component allows you to easily use hot keys in your project. These hot keys
are active even if your application is not active.

Component use :
Drop it on your Form/DataModule
Dbl click on it or Edit the HotKeys property.
In the editor, select the key and the optional shifts (Shift, Alt or Ctrl)
Give a name to the hot key (optional).
Finally, double click on the OnHotKeyActivation event in the object inspector.
The will create an event where you will be able to make your code.

E-Mail = AGuillien@csi.com
Mail : 12, rue Rhonat 69100 Villeurbanne FRANCE
}

interface

uses
Classes, Windows, Messages, Forms;

type
TShiftState = set of (ssShift, ssAlt, ssCtrl);

THotKeyManager = class;

THotKeyItem = class(TCollectionItem)
private
FHotKeyId: Integer;
FOnHotKey: TNotifyEvent;
FName: string;
{}
FHotKey: Integer;
FShiftState: TShiftState;
procedure SetShiftState(State: TShiftState);
function GetHotKey: string;
procedure SetHotKey(Key: string);
function GetManager: THotKeyManager;
protected
function GetDisplayName: string; override;
{}
procedure RegisterHotKey;
procedure UnRegisterHotKey;
{}
property HotKeyId: Integer read FHotKeyId;
property Manager: THotKeyManager read GetManager;
public
function GetNamePath: string; override;
{}
procedure Assign(Item: TPersistent); override;
published
property Name: string read FName write FName;
property ShiftState: TShiftState read FShiftState write SetShiftState;
property HotKey: string read GetHotKey write SetHotKey;
property OnHotKeyActivation: TNotifyEvent read FOnHotKey write FOnHotKey;
end;

THotKeyCollection = class(TCollection)
private
FOwner: THotKeyManager;
function GetItem(Idx: Integer): THotKeyItem;
procedure SetItem(Idx: Integer; Item: THotKeyItem);
protected
function GetOwner: TPersistent; override;
public
constructor Create(Manager: THotKeyManager);
{}
property Items[Idx: Integer]: THotKeyItem read GetItem write SetItem; default;
end;

THotKeyManager = class(TComponent)
private
FHotKeys: THotKeyCollection;
procedure SetHotKeys(HotKeys: THotKeyCollection);
{}
function WMHotKey(var Msg: TMessage): Boolean;
protected
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{}
function HotKeyByName(const Name: string): THotKeyItem;
published
property HotKeys: THotKeyCollection read FHotKeys write SetHotKeys;
end;

procedure Register;

implementation

uses SysUtils, DsgnIntf, TypInfo;

const
KeyCodes: array[0..60] of Integer =
(0,
Ord('A'), Ord('B'), Ord('C'), Ord('D'), Ord('E'), Ord('F'), Ord('G'), Ord('H'),
Ord('I'), Ord('J'), Ord('K'), Ord('L'), Ord('M'), Ord('N'), Ord('O'), Ord('P'),
Ord('Q'), Ord('R'), Ord('S'), Ord('T'), Ord('U'), Ord('V'), Ord('W'), Ord('X'),
Ord('Y'), Ord('Z'),
Ord('1'), Ord('2'), Ord('3'), Ord('4'), Ord('5'), Ord('6'), Ord('7'), Ord('8'),
Ord('9'), Ord('0'),
VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_ESCAPE, VK_TAB, VK_INSERT, VK_DELETE,
VK_HOME, VK_END, VK_PRIOR, VK_NEXT);

KeyLabels: array[0..60] of string =
('',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12',
'Up', 'Down', 'Left', 'Right', 'Echap', 'Tab', 'Insert', 'Delete',
'Home', 'End', 'Page up', 'Page down');

function THotKeyManager.WMHotKey(var Msg: TMessage): Boolean;
var i: Integer;
begin
for i:= 0 to HotKeys.Count - 1 do
if Msg.wParam = HotKeys[i].HotKeyId then
begin
Result:= True;
if Assigned(HotKeys[i].OnHotKeyActivation) then
HotKeys[i].OnHotKeyActivation(HotKeys[i]);
Exit;
end;
Result:= False;
end;

constructor THotKeyManager.Create(AOwner: TComponent);
begin
FHotKeys:= THotKeyCollection.Create(Self);
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
Application.HookMainWindow(WMHotKey);
end;

destructor THotKeyManager.Destroy;
var i: Integer;
begin
if not (csDesigning in ComponentState) then
Application.UnHookMainWindow(WMHotKey);
for i:= 0 to HotKeys.Count - 1 do
HotKeys[i].UnRegisterHotKey;
FHotKeys.Free; FHotKeys:= nil;
inherited Destroy;
end;

procedure THotKeyManager.Loaded;
var i: Integer;
begin
inherited Loaded;
if not (csDesigning in ComponentState) then
for i:= 0 to HotKeys.Count - 1 do
HotKeys[i].RegisterHotKey;
end;

goomoo 2003-09-03
  • 打赏
  • 举报
回复
//注册系统热键 /////////////////////
//http://www.goomoo.net /////////////////////
//曾劲松 2003-9-3 /////////////////////

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure wmHotkey(var _msg:TMessage);message WM_HOTKEY;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

var
gAtom:ATOM;

procedure TForm1.wmHotkey(var _msg:TMessage);
begin
application.Restore;
setForegroundWindow(form1.Handle);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
gAtom:=globalAddAtom('www.goomoo.net');
registerHotkey(form1.Handle,gAtom,MOD_CONTROL,ord('A')); // Ctrl + A
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
unregisterHotkey(form1.Handle,gAtom);
globalDeleteAtom(gAtom);
end;

end.
goomoo 2003-09-03
  • 打赏
  • 举报
回复
// 这是正解
// http://www.goomoo.net
// 曾劲松 2003-9-3

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure wmHotkey(var _msg:TMessage);message WM_HOTKEY;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

var
gAtom:ATOM;

procedure TForm1.wmHotkey(var _msg:TMessage);
begin
application.Restore;
setForegroundWindow(form1.Handle);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
gAtom:=globalAddAtom('www.goomoo.net');
registerHotkey(form1.Handle,gAtom,MOD_CONTROL,ord('A')); // Ctrl + A
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
unregisterHotkey(form1.Handle,gAtom);
globalDeleteAtom(gAtom);
end;

end.
Drate 2003-09-03
  • 打赏
  • 举报
回复
呵呵,楼上的连这个贴子的主题 是什么都没有看清楚了

THotKey控件和RegisterHotKey控件的配合使用

我想注册一系统热键,但不在设计时注册,要在运行时通过按“设置”按钮,将THotKey1

组件中用户选定的组合键(比如:Ctrl+A;或Alt+Ctrl+R)设为系统热键(用RegisterHotKey)。请问该怎么样做?急用。

下面是Kingron的回答:

unit Unit1;

{ Copyright Kingron 2002 }

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, ValEdit, StdCtrls, ExtCtrls, ComCtrls;

type

TForm1 = class(TForm)

LabeledEdit1: TLabeledEdit;

HotKey1: THotKey;

Button1: TButton;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

Key,Shift:Word;

procedure wmhotkey(var Msg:TMessage);message WM_HOTKEY;

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

uses

Menus;

function ShiftStateToWord(Shift:TShiftState):Word;

begin

if ssShift in Shift then Result :=MOD_SHIFT;

if ssCtrl in Shift then Result :=Result or MOD_CONTROL;

if ssAlt in Shift then Result:=Result or MOD_ALT;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

T:TShiftState;

begin

ShortCutToKey(HotKey1.HotKey,Key,T);

Shift :=ShiftStateToWord(T);

RegisterHotKey(Handle,GlobalAddAtom('MyHotKey') - $C000,Shift,Key);

end;

procedure TForm1.wmhotkey(var Msg: TMessage);

begin

if (Msg.LparamLo = Shift) AND (Msg.LParamHi = Key) then

ShowMessage('OK');

end;

end.


cxz7531 2003-09-03
  • 打赏
  • 举报
回复
利用RegisterHotkey
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
procedure WMHOTKEY(var msg: TWMHOTKEY);message WM_HOTKEY;
end;

var
Form1: TForm1;
ID:ATOM;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
ID:= GlobalAddAtom('HotkeyMY');
RegisterHotkey(handle,ID,mod_control+mod_Alt,ord('V'));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotkey(handle,ID);
GlobalDeleteAtom(ID);
end;


procedure TForm1.WMHOTKEY(var msg: TWMHOTKEY);
begin
if msg.HotKey=ID then
showmessage('OK');
end;

end.
sy_315 2003-09-03
  • 打赏
  • 举报
回复
转帖:已经说很清楚啦,
利用GINA实现Ctrl+Alt+Del的拦截

WINDOWS NT/2000下如何屏蔽CTRL+ALT+DEL

前言

在WINDOWS 9X环境中我们可以使用SystemParametersInfo (SPI_SCREENSAVERRUNNING, 1,NULL, 0);来屏蔽CTRL+ALT+DEL,但在NT/2000环境下却行不通,即使使用WH_KEYBOARD_LL这个低级的键盘hook也无法拦截!笔者通过替换GINA DLL的方式很好地实现了在NT/2000下屏蔽CTRL+ALT+DEL的功能。

下载源代码 6K

一、原理

在NT/2000中交互式的登陆支持是由WinLogon调用GINA DLL实现的,GINA DLL提供了一个交互式的界面为用户登陆提供认证请求。在WinLogon初始化时,就向系统注册截获CTRL+ALT+DEL消息,所以其他程序就无法得到CTRL+ALT+DEL的消息。

WinLogon会和GINA DLL进行交互,缺省是MSGINA.DLL(在System32目录下)。微软同时也为我们提供的接口,自己

可以编GINA DLL来代替MSGINA.DLL。

WinLogon初始化时会创建3个桌面:

(1)、winlogon桌面:主要显示window 安全等界面,如你按下CTRL+ALT+DEL,登陆的界面等

(2)、应用程序桌面:我们平时见到的那个有我的电脑的界面

(3)、屏幕保护桌面:屏幕保护显示界面。

在用户登陆以后,按下CTRL+ALT+DEL键的时候,WinLogon回调用GINA DLL的输出函数:WlxLoggedOnSAS,

这时正处于winlogon桌面,我们只要直接将他转向应用程序桌面,系统就不会显示Windows安全那个界面,换一种说法

也就是用户按下CTRL+ALT+DEL后,不会起什么作用。当是我们在切换桌面的时候会出现屏幕闪动!

二、程序实现

GINA DLL要输出下列函数(winlogon会调用)

WlxActivateUserShell

WlxDisplayLockedNotice

WlxDisplaySASNotice

WlxDisplayStatusMessage

WlxGetStatusMessage

WlxInitialize

WlxIsLockOk

WlxIsLogoffOk

WlxLoggedOnSAS

WlxLoggedOutSAS

WlxLogoff

WlxNegotiate

WlxNetworkProviderLoad

WlxRemoveStatusMessage

WlxScreenSaverNotify

WlxShutdown

WlxStartApplication

WlxWkstaLockedSAS

为了简化编程,我们从MSGINA.DLL中动态获取上诉函数,在自定义的DLL中(以下称为NoReboot.DLL)中直接调用MSGINA.DLL

的函数即可。现在我们要处理的就是WlxLoggedOnSAS函数:

 

int WINAPI WlxLoggedOnSAS (

PVOID pWlxContext,

DWORD dwSasType,

PVOID pReserved)

{

HANDLE hMutex;

WriteInfo("WlxLoggedOnSAS "); //用于记录信息

if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL){ //屏蔽CTRL_ALT_DEL,也可以根据特定条件来决定是否要屏蔽

//我采用了Mutex来控制是否屏蔽,(注意:要用unicode)

hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, L"_ac952_z_cn_CTRL_ALT_DEL");

if (hMutex){

CloseHandle(hMutex);

WriteInfo("disble CTRL+ALT+DEL ");

return WLX_SAS_ACTION_NONE; //将屏幕切换到应用程序桌面,屏蔽掉CTRL+ALT+DEL

}

else

WriteInfo("not disble CTRL+ALT+DEL ");

}

return prcWlxLoggedOnSAS ( //这是我从MSGINA.DLL中获取的函数。

pWlxContext,

dwSasType,

pReserved);

}

我们要在自己的程序中调用hMutex = CreateMutex(NULL, FALSE, "_ac952_z_cn_CTRL_ALT_DEL");就可屏蔽CTRL+ALT+DEL。

三、安装和注意事项:

在编写GIAN DLL中要注意,GINA DLL使用的是unicode。

GINA DLL的安装:

键名 : _LOCAL_MACHINENT

变量名 : GinaDLL

变量类型 : [REG_SZ]

内容 : "你的GINA DLL的名称" 如:"NoReboot.DLL:

将你的GINA DLL(NoReboot.dll)拷贝到系统目录下(system32),重启机器,你的GINA DLL(NoReboot.dll)就会运行。

如果出现进不了你的系统,那你进入DOS后,将msgina.dll拷贝成你的GINA DLL(NoReboot.dll)就可进入了,或者进入

安全模式,删除掉那个键值。

 


1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧