If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Verwijderd
1
2
3
4
5
6
7
8
| function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
var
ProcessID: DWORD;
begin
GetWindowThreadProcessId(hWnd, ProcessID);
if ProcessID = DWORD(lParam) then
Caption := IntToStr(hWnd);
end; |
Maar tnx voor de hulp
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Verwijderd
1
| GetWindowThreadProcessId(hWnd, @ProcessID); |
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
| Function TForm1.StartFile(Str : String) : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
var
ProcessID: DWORD;
begin
GetWindowThreadProcessId(hWnd, @ProcessID);
if ProcessID = DWORD(lParam) then
Caption := IntToStr(hWnd);
end;
var PCharArr:PChar;
pInfo:Process_Information;
sInfo:StartupInfo;
ItemToAdd : TListItem;
Msg: TMsg;
lpExitCode : DWORD;
begin
PCharArr := AllocMem(SizeOf(Char)*(Length(Str)+7));
try
FillChar (sInfo, SizeOf (sInfo), 0);
sInfo.cb := SizeOf (sInfo);
with sInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := startf_UseShowWindow or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_HIDE;
end;
Result := CreateProcess(nil,StrPCopy(PCharArr,(Str)),nil,nil,FALSE,0,nil,nil,sInfo,pInfo);
finally
freemem(PCharArr);
end;
ItemToAdd := ListView1.Items.Add;
ItemToAdd.Caption := IntToStr(pInfo.dwThreadId);
ItemToAdd.SubItems.Add(IntToStr(pInfo.dwProcessId));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hThread));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hProcess));
EnumThreadWindows(pInfo.hThread, @EnumWindProc, pInfo.dwProcessId);
End; |
StartFile('notepad.exe');
Alleen, ik krijg die windowhandle niet.
Maar als ik die laatste EnumThreadWindows functie via een button daarna uitvoer, krijg ik `m wel.
Hoe kan ik wachten in deze functie totdat de app gestart is?
Bij voorbaat dank
XL
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
met dank aan hvdberg voor het me laten herinneren
.edit: hmm ik zie dat jij ook degene bent van deze topic: [topic=489019]
je was er toch uit?
en zo niet, waarom ga je dan daar niet verder?
.edit2: oh wacht ik zie dat je het al over EnumThreadWindows () had... niet goed gelezen
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Ja dat was ik en ja dáár was ik uit.Op vrijdag 10 mei 2002 01:26 schreef .oisyn het volgende:
EnumThreadWindows ()
met dank aan hvdberg voor het me laten herinneren
.edit: hmm ik zie dat jij ook degene bent van deze topic: [topic=489019]
je was er toch uit?
en zo niet, waarom ga je dan daar niet verder?
.edit2: oh wacht ik zei dat je het al over EnumThreadWindows () had... niet goed gelezen![]()
Maar dit gaat te snel ofzo voor de PC.
Bij die andere had ik 2 knoppen. Dus tijd genoeg.
Maar dit is een ander onderwerp als die andere.
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Is dat zo?? HmmOp vrijdag 10 mei 2002 01:33 schreef .oisyn het volgende:
overigens hoef je het processID niet meer te controleren, aangezien de betreffende window altijd door de betreffende thread is gecreert
Maar ... het antwoord heb ik nu nog niet
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
je probleem is dus dat je de EnumThreadWindows () functie te vroeg uitvoert, zodat notepad dus nog geen kans gekregen heeft z'n window te creeeren...
Tja, je zou natuurlijk regelmatig kunnen kijken, met steeds korte wachtpauzes ertussen
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Maar hoe doe ik dat wachten?
Hoe kijk ik of tie klaar is?
[edit]
"Of ie bezig is" en "Waneer ie klaar is"
`t Is maar goed dat we weten waar we het over hebben
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
The PROCESS_INFORMATION structure is filled in by the CreateProcess function with information about a newly created process and its primary thread.
typedef struct _PROCESS_INFORMATION { // pi
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
} PROCESS_INFORMATION;
Members
hProcess
Returns a handle to the newly created process. The handle is used to specify the process in all functions that perform operations on the process object.
hThread
Returns a handle to the primary thread of the newly created process. The handle is used to specify the thread in all functions that perform operations on the thread object.
dwProcessId
Returns a global process identifier that can be used to identify a process. The value is valid from the time the process is created until the time the process is terminated.
dwThreadId
Returns a global thread identifiers that can be used to identify a thread. The value is valid from the time the thread is created until the time the thread is terminated.
Forget your fears...
...and want to know more...
(en dan zet je in je EnumWindProc een bepaalde variabele naar een bepaalde waarde, zodat de code die de hele tijd EnumThreadWindows aan het aanroepen is dat ie klaar is)
zoiets dus (* .oisyn is geen delphi kenner):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| in je EnumWindProc:
windowGevonden = true;
in de code die de hele tijd EnumThreadWindows aanroept:
windowGevonden = false;
while (!windowGevonden)
{
EnumThreadWindows (...);
Sleep (100);
} |
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Daar staat process/thread ID en handle
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Op die manier hangt ieOp vrijdag 10 mei 2002 01:43 schreef .oisyn het volgende:
simpel, gewoon EnumThreadWindows aan blijven roepen net zo lang tot je EnumWindProc wordt aangeroepen met de goeie window
(en dan zet je in je EnumWindProc een bepaalde variabele naar een bepaalde waarde, zodat de code die de hele tijd EnumThreadWindows aan het aanroepen is dat ie klaar is)
zoiets dus (* .oisyn is geen delphi kenner):
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14in je EnumWindProc: windowGevonden = true; in de code die de hele tijd EnumThreadWindows aanroept: windowGevonden = false; while (!windowGevonden) { EnumThreadWindows (...); Sleep (100); }
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
[edit]
Moet zijn:zoiets dus (* .oisyn is geen delphi kenner):
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14in je EnumWindProc: windowGevonden = true; in de code die de hele tijd EnumThreadWindows aanroept: windowGevonden = false; while (!windowGevonden) { EnumThreadWindows (...); Sleep (100); }
1
2
3
4
5
6
7
8
9
10
| in je EnumWindProc: in de code die de hele tijd EnumThreadWindows aanroept: windowGevonden := false; while (NOT windowGevonden) do Begin WindowGevonden := EnumThreadWindows(thread,functie,param); Sleep(100); End; |
Jij bent C programmeur
Forget your fears...
...and want to know more...
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Forget your fears...
...and want to know more...
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Hmmm dan doet ie `t alleen de 1e keerOp vrijdag 10 mei 2002 01:55 schreef Aetje het volgende:
Waarom heb je deze eigenlijk nodig? Als je aan het te creeren window enkele properties enzo wil toekennen, check de startupinfo struct es.
[edit]
[..]
Moet zijn:
code:
1 2 3 4 5 6 7 8 9 10 in je EnumWindProc: in de code die de hele tijd EnumThreadWindows aanroept: windowGevonden := false; while (NOT windowGevonden) do Begin WindowGevonden := EnumThreadWindows(thread,functie,param); Sleep(100); End;
Jij bent C programmeur
Als ik dan nog een process open, zet ie die 1e handle erneer, en niet de nieuwe.
Nope, dat was lulkoek.
Maar hij doet t niet op deze manier
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
ThanxOp vrijdag 10 mei 2002 01:55 converteerde Aetje mijn C-code naar Delphi-code
WindowGevonden := EnumThreadWindows(thread,functie,param);
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
?? Wrom?Op vrijdag 10 mei 2002 02:21 schreef .oisyn het volgende:
[..]
Thanx, maar die ene WindowGevonden moet weg:
[..]
Dan doet ie t niet meer, dan hangt ie
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Nee, want als je die wegdoet blijft ie in dat loopje hangenOp vrijdag 10 mei 2002 02:21 schreef .oisyn het volgende:
[..]
Thanx, maar die ene WindowGevonden moet weg:
[..]
EnumThreadWindows is een functie die een boolean waarde terug geeft. True als gelukt, False als gefaald. Je wil doorgaan tot ie gelukt is. Dan klopt het toch als je dit op deze manier doet? Je kent de return waarde toe aan een variabele
Forget your fears...
...and want to know more...
Of ik nou Result := False of True in die WinThreadProc zet, dat maakt geen verschil i.i.g
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Met 5 knoppen, en een ListView.
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ShellApi, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button3: TButton;
Button4: TButton;
ListView1: TListView;
Button5: TButton;
function ShowInstance(Pid : Integer) : Boolean;
function HideInstance(Pid : Integer) : Boolean;
Function StartFile(Str: String) : Boolean;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
public
protected
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Function TForm1.StartFile(Str : String) : Boolean;
var PCharArr:PChar;
pInfo:Process_Information;
sInfo:StartupInfo;
ItemToAdd : TListItem;
Msg: TMsg;
lpExitCode : DWORD;
windowGevonden : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
if ListView1.Items[ListView1.Items.Count - 1] <> nil Then
ListView1.Items[ListView1.Items.Count - 1].SubItems.Add(IntToStr(hWnd));
end;
begin
PCharArr := AllocMem(SizeOf(Char)*(Length(Str)+7));
try
FillChar (sInfo, SizeOf (sInfo), 0);
sInfo.cb := SizeOf (sInfo);
with sInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := startf_UseShowWindow or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_HIDE;
end;
Result := CreateProcess(nil,StrPCopy(PCharArr,(Str)),nil,nil,FALSE,0,nil,nil,sInfo,pInfo);
finally
freemem(PCharArr);
end;
ItemToAdd := ListView1.Items.Add;
ItemToAdd.Caption := IntToStr(pInfo.dwThreadId);
ItemToAdd.SubItems.Add(IntToStr(pInfo.dwProcessId));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hThread));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hProcess));
WindowGevonden := false;
while (NOT windowGevonden) do
Begin
WindowGevonden := EnumThreadWindows(pInfo.hThread,@EnumWindProc,0);
Sleep(100);
End;
End;
function TForm1.ShowInstance(Pid : Integer) : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
Result:=lParam=1234;
if Result then
ShowWindow(hWnd, SW_SHOWNORMAL);
end;
begin
EnumThreadWindows(Pid, @EnumWindProc, 1234);
End;
function TForm1.HideInstance(Pid : Integer) : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
Result:=lParam=1234;
if Result then
ShowWindow(hWnd, SW_HIDE);
end;
begin
EnumThreadWindows(Pid, @EnumWindProc, 1234);
End;
procedure TForm1.Button2Click(Sender: TObject);
begin
StartFile('notepad.exe');
//ListView1.Items[0].Selected := True;
// Button5Click(nil);
end;
procedure TForm1.Button3Click(Sender: TObject);
Var Item : TListItem;
begin
Item := ListView1.Selected;
If Item = nil Then Exit;
ShowInstance(StrToInt(Item.Caption));
end;
procedure TForm1.Button4Click(Sender: TObject);
Var Item : TListItem;
begin
Item := ListView1.Selected;
If Item = nil Then Exit;
HideInstance(StrToInt(Item.Caption));
end;
procedure TForm1.Button1Click(Sender: TObject);
var hProcess : Integer;
Item : TListItem;
begin
Item := ListView1.Selected;
If Item = nil Then Exit;
hProcess := OpenProcess(PROCESS_TERMINATE, False, StrToInt(Item.SubItems[0]));
If TerminateProcess(hProcess, 0) Then
Begin
Item.Delete;
End;
end;
procedure TForm1.Button5Click(Sender: TObject);
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
Form1.ListView1.Selected.SubItems.Add(IntToStr(hWnd));
end;
begin
EnumThreadWindows(StrToInt(ListView1.Selected.Caption), @EnumWindProc, StrToInt(ListView1.Selected.Caption));
end;
end. |
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
WindowGevonden := false;
Sleep(400);
// while (NOT windowGevonden) do
//Begin
WindowGevonden := EnumThreadWindows(pInfo.dwThreadId,@EnumWindProc,0);
//Sleep(100);
// End;
[/quote]
Neerzet doet ie t wel.
Dus dat loopje gaat niet goed....
ps. let op het commentaar
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Forget your fears...
...and want to know more...
Als ik een app opstart die meer dan 400 ms nodig heeft, dan doet ie t niet dus...
Dat loopje heb ik dus wel nodig
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
EnumThreadWindows retourneert 0 als er een fout opgetreden is, en ongelijk aan 0 als het goed is gegaan (of er nou een window te enumeraten is of niet)Op vrijdag 10 mei 2002 02:23 schreef XLerator het volgende:
[..]
?? Wrom?
Dan doet ie t niet meer, dan hangt ie
maw, WindowGevonden wordt ook true als er helemaal geen window gevonden is
nee, je moet WindowGevonden op true zetten in je EnumWindProc!Op vrijdag 10 mei 2002 02:25 schreef Aetje het volgende:
[..]
Nee, want als je die wegdoet blijft ie in dat loopje hangeniteratief, dus in de loop een uitweg geven (door WindowGevonden op true te zetten)
EnumThreadWindows is een functie die een boolean waarde terug geeft. True als gelukt, False als gefaald. Je wil doorgaan tot ie gelukt is. Dan klopt het toch als je dit op deze manier doet? Je kent de return waarde toe aan een variabele
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Forget your fears...
...and want to know more...
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
| Function TForm1.StartFile(Str : String) : Boolean;
var PCharArr:PChar;
pInfo:Process_Information;
sInfo:StartupInfo;
ItemToAdd : TListItem;
Msg: TMsg;
lpExitCode : DWORD;
windowGevonden : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
if Form1.ListView1.Items[Form1.ListView1.Items.Count - 1] <> nil Then
Form1.ListView1.Items[Form1.ListView1.Items.Count - 1].SubItems.Add(IntToStr(hWnd));
WindowGevonden := True;
end;
begin
PCharArr := AllocMem(SizeOf(Char)*(Length(Str)+7));
try
FillChar (sInfo, SizeOf (sInfo), 0);
sInfo.cb := SizeOf (sInfo);
with sInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := startf_UseShowWindow;
wShowWindow := SW_HIDE;
end;
Result := CreateProcess(nil,StrPCopy(PCharArr,(Str)),nil,nil,FALSE,0,nil,nil,sInfo,pInfo);
finally
freemem(PCharArr);
end;
ItemToAdd := ListView1.Items.Add;
ItemToAdd.Caption := IntToStr(pInfo.dwThreadId);
ItemToAdd.SubItems.Add(IntToStr(pInfo.dwProcessId));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hThread));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hProcess));
WindowGevonden := False;
// Sleep(400);
while (Not WindowGevonden) do
Begin
EnumThreadWindows(pInfo.dwThreadId,@EnumWindProc,0);
Sleep(100);
End;
End; |
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Wel als ik er Sleep(400) voor zet
Ten misnte met notepad, omdat die wel binnen die tijd gestart is
Ten minste, dan hangt ie ook.
[edit]
Hij wordt wel uitgevoerd, WindowGevonden wordt in die proc wel op true gezet, maar die in dat loopje, de globale var zeg maar, blijft false.
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
.edit: oh, dan hangt ie ook... dat is wel wazig. In C heb je het keyword volatile, heb je dat in Delphi ook?
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
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
| Function TForm1.StartFile(Str : String) : Boolean;
var PCharArr:PChar;
pInfo:Process_Information;
sInfo:StartupInfo;
ItemToAdd : TListItem;
Msg: TMsg;
lpExitCode : DWORD;
WindowGevonden : Boolean;
function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
if Form1.ListView1.Items[Form1.ListView1.Items.Count - 1] <> nil Then
Form1.ListView1.Items[Form1.ListView1.Items.Count - 1].SubItems.Add(IntToStr(hWnd));
WindowGevonden := True;
end;
begin
blabla
WindowGevonden := False;
// Sleep(400);
while (Not WindowGevonden) do
Begin
EnumThreadWindows(pInfo.dwThreadId,@EnumWindProc,0);
Sleep(100);
End;
End; |
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Nee wat is dat dan?Op vrijdag 10 mei 2002 02:55 schreef .oisyn het volgende:
ja maar als het 400 ms duurt, dan moet je EnumWindProc dus in de 4e iteratie worden aangeroepen (aangezien dan 400 ms gewacht is), en dus moet ie uit dat loopje komen
.edit: oh, dan hangt ie ook... dat is wel wazig. In C heb je het keyword volatile, heb je dat in Delphi ook?
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
hoewel hij dat wel zou moeten doen, want er staat een functioncall in dat loopje, en na een functioncall kan alles veranderd zijn, dus dan kan ie dat ook niet optimalizeren
Zijn de 2 WindowGevonden's wel hetzelfde?
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Hoe kan ik dat, en de rest, controleren?Op vrijdag 10 mei 2002 03:00 schreef .oisyn het volgende:
Zijn de 2 WindowGevonden's wel hetzelfde?
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Door een @ ervoor te zetten?
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
ShowMessage(@WindowGevonden);
'Incompatible types 'string' and 'pointer'
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Maak die functie EnumWindProc eens globaal (dus niet genest in je TForm1.StartFile functie), evenals de WindowGevonden variabele
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Dus er is maar een windowgevonden.
Ook dat 400ms wachten, dat ie bij de 4e iteratie naar buiten springt... Nee dus. Dit stuk code zegt:
1
2
3
4
| ZOLANG Niet (WindowGevonden) DOE Wacht 400 ms WindowGevonden wordt EnumThreadWindows... Eind ZOLANG |
WindowGevonden is ergens boven de iteratie gedefineerd.
Zet eens een watch op de WindowGevonden. En kijk of ie eindeloos in het loopje blijft. Kijk ook of EnumThreadWindows uberhaupt iets teruggeeft...
Forget your fears...
...and want to know more...
Testing
Dan is Handle 0, maar hangt niet meer
Testing #2
Met die watch erop, zegt ie als ik in de WinThreadProc ben, 'inaccessable value'
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Forget your fears...
...and want to know more...
ik weet hoe het in Delphi werkt, althans, ik heb ooit in pascal geprogrammeerd (alle syntax is me alleen niet echt bijgebleven)Op vrijdag 10 mei 2002 03:07 schreef Aetje het volgende:
Dit is niet hoe Delphi werkt. Die WindowGevonden is een lokale variabele van de functie/procedure waarin ie wordt opgeroepen. Dus NIET een lokale variabele van de iteratie. Dat mag nl in delphi niet (alle variabelen moeten expliciet met type gedefineerd worden, dmv het keyword var.
ik bedoelde ook niet lokaal als in het loopje, maar lokaal van de functie. Een geneste functie in Delphi kan toch ook gewoon bij de lokale vars van z'n parent? Maar er is echter een probleem: als ie bij de vars van z'n parent moet kunnen, mag die functie dus ook alleen maar aangeroepen worden vanuit z'n parent, en niet in een andere functie, omdat dan de stack niet meer klopt, en kan hij dus ook niet meer bij de vars van z'n parent. Daarom wordt ook de verkeerde WindowGevonden var gezet (dwz, hij schrijft naar een compleet verkeerd geheugenadres)
ik ga nu
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
mom. code komt eraan
Tnx allebij he!!!! TOPPIE!!!!
Fantastische hulp ( en dat om middennacht
Maar wat .oisyn zij, dat was het. Functie globaal maken
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
| Function EnumWindProc(hWnd: HWND;lParam: LPARAM): BOOL; stdcall;
begin
if Form1.ListView1.Items[Form1.ListView1.Items.Count - 1] <> nil Then
Form1.ListView1.Items[Form1.ListView1.Items.Count - 1].SubItems.Add(IntToStr(hWnd));
WindowGevonden := True;
end;
Function TForm1.StartFile(Str : String) : Boolean;
var PCharArr:PChar;
pInfo:Process_Information;
sInfo:StartupInfo;
ItemToAdd : TListItem;
Msg: TMsg;
lpExitCode : DWORD;
begin
PCharArr := AllocMem(SizeOf(Char)*(Length(Str)+7));
try
FillChar (sInfo, SizeOf (sInfo), 0);
sInfo.cb := SizeOf (sInfo);
with sInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := startf_UseShowWindow;
wShowWindow := SW_HIDE;
end;
Result := CreateProcess(nil,StrPCopy(PCharArr,(Str)),nil,nil,FALSE,0,nil,nil,sInfo,pInfo);
finally
freemem(PCharArr);
end;
ItemToAdd := ListView1.Items.Add;
ItemToAdd.Caption := IntToStr(pInfo.dwThreadId);
ItemToAdd.SubItems.Add(IntToStr(pInfo.dwProcessId));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hThread));
ItemToAdd.SubItems.Add(IntToStr(pInfo.hProcess));
WindowGevonden := False;
while (Not WindowGevonden) do
Begin
EnumThreadWindows(pInfo.dwThreadId,@EnumWindProc,0);
Sleep(100);
End;
End; |
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
[edit]
Laat dus maar
En het is na 3en
Forget your fears...
...and want to know more...
Als ik nu 'c:\program files\internet explorer\iexplore.exe' gebruik, dan is het venster na een SW_HIDE, en dan SW_SHOW, niet goed.
Een gek wit vlakje linksboven waarmee je nix kan
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
uit de MSDN:
SW_SHOW - Activates the window and displays it in its current size and position.
SW_SHOWNORMAL - Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
maar is het niet gewoon beter als je m start met SW_MINIMIZED ipv SW_HIDE?
.edit: sorry, verkeerde functie
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Maar als ik dat ook ff probeer, dan is ie nogsteeds niet goed als ik `m daarna met ShowWindow op SW_SHOW* zet
[edit]
Hmm, als ik eerst SHOW doe, en dan met een knop op SHOWMINIMIZED, dan komt er een ander scherm, die wordt minimized. En als je dan SHOWNORMAL doet, wordt dát venster dat gekke vierkantje, en met de echte IE window gebeurd nix.
Dus das een andere ID
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
Kun je text gooien in dat gekke witte vierkantje?Op vrijdag 10 mei 2002 16:38 schreef XLerator het volgende:
Ten eerste is het niet de bedoeling dat ie SW_SHOWMINIMIZED is.
Maar als ik dat ook ff probeer, dan is ie nogsteeds niet goed als ik `m daarna met ShowWindow op SW_SHOW* zet
[edit]
Hmm, als ik eerst SHOW doe, en dan met een knop op SHOWMINIMIZED, dan komt er een ander scherm, die wordt minimized. En als je dan SHOWNORMAL doet, wordt dát venster dat gekke vierkantje, en met de echte IE window gebeurd nix.
Dus das een andere ID
* Aetje heeft een vermoeden dat een memoveldje van dat notepadje geen baasje meer heeft...
Forget your fears...
...and want to know more...
Notepad werkt vlekkeloos, net als vele anderen.
IExplore is de eerste nu die het niet doen
If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router
