Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetWindowThreadProcessId

Status
Not open for further replies.

benmillus

Programmer
Jun 17, 2003
18
US
Not getting output for the 'Process ID'.

Here is my code:

Const PROCESS_SET_QUOTA = 256;
Const TRIM_TO_ZERO = 4294967295; # 0xFFFFFFFF or (-1 as a signed long)
Public hWnd, processID, threadID, hProcess, hCurProcess
Declare DllFunc "long GetCurrentProcess() kernel32" _GetCurrentProcess
Declare DllFunc "short SetProcessWorkingSetSize(long, long, long) kernel32" _SetProcessWorkingSetSize
Declare DllFunc "long GetWindowThreadProcessId(long, short) user32" _GetWindowThreadProcessId
Declare DllFunc "long GetWindowProcessId(long) user32" _GetWindowProcessId
Declare DllFunc "long OpenProcess(long, short, long) kernel32" _OpenProcess
Declare DllFunc "short CloseHandle(long) kernel32" _CloseHandle
Function Main
hWnd = ActiveWindow()
MsgBox("hWnd",hWnd)

threadID = _GetWindowThreadProcessId( hWnd, processID)
MsgBox("threadID",threadID)
MsgBox("processID",processID)

hProcess = _OpenProcess(PROCESS_SET_QUOTA, TRUE, processID)
MsgBox("hProcess",hProcess)

_SetProcessWorkingSetSize(hProcess, TRIM_TO_ZERO, TRIM_TO_ZERO)
_CloseHandle(hProcess)

hCurProcess = _GetCurrentProcess(); Free extra CRV memory
MsgBox("hCrvProcess",hCurProcess)

_SetProcessWorkingSetSize(hCurProcess, TRIM_TO_ZERO, TRIM_TO_ZERO);
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top