| Autor |
Beitrag |
Segaja
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Di 12.04.05 12:52
Moderiert von Tino: Abgetrennt aus: Fremden Task beenden
jetzt habe ich nur noch ein kleines schönheitsproblem. und zwar:
wenn ich das programm ausführe, beendet es den task, wie es auch vorgesehen ist, aber das symbol von diesem task steht immernoch im systray, bis ich einmal mit der maus darüber gehe.
gibt es einen refreshbefehl für den systray, und wenn ja, wie heißt er?
|
|
Hansi@OMG
      
Beiträge: 304
Vista
Delphi 2006 Prof., Lazarus
|
Verfasst: Di 12.04.05 12:58
Delphi-Quelltext 1:
| SendMessage(FindWindow('Progman', 'Program Manager'),WM_COMMAND,106597,0); |
Damit müsste es gehen.
_________________ Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Di 12.04.05 13:19
Hansi@OMG hat folgendes geschrieben: | Delphi-Quelltext 1:
| SendMessage(FindWindow('Progman', 'Program Manager'),WM_COMMAND,106597,0); |
Damit müsste es gehen. |
soll da villeicht Program stehen?
jedenfalls geht es so nicht.
Moderiert von raziel: Color- durch Highlight-Tags ersetzt.
|
|
Hansi@OMG
      
Beiträge: 304
Vista
Delphi 2006 Prof., Lazarus
|
Verfasst: Di 12.04.05 13:42
Nein, da soll Progman stehen, dass ist normalerweise das Handle des Systraymanagers von Windows.
_________________ Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Di 12.04.05 20:36
aber damit geht es leider nicht.
|
|
Radioactive
      
Beiträge: 179
Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
|
Verfasst: Di 12.04.05 20:51
Ein Handle von der TNA (TrayNotifictaionArea) bekommt man so:
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:
| var shellt, tray, sysp, toolb: hWnd;
shellt := FindWindow('','Shell_TrayWnd'); if shellt <> 0 then begin tray := FindWindowEx('','shellt','','TrayNotifyWnd'); if tray <> 0 then begin sysp := FindWindowEx('',tray,'','SysPager'); if sysp <> 0 then begin toolb := FindWindowEx('',sysp,'Infobereich','ToolbarWindow32'); if toolb <> 0 then begin SendMessage(toolb,WM_COMMAND,106597,0); end else ShowMEssage('ToolbarWindow32 nicht gefunden'); end else ShowMessage('SysPager nicht gefunden'); end else ShowMessage('TrayNotifyWnd nicht gefunden'); end else ShowMessage('Shell_TrayWnd nicht gefunden'); |
Kann den Code jetzt leider nicht testen. Hoffe, er bringt euch was.
_________________ Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Di 12.04.05 21:07
wow, so lang?
muss das so übernommen werden? und was steht bei // ...???
|
|
Radioactive
      
Beiträge: 179
Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
|
Verfasst: Di 12.04.05 21:10
Tut mir leid, aber Microsoft hat alle diese Komponenten übereinandergelegt, da wird es etwas länger.
//... steht für
Delphi-Quelltext
War nur zu faul ein begin zu tippen 
_________________ Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Di 12.04.05 21:18
bin heute etwas begriffsstutzig. das is mein 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: 57: 58: 59: 60:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tlhelp32;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end;
procedure TForm1.FormCreate(Sender: TObject); begin KillTask('Kill 1'); KillTask('Kill 2'); Application.Terminate; end;
end. |
da soll jetzt noch ein refresh für den systray neben der uhr rein, der vor dem Application.Terminate; ausgeführt wird.
|
|
Radioactive
      
Beiträge: 179
Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
|
Verfasst: Di 12.04.05 21:22
Probier mal aus, ob es jetzt klappt.
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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tlhelp32;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private procedure RefreshTNA; public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end;
procedure TForm1.FormCreate(Sender: TObject); begin KillTask('Kill 1'); KillTask('Kill 2'); RefreshTNA; Application.Terminate; end;
procedure TForm1.RefreshTNA; var shellt, tray, sysp, toolb: hWnd; begin shellt := FindWindow('','Shell_TrayWnd'); if shellt <> 0 then begin tray := FindWindowEx('','shellt','','TrayNotifyWnd'); if tray <> 0 then begin sysp := FindWindowEx('',tray,'','SysPager'); if sysp <> 0 then begin toolb := FindWindowEx('',sysp,'Infobereich','ToolbarWindow32'); if toolb <> 0 then begin SendMessage(toolb,WM_COMMAND,106597,0); end else ShowMEssage('ToolbarWindow32 nicht gefunden'); end else ShowMessage('SysPager nicht gefunden'); end else ShowMessage('TrayNotifyWnd nicht gefunden'); end else ShowMessage('Shell_TrayWnd nicht gefunden'); end;
end. |
_________________ Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Mi 13.04.05 12:44
das ist mein programm:
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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tlhelp32;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private procedure RefreshTNA; public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end;
procedure TForm1.RefreshTNA; var shellt, tray, sysp, toolb: hWnd; begin shellt := FindWindow('','Shell_TrayWnd'); if shellt <> 0 then begin tray := FindWindowEx('','shellt','','TrayNotifyWnd'); if tray <> 0 then begin sysp := FindWindowEx('',tray,'','SysPager'); if sysp <> 0 then begin toolb := FindWindowEx('',sysp,'Infobereich','ToolbarWindow32'); if toolb <> 0 then begin SendMessage(toolb,WM_COMMAND,106597,0); end else ShowMEssage('ToolbarWindow32 nicht gefunden'); end else ShowMessage('SysPager nicht gefunden'); end else ShowMessage('TrayNotifyWnd nicht gefunden'); end else ShowMessage('Shell_TrayWnd nicht gefunden'); end;
procedure TForm1.FormCreate(Sender: TObject); begin KillTask('Kill 1'); KillTask('Kill 2'); RefreshTNA; Application.Terminate; end;
end. |
und das sind die fehlermeldungen:
Quelltext 1: 2: 3: 4:
| [Error] Unit1.pas(60): Incompatible types: 'HWND' and 'String' [Error] Unit1.pas(65): Incompatible types: 'HWND' and 'String' [Error] Unit1.pas(68): Incompatible types: 'HWND' and 'String' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' |
// evt. hier schon ein Refresh senden
// SendMessage(tray,WM_COMMAND,106597,0);
muss ich da was ändern?
|
|
Tino
      

