Jump to content

TerminateProcess()


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...