ntdll/tests: Fix a couple of test failures on older Windows versions.
[wine.git] / programs / winoldap.mod16 / winoldap.c
blobc6342d0d90f71e43e792c9dea141ef4ea17fc020
1 /*
2 * WINOLDAP implementation
4 * Copyright 2000 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wownt32.h"
27 #include "wine/winbase16.h"
28 #include "wine/server.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(module);
34 /***********************************************************************
35 * wait_input_idle
37 * user32.WaitForInputIdle releases the win16 lock, so here is a replacement.
39 static DWORD wait_input_idle( HANDLE process, DWORD timeout )
41 DWORD ret;
42 HANDLE handles[2];
44 handles[0] = process;
45 SERVER_START_REQ( get_process_idle_event )
47 req->handle = wine_server_obj_handle(process);
48 if (!(ret = wine_server_call_err( req ))) handles[1] = wine_server_ptr_handle( reply->event );
50 SERVER_END_REQ;
51 if (ret) return WAIT_FAILED; /* error */
52 if (!handles[1]) return 0; /* no event to wait on */
54 return WaitForMultipleObjects( 2, handles, FALSE, timeout );
58 /**************************************************************************
59 * WINOLDAP entry point
61 WORD WINAPI WinMain16( HINSTANCE16 inst, HINSTANCE16 prev, LPSTR cmdline, WORD show )
63 PROCESS_INFORMATION info;
64 STARTUPINFOA startup;
65 DWORD count, exit_code = 1;
67 WINE_TRACE( "%x %x %s %u\n", inst, prev, wine_dbgstr_a(cmdline), show );
69 memset( &startup, 0, sizeof(startup) );
70 startup.cb = sizeof(startup);
72 if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
73 0, NULL, NULL, &startup, &info ))
75 /* Give 10 seconds to the app to come up */
76 if (wait_input_idle( info.hProcess, 10000 ) == WAIT_FAILED)
77 WINE_WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
78 ReleaseThunkLock( &count );
79 WaitForSingleObject( info.hProcess, INFINITE );
80 RestoreThunkLock( count );
82 GetExitCodeProcess( info.hProcess, &exit_code );
83 CloseHandle( info.hThread );
84 CloseHandle( info.hProcess );
87 HeapFree( GetProcessHeap(), 0, cmdline );
88 ExitThread( exit_code );