Autor Beitrag
Doc Morelli
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 07:59 
Hallo,

folgendes weiß ich schon:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
CreateDesktop('Oliver', 
                nil, 
                nil, 
                DF_ALLOWOTHERACCOUNTHOOK, 
                DESKTOP_CREATEMENU or 
                  DESKTOP_CREATEWINDOW or 
                  DESKTOP_ENUMERATE or 
                  DESKTOP_HOOKCONTROL or 
                  DESKTOP_JOURNALPLAYBACK or 
                  DESKTOP_JOURNALRECORD or 
                  DESKTOP_READOBJECTS or 
                  DESKTOP_SWITCHDESKTOP or 
                  DESKTOP_SWITCHDESKTOP, 
                nil); 
//Erstellt einen neuen Desktop
  SetThreadDesktop(Opendesktop('Oliver', 
                               DF_ALLOWOTHERACCOUNTHOOK, 
                               true, 
                               DESKTOP_CREATEMENU or 
                                 DESKTOP_CREATEWINDOW or 
                                 DESKTOP_ENUMERATE or 
                                 DESKTOP_HOOKCONTROL or 
                                 DESKTOP_JOURNALPLAYBACK or 
                                 DESKTOP_JOURNALRECORD or 
                                 DESKTOP_READOBJECTS or 
                                 DESKTOP_SWITCHDESKTOP or 
                                 DESKTOP_SWITCHDESKTOP));
//Soll bewirken, dass ein neues Fenster in neuem Desktop geöffnet wird.
  shellexecute(application.Handle, 
               'open', 
               'C:\Programme\Borland\Delphi7\Projects\Desktops\DesktopClosedpr.exe', 
               nil, 
               nil, 
               sw_shownormal);
//Öffnet neues Programm, was den Desktop dann wieder schließen soll.
end;

procedure TForm1.Button2Click(Sender: TObject); 
begin 
  switchdesktop(Opendesktop('Oliver', 
                            DF_ALLOWOTHERACCOUNTHOOK, 
                            true, 
                            DESKTOP_CREATEMENU or 
                              DESKTOP_CREATEWINDOW or 
                              DESKTOP_ENUMERATE or 
                              DESKTOP_HOOKCONTROL or 
                              DESKTOP_JOURNALPLAYBACK or 
                              DESKTOP_JOURNALRECORD or 
                              DESKTOP_READOBJECTS or 
                              DESKTOP_SWITCHDESKTOP or 
                              DESKTOP_SWITCHDESKTOP)); 
//Wechselt zum neuen Desktop
end;


Jetzt habe ich zwei kleine Probleme:
1. Das neue Fenser (DesktopClosedpr.exe) wird nicht im neuen Desktop angezeigt...
2. Ich hab mir sagen lassen, dass ich mir mit EnumDesktops alle verfügbaren Desktops anzeigen lassen kann, nur komme ich mit den Attributen für diese Funktion nicht ganz zurecht. Hab mir auch schon Das hier angesehen, bin aber damit nicht ganz zurecht gekommen...

Hoffe, mir kann jemand erklären, was ich beim Ersten Problem falsch gemacht habe und wie ich die Funktion EnumDesktops benutzen kann...

MFG Doc
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 23.08.04 09:15 
ausblenden Delphi-Quelltext
1:
TEnumDesktopFunc = function (lpszDesktopName:PChar; lParam:DWORD): Boolean; stdcall;					


Aus dieser heraus einfach in Ne StringListe die Namen aller Desktops abspeichern.

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Doc Morelli Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 09:37 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
TEnumDesktopFunc(list, DESKTOP_CREATEMENU or 
                               DESKTOP_CREATEWINDOW or 
                               DESKTOP_ENUMERATE or 
                               DESKTOP_HOOKCONTROL or 
                               DESKTOP_JOURNALPLAYBACK or 
                               DESKTOP_JOURNALRECORD or 
                               DESKTOP_READOBJECTS or 
                               DESKTOP_SWITCHDESKTOP or 
                               DESKTOP_SWITCHDESKTOP);


So bestimmt nicht, oder? Aber wie dann?

// Edit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
TEnumDesktopFunc = function (lpszDesktopName:PChar; lParam:DWORD): Boolean; stdcall;
{...}
implementation
var test: pchar;
    egal : integer;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
