Sign in to follow this  
Followers 0
slightly_abnormal

TerminateProcess()

9 posts in this topic

#1 ·  Posted (edited)

I was messing with DLLcalls.. okay heres one.. (note: my conversion to autoit is not the best :D)

I assume i need handle rather then process name.. but dont know how to get it../ i know this is already built into autoit i just wanna try this with a real dllcall..

$Process = 'notepad.exe'
$ExitC = DllCall('kernel32.dll','None','GetExitCodeProcess','hwnd',$Process,'ptr',0)
DllCall('kernel32.dll','None','TerminateProcess','hwnd',$Process,'int',$ExitC)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

just glancing through...

quick question:

If the function's return type is 'None', how can it return the variable $ExitC?

#)

edit: Spelling

Edited by nfwu

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well.. heres at msdn it said void i assume it means none, or would that be ptr ?? at answeres.com it says long .. :D

$Process = 'notepad.exe'
$ExitC = DllCall('kernel32.dll','Long','GetExitCodeProcess','hwnd',$Process,'ptr',0)
DllCall('kernel32.dll','ptr','TerminateProcess','hwnd',$Process,'int',$ExitC)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What? ProcessClose() does exactly what you are doing. What is the point of a second link?

BOOL TerminateProcess(
  HANDLE hProcess, // handle to the process
  UINT uExitCode   // exit code for the process
);

becomes

int TerminateProcess(
  void *hProcess,
  unsigned int uExitCode
);

and

BOOL GetExitCodeProcess(
  HANDLE hProcess,   // handle to the process
  LPDWORD lpExitCode   // termination status
);

becomes

int GetExitCodeProcess(
  void *hProcess,
  unsigned long *lpExitCode
);

HANDLE is not HWND. HANDLE = void* and HWND = HWND__*.

Edited by Icekirby1

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

[edit]

$Process = 'notepad.exe'
$Proc =  DllCall('kernel32.dll','Long','GetCurrentProcess','str',$Process)
$ExitC = DllCall('kernel32.dll','Long','GetExitCodeProcess','hwnd',$Proc,'ptr',0)
DllCall('kernel32.dll','ptr','TerminateProcess','hwnd',$Process,'int',$ExitC)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

Return type = "int", not "long".

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

okay heres another try .. why isn't there any processgethandle, processgetsate funcs btw?? do i need handle?

[edit] btw in the helpfile Int and long both say a 32 bit integer for whatever reason.. o.o

opt('wintitlematchmode',2)
$Winhandle = WinGetHandle('Untitled - Notepad')
$ProcH =  DllCall('kernel32.dll','int','GetCurrentProcess','hwnd',$Winhandle)
$ExitC = DllCall('kernel32.dll','int','GetExitCodeProcess','hwnd',$ProcH,'ptr',0)
DllCall('kernel32.dll','ptr','TerminateProcess','hwnd',$Winhandle,'int',$ExitC)
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

so i take it no one knows? :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0