Beiträge: 9839
Erhaltene Danke: 45
Windows 8.1
Delphi XE4
|
Verfasst: Mi 13.04.05 13:01
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Mi 13.04.05 18:41
|
|
Radioactive
      
Beiträge: 179
Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
|
Verfasst: Mi 13.04.05 19:47
Sorry, war mein Fehler. Jetzt müsste es gehen.
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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tlhelp32;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private procedure RefreshTNA; public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end;
procedure TForm1.RefreshTNA; var shellt, tray, sysp, toolb: hWnd; begin shellt := FindWindow('','Shell_TrayWnd'); if shellt <> 0 then begin tray := FindWindowEx(0,'shellt','','TrayNotifyWnd'); if tray <> 0 then begin sysp := FindWindowEx(0,tray,'','SysPager'); if sysp <> 0 then begin toolb := FindWindowEx(0,sysp,'Infobereich','ToolbarWindow32'); if toolb <> 0 then begin SendMessage(toolb,WM_COMMAND,106597,0); end else ShowMEssage('ToolbarWindow32 nicht gefunden'); end else ShowMessage('SysPager nicht gefunden'); end else ShowMessage('TrayNotifyWnd nicht gefunden'); end else ShowMessage('Shell_TrayWnd nicht gefunden'); end;
procedure TForm1.FormCreate(Sender: TObject); begin KillTask('Kill 1'); KillTask('Kill 2'); RefreshTNA; Application.Terminate; end;
end. |
_________________ Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Do 14.04.05 09:14
fast. das is mein programm:
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: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Tlhelp32;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private procedure RefreshTNA; public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end;
procedure TForm1.RefreshTNA; var shellt, tray, sysp, toolb: hWnd; begin shellt := FindWindow('','Shell_TrayWnd'); if shellt <> 0 then begin tray := FindWindowEx(0,'shellt','','TrayNotifyWnd'); if tray <> 0 then begin sysp := FindWindowEx(0,tray,'','SysPager'); if sysp <> 0 then begin toolb := FindWindowEx(0,sysp,'Infobereich','ToolbarWindow32'); if toolb <> 0 then begin SendMessage(toolb,WM_COMMAND,106597,0); end else ShowMEssage('ToolbarWindow32 nicht gefunden'); end else ShowMessage('SysPager nicht gefunden'); end else ShowMessage('TrayNotifyWnd nicht gefunden'); end else ShowMessage('Shell_TrayWnd nicht gefunden'); end;
procedure TForm1.FormCreate(Sender: TObject); begin KillTask('Kill 1'); KillTask('Kill 2'); RefreshTNA; Application.Terminate; end;
end. |
und das sind die fehlermeldungen (eigentlich ist es nur eine):
Quelltext 1: 2:
| [Error] Unit1.pas(60): Incompatible types: 'HWND' and 'String' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' |
|
|
Tino
      

Beiträge: 9839
Erhaltene Danke: 45
Windows 8.1
Delphi XE4
|
Verfasst: Do 14.04.05 09:21
Dann schau dir doch mal die Zeile 60 genauer an. Wo könnte denn da wohl der Fehler liegen? 
Zuletzt bearbeitet von Tino am Do 14.04.05 09:25, insgesamt 2-mal bearbeitet
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Do 14.04.05 09:24
sorry, ich komme nicht auf den fehler.
|
|
Tino
      

Beiträge: 9839
Erhaltene Danke: 45
Windows 8.1
Delphi XE4
|
Verfasst: Do 14.04.05 09:26
Die Funktion FindWindowsEx ist wie folgt definiert:
Delphi-Quelltext 1:
| function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PChar): HWND; |
Wenn Du diese Funktion aufrufst dann musst Du bei der Parameterübergabe auch die richtigen Typen angeben.
Schau dir auch mal an wo genau der Cursor steht (Spalte) wenn du auf die Fehlermeldung doppelt drauf klickst.
|
|
Segaja 
      
Beiträge: 35
Win XP
D7 Enterprise
|
Verfasst: Do 14.04.05 09:52
wenn ich doppelt auf die fehlermeldung klicke, wird diese zeile markiert:
Delphi-Quelltext 1:
| tray := FindWindowEx(0,'shellt','','TrayNotifyWnd'); |
un der cursor steht hinter 'shellt',
|
|
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 14.04.05 09:58
Ich sag´s dir gern noch mal: Schau dir doch erst mal die Grundlagen an, bevor du versuchst, fremde Programme zu kicken. Dann wüsstest du den Unterschied zwischen einem String und einem HWND. 
|
|
|