aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder4/UninstCust/CoolTools.cpp
blob: 451aa358331491c8d60e7c49c81df1c774946981 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//---------------------------------------------------------------------------
#include <vcl.h>
#include <dos.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//
//   If your DLL exports any functions that pass String objects (or structs/
//   classes containing nested Strings) as parameter or function results,
//   you will need to add the library MEMMGR.LIB to both the DLL project and
//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
//   if any other projects which use the DLL will be perfomring new or delete
//   operations on any non-TObject-derived classes which are exported from the
//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
//   EXE's to use the BORLNDMM.DLL as their memory manager.  In these cases,
//   the file BORLNDMM.DLL should be deployed along with your DLL.
//
//   To avoid using BORLNDMM.DLL, pass string information using "char *" or
//   ShortString parameters.
//
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
USERES("CoolTools.res");
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
	return 1;
}
//---------------------------------------------------------------------------
extern "C" {

DWORD APIENTRY __export launchAndWait(LPCSTR cmdLine, LPCSTR workDir) {
	STARTUPINFO StartupInfo;
	PROCESS_INFORMATION ProcessInformation;
	DWORD ExitCode = -1;

	GetStartupInfo(&StartupInfo);
	if (CreateProcess(NULL, (char *)cmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, workDir, &StartupInfo, &ProcessInformation)) {
		do {
			_sleep(1);
			GetExitCodeProcess(ProcessInformation.hProcess, &ExitCode);
		} while (ExitCode == STILL_ACTIVE);
	}
	else {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
		MessageBox(NULL, (const char *)lpMsgBuf, "Error", MB_OK|MB_ICONINFORMATION);
		LocalFree(lpMsgBuf);
	}
	return ExitCode;
}

}