|
|
|

| | | | | | | | |  |
 | 
 | Code source : unité LRJ_WinDesktop |  |

|  |
 | |  |

|
Description : cette unité contient les objets LRJ_TWinDesktop
et LRJ_TWinDesktopList. LRJ_TWinDesktop permet ouvrir, de créer ou de switcher sur un Desktop
et d'extraire des informations sur ce Desktop et LRJ_TWinDesktopList
liste les Desktops ouverts sous Windows.
L'unité est livrée avec une application de démonstration (
voir description plus loin
) qui utilise les fonctionnalités des
objets contenus dans l'unité. Les codes de l'application
sont livrés avec l'unité pour illustrer comment utiliser les objets de
cette unité. L'application de démonstration utilise les unités
LRJ_GridsPlus,
LRJ_WinStation et
LRJ_WinSID non livrées avec l'application.
L'unité LRJ_WinDesktop met en oeuvre les fonctions de Windows suivantes :
|
|
CreateDesktop
CreateDesktopEx
EnumDesktops
GetCurrentThreadId
GetThreadDesktop
GetUserObjectInformation
GetUserObjectSecurity
OpenDesktop
OpenInputDesktop
SetThreadDesktop
SetUserObjectInformation
SetUserObjectSecurity
SwitchDesktop
|
Déclarations publiques de l'unité
I
Télécharger l'application de démonstration
I
Exemples d'utilisations
Utilise les unités : Windows et
LRJ_ClassesPlus
.
Version : 1 du 10.01.2009
Auteur : Laurent Hède
Copyright : LorenJo
Nombre de lignes : 539
Réalisée sous : Delphi 6
Systèmes compatibles : NT4, 2000, XP, Vista, serveurs
Prix : 130.00 € H.T.
Déclarations publiques de l'unité :
unit LRJ_WinDesktop;
interface
uses
Windows,
LRJ_ClassesPlus;
function LRJ_CreateDesktopEx(const lpszDesktop: string; const dwFlags: DWORD; const dwDesiredAccess: DWORD;
const lpsa: PSecurityAttributes; const ulHeapSize: ULONG): HDESK;
..........
// Se charge par les Open ou Create. Consulter la doc Windows sur les Desktops pour les propriétés et
// l'utilisation des fonctionnalités
//------------OBJET----------------------------
LRJ_TWinDesktop = class(TObject)
..........
function Open(const AName: string; const fAllowOtherAccountHook: boolean; const Inheritable: boolean;
const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean; overload;
function Open(const IfAllowOtherAccountHook: boolean; const Inheritable: boolean;
const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean; overload;
function OpenDefaultDesktop(const IfAllowOtherAccountHook: boolean; const Inheritable: boolean;
const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean;
function OpenInputDesktop(const IfAllowOtherAccountHook: boolean; const Inheritable: boolean;
const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean;
function CreateDesktop(const AName: string; const ifAllowOtherAccountHook: boolean; const SecurityAttributes: PSecurityAttributes;
const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean;
function CreateDesktopEx(const AName: string; const ifAllowOtherAccountHook: boolean; const SecurityAttributes: PSecurityAttributes;
const HeapSize: ULONG; const AccesRights: DWORD = MAXIMUM_ALLOWED): boolean; // à
// partir de Vista et Serveur 2008
function OpenThreadDesktop: boolean;
function SetToCurrentThread: boolean;
function SetUserObjectSecurity(var pSIRequested: DWORD; const pSID: PSecurityDescriptor): boolean;
function GetUserObjectSecurity(var pSIRequested: DWORD; var pSID: PSecurityDescriptor): boolean; // Détruire
// PSecurityDescriptor par FreeMem si result = true
procedure CloseDesktop;
function SwitchToThisDesktop: boolean;
property IfOpen: boolean read GetIfOpen;
property Name: string read GetName write SetName;
property Handle: HDESK read MOHandle;
property TypeObject: string read GetTypeObject;
property UserSID: PSID read GetUserSID;
property IfAllowOtherAccountHook: boolean read GetIfAllowOtherAccountHook write SetIfAllowOtherAccountHook;
property InheritableHandle: boolean read GetInheritableHandle;
property IfReceivingInput: boolean read GetIfReceivingInput; //Après serveur 2003 et XP, sinon retourne false
property HeapSize: ULONG read GetHeapSize; //Après serveur 2003 et XP, sinon retourne 0
end;//-----------FIN--------------------------
// Se charge lorsqu'on renseigne WinStation. Utiliser Refresh que lorsque il y a un risque que de nouveaux
// Desktop aient été chargés depuis l'attribution de WinStation
//------------OBJET----------------------------
LRJ_TWinDesktopList = class(TObject)
..........
procedure Refresh;
function Count: integer;
property WinStation: HWINSTA read MOWinStation write SetWinStation;
property Desktops[const Index: integer]: LRJ_TWinDesktop read GetDesktop;
end;//-----------FIN--------------------------
|
Application de démonstration

Le ComboBox 'WinStation' contient les Windows Stations ouvertes.
En sélectionnant un Windows Station, la liste des Desktops ouverts dans cette Windows
Station est lister dans la ListBox intitulée 'Desktop'.
En sélectionnant un Desktop dans la ListBox, la grille est chargée avec les informations
extraite sur le Desktop.
Exemples d'utilisations
Charger la liste des Desktop ouverts de la Windows Station sélectionnée dans
combobox1 dans la listbox1.
var
zWS: LRJ_TWinStation;
zDeskTL: LRJ_TWinDesktopList;
i: integer;
begin
if ComboBox1.ItemIndex > -1 then
begin
ListBox1.Items.Clear;
ListBox1.Items.BeginUpdate;
zWS := LRJ_TWinStation.Create;
zWS.Open(ComboBox1.Items[ComboBox1.ItemIndex], false );
if zWS.IfOpen then
begin
zDeskTL := LRJ_TWinDesktopList.Create;
zDeskTL.WinStation := zWS.Handle;
for i:=0 to zDeskTL.Count-1 do
ListBox1.Items.Add(zDeskTL.Desktops[i].Name);
zDeskTL.Free;
end;
zWS.Free;
ListBox1.Items.EndUpdate;
end;
end;
|
Vous n'avez pas trouvé d'exemple répondant à votre problématique ?
Cliquez sur ce lien.
|
|
 |
 | |  |
|
|