Thema: Delphi Bildschirm sperren

Einzelnen Beitrag anzeigen

Tommy1988
(Gast)

n/a Beiträge
 
#10

Re: Bildschirm sperren

  Alt 23. Jun 2007, 09:49
Ok, wie man einen Desktop erstell weis ich nun:

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button3: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    odeskt, ndeskt:hdesk;
    ninit:boolean;
    coml:string;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  thr:longint;
begin
  thr:= getcurrentthreadid;
  label1.Caption:= inttostr(thr);
  odeskt:= getthreaddesktop(thr);
  label2.Caption:= inttostr(odeskt);
  ninit:= false;
  ndeskt:= 0;
  if paramcount = 0
  then coml:= inttostr(odeskt)
  else begin
    coml:= '';
    odeskt:= strtoint(paramstr(1))
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
switchdesktop(odeskt);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  sab:_SECURITY_ATTRIBUTES;
  pri:_PROCESS_INFORMATION;
  sti:STARTUPINFO;
  yes:boolean;
begin
  if not(ninit)
  then begin
    sab.nLength:= sizeof(sab);
    sab.lpSecurityDescriptor:= nil;
    sab.bInheritHandle:= true;
    ndeskt:= createdesktop(pchar('pokus'),
                           nil,
                           nil,
// DF_ALLOWOTHERACCOUNTHOOK,
                           0,
                           (DESKTOP_CREATEMENU
                            + DESKTOP_CREATEWINDOW
                            + DESKTOP_ENUMERATE
                            + DESKTOP_HOOKCONTROL
                            + DESKTOP_JOURNALPLAYBACK
                            + DESKTOP_JOURNALRECORD
                            + DESKTOP_READOBJECTS
                            + DESKTOP_SWITCHDESKTOP
                            + DESKTOP_WRITEOBJECTS),
                           @sab);
    ninit:= (ndeskt <> 0);
    if ninit
    then begin
      sti.cb:= sizeof(sti);
      sti.lpReserved:= nil;
      sti.lpDesktop:= pchar('pokus');
      sti.lpTitle:= nil;
      sti.dwX:= 0;
      sti.dwY:= 0;
      sti.dwXSize:= 0;
      sti.dwYSize:= 0;
      sti.dwXCountChars:= 0;
      sti.dwYCountChars:= 0;
      sti.dwFillAttribute:= FOREGROUND_BLUE;
      sti.dwFlags:= 0;
      sti.wShowWindow:= 0;
      sti.cbReserved2:= 0;
      sti.lpReserved2:= nil;
      sti.hStdInput:= 0;
      sti.hStdOutput:= 0;
      sti.hStdError:= 0;
      yes:= createprocess(pchar('C:\Desk.com'),
                          pchar(coml),
                          @sab,
                          @sab,
                          true,
                          (CREATE_SEPARATE_WOW_VDM),
                          nil,
                          nil,
                          sti,
                          pri);
      switchdesktop(ndeskt);
    end;
  end
  else switchdesktop(ndeskt);
end;
end.
Wenn der Code schlecht ist, sagt es mir bitte.

Nur wie stelle ich ein EditFeld dort rein (CreateWindow vielleicht) und frage ein Passwort ab?

Edit:

Ich kriegs nicht hin mit dem EditFeld
  Mit Zitat antworten Zitat