37 "Create a new process running in a separate address space. n.b., we use CreateProcessA |
37 "Create a new process running in a separate address space. n.b., we use CreateProcessA |
38 (the ANSI version) rather than CreateProcessW (the UNICODE/wide version) as we want the |
38 (the ANSI version) rather than CreateProcessW (the UNICODE/wide version) as we want the |
39 daemon, vworad, to receive its command line arguments as ANSI strings not wide strings." |
39 daemon, vworad, to receive its command line arguments as ANSI strings not wide strings." |
40 |
40 |
41 <C: BOOL CreateProcessA( |
41 <C: BOOL CreateProcessA( |
42 LPCTSR imageName, |
42 LPCTSR imageName, |
43 LPCTSTR commandLine, |
43 LPCTSTR commandLine, |
44 struct SECURITY_ATTRIBUTES *pSecurity, |
44 struct SECURITY_ATTRIBUTES *pSecurity, |
45 struct SECURITY_ATTRIBUTES *tSecurity, |
45 struct SECURITY_ATTRIBUTES *tSecurity, |
46 BOOL inheritHandles, |
46 BOOL inheritHandles, |
47 DWORD creationFlags, |
47 DWORD creationFlags, |
48 LPVOID environment, |
48 LPVOID environment, |
49 LPTSTR currentDirectoryName, |
49 LPTSTR currentDirectoryName, |
50 struct STARTUPINFO *startupInfo, |
50 struct STARTUPINFO *startupInfo, |
51 struct PROCESS_INFORMATION *processInfo)> |
51 struct PROCESS_INFORMATION *processInfo)> |
52 |
52 |
53 " |
53 " |
54 self new |
54 self new |
55 CreateProcess: 'foo' commandLine: 'foo bla' pSecurity: nil tSecurity: nil inheritHandles: false |
55 CreateProcess: 'foo' commandLine: 'foo bla' pSecurity: nil tSecurity: nil inheritHandles: false |
56 creationFlags: 0 environment: nil currentDirectoryName: 'baz' startupInfo: nil processInfo: nil |
56 creationFlags: 0 environment: nil currentDirectoryName: 'baz' startupInfo: nil processInfo: nil |
57 " |
57 " |
58 ! |
58 ! |
59 |
59 |
60 TerminateProcess: hProcess exitCode: dwExitCode |
60 TerminateProcess: hProcess exitCode: dwExitCode |
61 "Kill the specified process." |
61 "Kill the specified process." |
62 |
62 |
63 self primTerminateProcess: hProcess exitCode: 1234 |
63 self primTerminateProcess: hProcess exitCode: 1234 |
64 ! |
64 ! |
65 |
65 |
66 closeHandle: aHandle |
66 closeHandle: aHandle |
67 "Close an OS Handle decrementing it's use count." |
67 "Close an OS Handle decrementing it's use count." |
68 |
68 |
69 <C: int CloseHandle(HANDLE aHandle)> |
69 <C: int CloseHandle(HANDLE aHandle)> |
70 ! |
70 ! |
71 |
71 |
72 primTerminateProcess: hProcess exitCode: dwExitCode |
72 primTerminateProcess: hProcess exitCode: dwExitCode |
73 "Kill the specified process." |
73 "Kill the specified process." |
74 |
74 |
75 <C: BOOL TerminateProcess(HANDLE hProcess, DWORD dwExitCode)> |
75 <C: BOOL TerminateProcess(HANDLE hProcess, DWORD dwExitCode)> |
76 ! |
76 ! |
77 |
77 |
78 setCurrentDirectory: pathName |
78 setCurrentDirectory: pathName |
79 "Set the current working directory." |
79 "Set the current working directory." |
80 |
80 |
81 <C: BOOL _wincall SetCurrentDirectoryA(LPCTSTR pathName)> |
81 <C: BOOL _wincall SetCurrentDirectoryA(LPCTSTR pathName)> |
82 ^self externalAccessFailedWith: _errorCode |
82 ^self externalAccessFailedWith: _errorCode |
83 ! ! |
83 ! ! |
84 |
84 |
85 !ExternalInterfaceTests methodsFor:'structs'! |
85 !ExternalInterfaceTests methodsFor:'structs'! |
86 |
86 |
87 PROCESS_INFORMATION |
87 PROCESS_INFORMATION |
88 "Describes a created process and its main thread." |
88 "Describes a created process and its main thread." |
89 |
89 |
90 <C: struct PROCESS_INFORMATION { |
90 <C: struct PROCESS_INFORMATION { |
91 HANDLE hProcess; |
91 HANDLE hProcess; |
92 HANDLE hThread; |
92 HANDLE hThread; |
93 DWORD dwProcessId; |
93 DWORD dwProcessId; |
94 DWORD dwThreadId; |
94 DWORD dwThreadId; |
95 }> |
95 }> |
96 ! |
96 ! |
97 |
97 |
98 SECURITY_ATTRIBUTES |
98 SECURITY_ATTRIBUTES |
99 "Describes security of associated process." |
99 "Describes security of associated process." |
100 |
100 |
101 <C: struct SECURITY_ATTRIBUTES { |
101 <C: struct SECURITY_ATTRIBUTES { |
102 DWORD nLength; |
102 DWORD nLength; |
103 LPVOID lpSecurityDescriptor; |
103 LPVOID lpSecurityDescriptor; |
104 BOOL bInheritHandle; |
104 BOOL bInheritHandle; |
105 }> |
105 }> |
106 ! |
106 ! |
107 |
107 |
108 STARTUPINFO |
108 STARTUPINFO |
109 "Describes how we want the process to be started." |
109 "Describes how we want the process to be started." |
110 |
110 |
111 <C: struct STARTUPINFO { |
111 <C: struct STARTUPINFO { |
112 DWORD cb; |
112 DWORD cb; |
113 LPSTR lpReserved; |
113 LPSTR lpReserved; |
114 LPSTR lpDesktop; |
114 LPSTR lpDesktop; |
115 LPSTR lpTitle; |
115 LPSTR lpTitle; |
116 DWORD dwX; |
116 DWORD dwX; |
117 DWORD dwY; |
117 DWORD dwY; |
118 DWORD dwXSize; |
118 DWORD dwXSize; |
119 DWORD dwYSize; |
119 DWORD dwYSize; |
120 DWORD dwXCountChars; |
120 DWORD dwXCountChars; |
121 DWORD dwYCountChars; |
121 DWORD dwYCountChars; |
122 DWORD dwFillAttribute; |
122 DWORD dwFillAttribute; |
123 DWORD dwFlags; |
123 DWORD dwFlags; |
124 WORD wShowWindow; |
124 WORD wShowWindow; |
125 WORD cbReserved2; |
125 WORD cbReserved2; |
126 LPBYTE lpReserved2; |
126 LPBYTE lpReserved2; |
127 HANDLE hStdInput; |
127 HANDLE hStdInput; |
128 HANDLE hStdOutput; |
128 HANDLE hStdOutput; |
129 HANDLE hStdError; |
129 HANDLE hStdError; |
130 }> |
130 }> |
131 ! ! |
131 ! ! |
132 |
132 |
133 !ExternalInterfaceTests methodsFor:'tests'! |
133 !ExternalInterfaceTests methodsFor:'tests'! |
134 |
134 |
135 test_call_01 |
135 test_call_01 |
136 |fn| |
136 |fn| |
137 |
137 |
138 OperatingSystem isMSWINDOWSlike ifFalse:[ |
138 OperatingSystem isMSWINDOWSlike ifFalse:[ |
139 "This test makes sense only on windows" |
139 "This test makes sense only on windows" |
140 ^ self. |
140 ^ self. |
141 ]. |
141 ]. |
142 |
142 |
143 fn := ExternalLibraryFunction |
143 fn := ExternalLibraryFunction |
144 name:'Beep' |
144 name:'Beep' |
145 module:'kernel32.dll' |
145 module:'kernel32.dll' |
146 returnType:(CType bool) |
146 returnType:(CType bool) |
147 argumentTypes:(Array with:(CType unsignedLong) with:(CType unsignedLong)). |
147 argumentTypes:(Array with:(CType unsignedLong) with:(CType unsignedLong)). |
148 |
148 |
149 fn beCallTypeAPI. |
149 fn beCallTypeAPI. |
150 fn invokeWith:440 with:1. |
150 fn invokeWith:440 with:1. |
151 |
151 |
152 " |
152 " |