//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 

解决方案 »

  1.   

    //你参考参考//但我没有调试成功
    主  题:再问一个问题,怎样用代码使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;
    }