nrk (owner)

Revisions

gist: 136104 Download_button fork
public
Public Clone URL: git://gist.github.com/136104.git
Embed All Files: show embed
win32-process.rb #
1
2
3
4
5
6
7
require 'win32/process'
 
process_info = Process.create(
    :app_name => "notepad.exe",
    :creation_flags => Process::DETACHED_PROCESS,
    :process_inherit => false
)
win32api.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
close_handle = Win32API.new('kernel32', 'CloseHandle', 'L', 'L')
create_process = Win32API.new('kernel32', 'CreateProcess', 'PPPPLLLPPP', 'L')
startup_info = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].pack('LLLLLLLLLLLLSSLLLL')
process_info = [0,0,0,0].pack('LLLL')
 
created = create_process.call(
    0, # lpApplicationName
    "notepad.exe", # lpCommandLine
    0, # lpProcessAttributes
    0, # lpThreadAttributes
    0, # bInheritHandles
    0x08, # dwCreationFlags
    0, # lpEnvironment
    "C:/Temp/", # lpCurrentDirectory
    startup_info, # lpStartupInfo
    process_info # lpProcessInformation
)
 
close_handle.call(process_info[0,4].unpack('L').first)
close_handle.call(process_info[4,4].unpack('L').first)