//pas
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure Label2MouseEnter(Sender: TObject);
procedure Label2MouseLeave(Sender: TObject);
procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
ShellApi;procedure TForm1.Label2MouseEnter(Sender: TObject);
begin
TLabel(Sender).Font.Color := clBlue;
TLabel(Sender).Font.Style := [fsUnderline];
end;procedure TForm1.Label2MouseLeave(Sender: TObject);
begin
TLabel(Sender).Font.Color := clWindowText;
TLabel(Sender).Font.Style := [];
end;procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ShellExecute(0, 'OPEN', PChar(TLabel(Sender).Caption), nil, nil, SW_NORMAL);
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 48
Width = 99
Height = 13
Caption = 'http://www.csdn.net'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
object Label2: TLabel
Left = 8
Top = 104
Width = 104
Height = 13
Caption = 'http://www.sohu.com'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
end
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure Label2MouseEnter(Sender: TObject);
procedure Label2MouseLeave(Sender: TObject);
procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
ShellApi;procedure TForm1.Label2MouseEnter(Sender: TObject);
begin
TLabel(Sender).Font.Color := clBlue;
TLabel(Sender).Font.Style := [fsUnderline];
end;procedure TForm1.Label2MouseLeave(Sender: TObject);
begin
TLabel(Sender).Font.Color := clWindowText;
TLabel(Sender).Font.Style := [];
end;procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ShellExecute(0, 'OPEN', PChar(TLabel(Sender).Caption), nil, nil, SW_NORMAL);
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 48
Width = 99
Height = 13
Caption = 'http://www.csdn.net'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
object Label2: TLabel
Left = 8
Top = 104
Width = 104
Height = 13
Caption = 'http://www.sohu.com'
OnMouseDown = Label1MouseDown
OnMouseEnter = Label2MouseEnter
OnMouseLeave = Label2MouseLeave
end
end
解决方案 »
- 想使用delphi将注册表读取到treeview中
- WindowProc只能全局吗?能在类里面用吗?
- 紧急,一个小问题!
- 图形函数的问题?
- [请教]Delphi7.0中使用TClientSocket进行Socket编程的问题
- 问各位个问题,有没有小工具可以把Delphi的代码转成VB或VB.net的
- 怎样进行数据库文件的备份和恢复!
- ado如何存取text类型的字段?
- 如何在程序中加入socket4支持代理,在线关注...等待中......
- 大家帮忙看看这几行代码,一时找不出问题来。
- 谁知道cocatalog对象的使用
- 请问我用Delphi6开发ASP组件,线程模式用哪一个?应该还要注意哪些问题?
主 题:再问一个问题,怎样用代码使Win2000休眠?
作 者:cdws222
所属论坛:C++ Builder
问题点数:50
回复次数:31
发表时间:2001-8-3 20:00:32
我们可以用ExitWindows来关机、重启等等,怎么来使Win2000休眠呢? 回复人: AlphaOne(总是第一个倒下) (2001-8-3 20:54:41) 得50分
在前面加入下面一段代码就可以了,我刚刚试过,没问题。(还重启了一回)
//-----------------------------------------------------------
HANDLE hToken; // handle to process token
TOKEN_PRIVILEGES tkp; // pointer to token structureBOOL fResult; // system shutdown flag// Get the current process token handle so we can get shutdown
// privilege.if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES ¦ TOKEN_QUERY, &hToken))
{
ShowMessage("OpenProcessToken failed.");
return;
}
// Get the LUID for shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;// Get shutdown privilege for this process.AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);// Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS)
{
ShowMessage("AdjustTokenPrivileges enable failed.");
return;
}