Link to home
Start Free TrialLog in
Avatar of shragi
shragiFlag for India

asked on

exitprocess using kernel32

In my program I used to use the below function

Call ExitProcess(retVal)

here retval is long and I declared exitprocess as below

Private Declare Sub ExitProcess Lib "KERNEL32" _
  (ByVal uExitCode As Long)



but now i want to return string, i made the same call
Call ExitProcess(retVal)

but my decalration is different
Private Declare Sub ExitProcess Lib "KERNEL32" (ByVal uExitCode As String)

is this correct ? can i use it in this way...because i heard we can just have uExitCOde as Long.
Avatar of vinodpaka
vinodpaka
Flag of India image

Hi shragi,
Input parameter can be long or string,since you need to return a string you can keep like this.

Private Declare Sub ExitProcess Lib "KERNEL32" _
  (ByVal uExitCode As Long)
-
-
string x=uExitCode.tostring()
end sub
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shragi

ASKER

Private Declare Sub ExitProcess Lib "KERNEL32" (ByVal uExitCode As String)


is this possible or not...


can the API take string if not is there any other options i have
No...it takes an Integer:

    Private Declare Sub ExitProcess Lib "KERNEL32" (ByVal uExitCode As Integer)

*Not necessary though as I pointed out previously.

What are you trying to do?...
I think @kaufmed gave you the correct answer already.  Operating system exit codes are inherently numeric by nature, for now (No, you won't be able to return a string).  You can try writing the string to the standard out before exit, and any monitoring processes might be able to catch/parse that.  But for now you are limited to using Integer or Long.  That is not to say that you couldn't have a specific meaning reserved for each numeric value.  Typically, processes return 0(zero) when successful, and !0 (not zero) otherwise.