-3

How can I convert the below program to 64 bit?

Declare Function OpenProcess Lib "kernel32" _
  (ByVal dwDesiredAccess As Long, _
    ByVal bInheritHandle As Long, _
     ByVal dwProcessId As Long) As Long

Declare Function GetExitCodeProcess Lib "kernel32" _
  (ByVal L_Prozess As Long, _
    l_Ende As Long) As Long

Declare Sub Sleep Lib "Kernel32.dll" _
  (ByVal SleepTime As Long)
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Welcome Sudhanshu! Please take some time to read the introduction to Stack Overflow and earn your first badge. We're a little bit different from other sites. Here's how... https://stackoverflow.com/tour – user10186832 May 30 '23 at 10:06
  • What problems are you specifically having? – halfer Jun 03 '23 at 10:44

1 Answers1

4

My advice was always to use the excellent free tool "Windows API Viewer" that was hosted on Ron de Bruins web page, however, the link is currently pointing to a 404, don't know why. You can still find it using the way back machine. Note that there are some AV scanners that don't like the tool and mark it as potentially harmful, however from all I know this is a false alert - I have been using that tool for a long time and never had issues.

The output of that tool gave me the following declarations. Note that they are not tested (except for Sleep)

#If VBA7 Then
    Declare PtrSafe Function OpenProcess Lib "kernel32" Alias "OpenProcess" _
                            (ByVal dwDesiredAccess As Long, _
                             ByVal bInheritHandle As Long, _
                             ByVal dwProcessId As Long) As LongPtr
    Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" Alias "GetExitCodeProcess" _
                            (ByVal hProcess As LongPtr, _
                             lpExitCode As Long) As Long
    Declare PtrSafe Sub Sleep Lib "kernel32" Alias "Sleep" _
                            (ByVal dwMilliseconds As Long)
#Else
    ' (This is your code)
    Declare Function OpenProcess Lib "kernel32" _
                            (ByVal dwDesiredAccess As Long, _
                             ByVal bInheritHandle As Long, _
                             ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
                            (ByVal L_Prozess As Long, _
                             l_Ende As Long) As Long
Declare Sub Sleep Lib "Kernel32.dll" _
                            (ByVal SleepTime As Long)
#End If
FunThomas
  • 23,043
  • 3
  • 18
  • 34
  • 1
    `Note that they are not tested` - the `#If Win64` [should be](https://stackoverflow.com/a/56940710/11683) `#If VBA7`, otherwise this is correct. – GSerg May 30 '23 at 09:41
  • @GSerg: You are right - I always confuse the meaning of those. I will correct my answer. – FunThomas May 30 '23 at 10:16