EnumDesktops(OpenWindowStation(nil, true, WINSTA_ENUMDESKTOPS), test, egal);
end;


Jetzt kommt eine Zugriffsverletzung... Was ist denn nun wieder falsch :?: :?: :?:
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 23.08.04 12:15 
So sollte es gehn:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function EnumDesktopsCallback(lpszDesktopName: PChar; lParam: TListBox): Boolean; stdcall;
begin
  lParam.Items.Add(lpszDesktopName);
  Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  hWinSta: THandle;
begin
  Listbox1.Clear;
  hWinSta := GetProcessWindowStation;
  EnumDesktops(hWinSta, @EnumDesktopsCallback, Integer(Listbox1));
  CloseWindowStation(hWinSta);
end;


Aber eine andere Frage... was hast du vor?? Du wühlst in den doch recht komplexen Security-APIs herum, hast aber noch Probleme mit einer recht simplen Callback-Funktion...? :?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Doc Morelli Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 13:13 
Motzi hat folgendes geschrieben:
Aber eine andere Frage... was hast du vor?? Du wühlst in den doch recht komplexen Security-APIs herum, hast aber noch Probleme mit einer recht simplen Callback-Funktion...? :?


So eine Art Desktopmanager... Mit verschiedenen Desktops halt...

Woran liegt es eigentlich, dass das neue Fenster
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  shellexecute(application.Handle,   
               'open',   
               'C:\Programme\Borland\Delphi7\Projects\Desktops\DesktopClosedpr.exe',   
               nil,   
               nil,   
               sw_shownormal);

nicht im neuen Desktop angezeigt wird???
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 23.08.04 13:59 
Doc Morelli hat folgendes geschrieben:
Woran liegt es eigentlich, dass das neue Fenster
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  shellexecute(application.Handle,   
               'open',   
               'C:\Programme\Borland\Delphi7\Projects\Desktops\DesktopClosedpr.exe',   
               nil,   
               nil,   
               sw_shownormal);

nicht im neuen Desktop angezeigt wird???

Daran, dass die Security-APIs und alles was damit zusammenhängt leider doch nicht so einfach ist.. ;)

Ne, im Ernst.. das was du vorhast ist doch recht komplex.. du solltest dich gut in das Thema einarbeiten und dich mit dem Security-Konzept von Windows (WindowStations und Desktops) vertraut machen.. ich empfehle dazu das Buch "Programming Windows Security" von Keith Brown!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Doc Morelli Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 14:04 
Hmm, sollte ich vllt. wirklich mal machen... Gibt es nicht irgendwo eine deutsche und kompetente Version mit dem Inhalt :?:
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 23.08.04 14:09 
Doc Morelli hat folgendes geschrieben:
Gibt es nicht irgendwo eine deutsche und kompetente Version mit dem Inhalt :?:

Nein.. bzw nicht dass ich wüsste.. Aber das Buch ist echt spitze und auch nicht sonderlich schwer zu verstehen..

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Doc Morelli Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 14:17 
ISBN hab ich ja nun, muss ich nur noch Zeit und Geld finden für das Buch :) :) :)
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 23.08.04 16:22 
Das Buch gibt es auch als Wiki kostenlos/offen:

(ist allerdings die neuere Version mit C#)

pluralsight.com/wiki...h.GuideBook.HomePage
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 23.08.04 18:06 
Oha.. für .NET gibts das auch schon.. interessant, danke für den Link!! :)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 23.08.04 18:07 
Man muß halt immer am Puls der Zeit bleiben ... nicht nur mit der Delphi-Version *g*
Doc Morelli Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.08.04 19:37 
Jo, danke nochmal für den Link. Kann mir das ja mal durchlesen, hab ja noch Ferien :D . Aber zurück zum Thema... :)

Gibt es eine Möglichkeit, einem Aktuellen Fenster einen bestimmten Desktop zuzuweisen??? Das währe eine sehr einfache Lösung, nur weiß ich halt nicht, ob sich das realisieren lässt.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 23.08.04 19:45 
Einem Fenster nicht... aber einem Thread wie du vielleicht schon festgestellt hast (immerhin hast du die Funktion SetThreadDesktop schon gefunden)... Mit Hilfe von GetWindowThreadProcessId und OpenThread sollte das ganze also kein Problem mehr darstellen. aber ich rate dir trotzdem dich ein bisschen mehr in das Thema einzuarbeiten..!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!