本文整理汇总了C++中ExitProcess函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitProcess函数的具体用法?C++ ExitProcess怎么用?C++ ExitProcess使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExitProcess函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateThread
void MergeHashManager::execute()
{
{
uint32 file_size = ((uint32)std::ceil(((float)this->merge_files.size()) / ((float)MAX_MERGE_THREADS)));
uint32 offset = (this->end - this->start) / MAX_MERGE_THREADS;
MergeHash merge[MAX_MERGE_THREADS];
int prev_size = 0;
for (int i = 0; i < MAX_MERGE_THREADS; ++i) {
std::deque<std::string>tmp_files;
for (int j = 0; j < file_size && this->merge_files.size() > 0; ++j) {
tmp_files.emplace_back(this->merge_files.front());
this->merge_files.pop_front();
}
(merge + i)->init(this->start + i*offset, this->start + (i + 1)*offset, tmp_files);
(merge + i)->file_count = i * (prev_size);
prev_size = tmp_files.size();
}
DWORD dwThreadIdArray[MAX_MERGE_THREADS];
HANDLE hThreadArray[MAX_MERGE_THREADS];
for (int i = 0; i < MAX_MERGE_THREADS; ++i) {
hThreadArray[i] = CreateThread(
NULL, // default security attributes
0, // use default stack size
mergeExecute, // thread function name
(merge + i), // argument to thread function
0, // use default creation flags
&dwThreadIdArray[i]); // returns the thread identifier
if (DEBUG && hThreadArray[i] == NULL)
{
//ErrorHandler(TEXT("CreateThread"));
ExitProcess(3);
}
}
WaitForMultipleObjects(MAX_MERGE_THREADS, hThreadArray, TRUE, INFINITE);
// Close all thread handles.
for (int i = 0; i < MAX_MERGE_THREADS; ++i)
{
CloseHandle(hThreadArray[i]);
}
//At this stage we have just 4 files to merge.
//Lets give two to each thread.
//Lets construct two new mergeHash objects to take care of them
for (int i = 0; i < MAX_MERGE_THREADS; ++i) {
this->total_read += (merge + i)->total_read;
this->total_write += (merge + i)->total_write;
this->merge_files.push_back((merge + i)->merge_files[0]);
}
}
MergeHash merge = MergeHash(this->start, this->end, this->merge_files);
merge.file_count = 100;
merge.execute();
this->merge_files.clear();
this->merge_files.push_back(merge.merge_files[0]);
this->total_read += merge.total_read;
this->total_write += merge.total_write;
}
示例2: Main
EXTERN_C int WINAPI Main()
{
int result = wWinMain(nullptr, nullptr, nullptr, 0);
ExitProcess(result);
return 0; // Never reached.
}
示例3: WINECON_Fatal
void WINECON_Fatal(const char* msg)
{
WINE_ERR("%s\n", msg);
ExitProcess(0);
}
示例4: GL_Init
bool GL_Init(HWND window, std::string *error_message) {
*error_message = "ok";
hWnd = window;
GLuint PixelFormat;
// TODO: Change to use WGL_ARB_pixel_format instead
static const PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
24, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
8, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // At least a 16Bit Z-Buffer (Depth Buffer)
8, // 8-bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
hDC = GetDC(hWnd);
if (!hDC) {
*error_message = "Failed to get a device context.";
return false; // Return FALSE
}
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) {
*error_message = "Can't find a suitable PixelFormat.";
return false;
}
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {
*error_message = "Can't set the PixelFormat.";
return false;
}
if (!(hRC = wglCreateContext(hDC))) {
*error_message = "Can't create a GL rendering context.";
return false;
}
if (!wglMakeCurrent(hDC, hRC)) {
*error_message = "Can't activate the GL rendering context.";
return false;
}
// Check for really old OpenGL drivers and refuse to run really early in some cases.
// TODO: Also either tell the user to give up or point the user to the right websites. Here's some collected
// information about a system that will not work:
// GL_VERSION GL_VENDOR GL_RENDERER
// "1.4.0 - Build 8.14.10.2364" "intel" intel Pineview Platform
I18NCategory *err = GetI18NCategory("Error");
std::string glVersion = (const char *)glGetString(GL_VERSION);
std::string glRenderer = (const char *)glGetString(GL_RENDERER);
const std::string openGL_1 = "1.";
if (glRenderer == "GDI Generic" || glVersion.substr(0, openGL_1.size()) == openGL_1) {
//The error may come from 16-bit colour mode
//Check Colour depth
HDC dc = GetDC(NULL);
u32 colour_depth = GetDeviceCaps(dc, BITSPIXEL);
ReleaseDC(NULL, dc);
if (colour_depth != 32) {
MessageBox(0, L"Please switch your display to 32-bit colour mode", L"OpenGL Error", MB_OK);
ExitProcess(1);
}
const char *defaultError = "Insufficient OpenGL driver support detected!\n\n"
"Your GPU reports that it does not support OpenGL 2.0. Would you like to try using DirectX 9 instead?\n\n"
"DirectX is currently compatible with less games, but on your GPU it may be the only choice.\n\n"
"Visit the forums at http://forums.ppsspp.org for more information.\n\n";
std::wstring versionDetected = ConvertUTF8ToWString(glVersion + "\n\n");
std::wstring error = ConvertUTF8ToWString(err->T("InsufficientOpenGLDriver", defaultError));
std::wstring title = ConvertUTF8ToWString(err->T("OpenGLDriverError", "OpenGL driver error"));
std::wstring combined = versionDetected + error;
bool yes = IDYES == MessageBox(hWnd, combined.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO);
if (yes) {
// Change the config to D3D and restart.
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
g_Config.Save();
W32Util::ExitAndRestart();
}
// Avoid further error messages. Let's just bail, it's safe, and we can't continue.
ExitProcess(1);
}
//.........这里部分代码省略.........
示例5: printf
/*-----------------------------------------------------------------------------
-- FUNCTION: receiveStream
--
-- DATE: 2009-04-06
--
-- REVISIONS: 2009-04-06 - Jaymz, Took out the TCP connection stuff since
-- we already have that at this point. Also added
-- a parameter WPARAM sd, which is the socket
-- from which we are receiving the data.
-- - Jaymz, Miscellaneous code touch-ups (mainly
-- formatting and removing of test printf()'s)
--
-- DESIGNER(S): David Overton
-- PROGRAMMER(S): David Overton, Jaymz Boilard, Steffen L. Norgren
--
-- INTERFACE: receiveStream(LPVOID iValue)
--
-- RETURNS: void
--
-- NOTES: The main function to receive a UDP stream of data and process
-- that information.
-----------------------------------------------------------------------------*/
DWORD WINAPI receiveStream(LPVOID iValue)
{
WAVEFORMATEX wfx;
char buffer[BLOCK_SIZE]; /* intermediate buffer for reading */
int i, n, remote_len;
DWORD outBytes = 0;
char * play_byte = "1";
BOOL firstRun = TRUE;
remote_len = sizeof(udp_remote);
/* initialise the module variables */
waveBlocks = allocateBlocks(BLOCK_SIZE, BLOCK_COUNT);
waveFreeBlockCount = BLOCK_COUNT;
waveCurrentBlock = 0;
InitializeCriticalSection(&waveCriticalSection);
/* playback loop - read from socket */
while (TRUE)
{
if (ci.request != MULTI_STREAM) {
/* send play signal */
sendto(ci.udpSocket, play_byte, sizeof(play_byte), 0, (struct sockaddr *)&udp_remote, remote_len);
}
if ((n = recvfrom(ci.udpSocket, buffer, sizeof(buffer), 0, (struct sockaddr *)&udp_remote, &remote_len)) <= 0)
{
waveOutClose(hWaveOut);
ExitThread(0);
}
/* first 4 bytes in a file, so set the header information */
if(strncmp(buffer, "RIFF", 4) == 0)
{
memcpy(&wfx, buffer+20, sizeof(wfx));
if (ci.request != MULTI_STREAM || firstRun == TRUE) {
waveOutClose(hWaveOut);
if(waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, (DWORD_PTR)waveOutProc,
(DWORD_PTR)&waveFreeBlockCount, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
{
MessageBox(NULL, "Unable to open mapper device.", "Error", MB_OK);
ExitProcess(1);
}
firstRun = FALSE;
}
}
if(n == 0)
break;
else if(n < sizeof(buffer) && n != WAVE_HEAD_SIZE)
{
memset(buffer + n, 0, sizeof(buffer) - n);
writeAudio(buffer, n);
break;
}
writeAudio(buffer, n);
}
/* wait for all blocks to complete */
while(waveFreeBlockCount < BLOCK_COUNT)
Sleep(10);
/* unprepare any blocks that are still prepared */
for(i = 0; i < waveFreeBlockCount; i++)
{
if(waveBlocks[i].dwFlags & WHDR_PREPARED)
waveOutUnprepareHeader(hWaveOut, &waveBlocks[i], sizeof(WAVEHDR));
}
DeleteCriticalSection(&waveCriticalSection);
freeBlocks(waveBlocks);
waveOutClose(hWaveOut);
streamInProgress = FALSE;
ExitThread(0);
}
示例6: WinMain
BOOL APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
PCHAR pszDllPath = "Accelerator.dll";
CHAR szDllPath[1024];
PCHAR pszFilePart = NULL;
if (!GetFullPathName(pszDllPath, ARRAYSIZE(szDllPath), szDllPath, &pszFilePart))
{
MessageBoxA(NULL, "GetFullPathName Failed\n", "Error", MB_OK);
return false;
}
HMODULE hDll = LoadLibraryEx(pszDllPath, NULL, DONT_RESOLVE_DLL_REFERENCES);
if (hDll == NULL)
{
MessageBoxA(NULL, "Failed to load dll\n", "Error", MB_OK);
return false;
}
ExportContext ec;
ec.fHasOrdinal1 = FALSE;
ec.nExports = 0;
DetourEnumerateExports(hDll, &ec, ExportCallback);
FreeLibrary(hDll);
if (!ec.fHasOrdinal1)
{
MessageBoxA(NULL, "This dll does not export ordinal #1.\n", "Error", MB_OK);
return false;
}
//////////////////////////////////////////////////////////////////////////////////
STARTUPINFO si;
PROCESS_INFORMATION pi;
CHAR szCommand[2048];
CHAR szExe[1024];
CHAR szFullExe[1024] = "\0";
PCHAR pszFileExe = NULL;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
szCommand[0] = L'\0';
strcpy(szExe, "LOVESICK_PUPPIES.exe");
strcpy(szCommand, "LOVESICK_PUPPIES.exe");
//////////////////////////////////////////////////////////////////////////////////
DWORD dwFlags = CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED;
SetLastError(0);
SearchPath(NULL, szExe, ".exe", ARRAYSIZE(szFullExe), szFullExe, &pszFileExe);
if (!DetourCreateProcessWithDllEx(szFullExe[0] ? szFullExe : NULL, szCommand,
NULL, NULL, TRUE, dwFlags, NULL, NULL,
&si, &pi, szDllPath, NULL))
{
DWORD dwError = GetLastError();
MessageBoxA(NULL, "DetourCreateProcessWithDllEx failed\n", "Error", MB_OK);
if (dwError == ERROR_INVALID_HANDLE)
{
#if DETOURS_64BIT
MessageBoxA(NULL, " Can't detour a 32-bit target process from a 64-bit parent process.\n", "Error", MB_OK);
#else
MessageBoxA(NULL, " Can't detour a 64-bit target process from a 32-bit parent process.\n", "Error", MB_OK);
#endif
}
ExitProcess(9009);
}
ResumeThread(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD dwResult = 0;
if (!GetExitCodeProcess(pi.hProcess, &dwResult))
{
MessageBoxA(NULL, "GetExitCodeProcess failed\n", "Error", MB_OK);
return false;
}
return true;
}
示例7: UIShader_Prepare
void MenuScreen::render() {
UIShader_Prepare();
UIBegin(UIShader_Get());
DrawBackground(1.0f);
double xoff = 150 - frames_ * frames_ * 0.4f;
if (xoff < -20)
xoff = -20;
if (frames_ > 200) // seems the above goes nuts after a while...
xoff = -20;
int w = LARGE_BUTTON_WIDTH + 60;
ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 75, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM);
ui_draw2d.SetFontScale(0.7f, 0.7f);
ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_GIT_VERSION, dp_xres + xoff, 85, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM);
ui_draw2d.SetFontScale(1.0f, 1.0f);
VLinear vlinear(dp_xres + xoff, 100, 20);
I18NCategory *m = GetI18NCategory("MainMenu");
if (UIButton(GEN_ID, vlinear, w, 0, m->T("Load", "Load..."), ALIGN_RIGHT)) {
#if defined(USING_QT_UI) && !defined(MEEGO_EDITION_HARMATTAN)
QString fileName = QFileDialog::getOpenFileName(NULL, "Load ROM", g_Config.currentDirectory.c_str(), "PSP ROMs (*.iso *.cso *.pbp *.elf)");
if (QFile::exists(fileName)) {
QDir newPath;
g_Config.currentDirectory = newPath.filePath(fileName).toStdString();
g_Config.Save();
screenManager()->switchScreen(new EmuScreen(fileName.toStdString()));
}
#elif _WIN32
MainWindow::BrowseAndBoot("");
#else
FileSelectScreenOptions options;
options.allowChooseDirectory = true;
options.filter = "iso:cso:pbp:elf:prx:";
options.folderIcon = I_ICON_FOLDER;
options.iconMapping["iso"] = I_ICON_UMD;
options.iconMapping["cso"] = I_ICON_UMD;
options.iconMapping["pbp"] = I_ICON_EXE;
options.iconMapping["elf"] = I_ICON_EXE;
screenManager()->switchScreen(new FileSelectScreen(options));
#endif
UIReset();
}
if (UIButton(GEN_ID, vlinear, w, 0, m->T("Settings"), ALIGN_RIGHT)) {
screenManager()->push(new SettingsScreen(), 0);
UIReset();
}
if (UIButton(GEN_ID, vlinear, w, 0, m->T("Credits"), ALIGN_RIGHT)) {
screenManager()->switchScreen(new CreditsScreen());
UIReset();
}
if (UIButton(GEN_ID, vlinear, w, 0, m->T("Exit"), ALIGN_RIGHT)) {
// TODO: Save when setting changes, rather than when we quit
NativeShutdown();
// TODO: Need a more elegant way to quit
#ifdef _WIN32
ExitProcess(0);
#else
exit(0);
#endif
}
if (UIButton(GEN_ID, vlinear, w, 0, "www.ppsspp.org", ALIGN_RIGHT)) {
LaunchBrowser("http://www.ppsspp.org/");
}
int recentW = 350;
if (g_Config.recentIsos.size()) {
ui_draw2d.DrawText(UBUNTU24, m->T("Recent"), -xoff, 80, 0xFFFFFFFF, ALIGN_BOTTOMLEFT);
}
int spacing = 15;
float textureButtonWidth = 144;
float textureButtonHeight = 80;
if (dp_yres < 480)
spacing = 8;
// On small screens, we can't fit four vertically.
if (100 + spacing * 6 + textureButtonHeight * 4 > dp_yres) {
textureButtonHeight = (dp_yres - 100 - spacing * 6) / 4;
textureButtonWidth = (textureButtonHeight / 80) * 144;
}
VGrid vgrid_recent(-xoff, 100, std::min(dp_yres-spacing*2, 480), spacing, spacing);
for (size_t i = 0; i < g_Config.recentIsos.size(); i++) {
std::string filename;
std::string rec = g_Config.recentIsos[i];
for (size_t j = 0; j < rec.size(); j++)
if (rec[j] == '\\') rec[j] = '/';
SplitPath(rec, nullptr, &filename, nullptr);
UIContext *ctx = screenManager()->getUIContext();
// This might create a texture so we must flush first.
//.........这里部分代码省略.........
示例8: exception_filter
static LONG CALLBACK exception_filter(struct _EXCEPTION_POINTERS *info)
{
static const struct
{
DWORD code;
const char *string;
} exception_table[] =
{
{ EXCEPTION_ACCESS_VIOLATION, "ACCESS VIOLATION" },
{ EXCEPTION_DATATYPE_MISALIGNMENT, "DATATYPE MISALIGNMENT" },
{ EXCEPTION_BREAKPOINT, "BREAKPOINT" },
{ EXCEPTION_SINGLE_STEP, "SINGLE STEP" },
{ EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "ARRAY BOUNDS EXCEEDED" },
{ EXCEPTION_FLT_DENORMAL_OPERAND, "FLOAT DENORMAL OPERAND" },
{ EXCEPTION_FLT_DIVIDE_BY_ZERO, "FLOAT DIVIDE BY ZERO" },
{ EXCEPTION_FLT_INEXACT_RESULT, "FLOAT INEXACT RESULT" },
{ EXCEPTION_FLT_INVALID_OPERATION, "FLOAT INVALID OPERATION" },
{ EXCEPTION_FLT_OVERFLOW, "FLOAT OVERFLOW" },
{ EXCEPTION_FLT_STACK_CHECK, "FLOAT STACK CHECK" },
{ EXCEPTION_FLT_UNDERFLOW, "FLOAT UNDERFLOW" },
{ EXCEPTION_INT_DIVIDE_BY_ZERO, "INTEGER DIVIDE BY ZERO" },
{ EXCEPTION_INT_OVERFLOW, "INTEGER OVERFLOW" },
{ EXCEPTION_PRIV_INSTRUCTION, "PRIVILEGED INSTRUCTION" },
{ EXCEPTION_IN_PAGE_ERROR, "IN PAGE ERROR" },
{ EXCEPTION_ILLEGAL_INSTRUCTION, "ILLEGAL INSTRUCTION" },
{ EXCEPTION_NONCONTINUABLE_EXCEPTION,"NONCONTINUABLE EXCEPTION" },
{ EXCEPTION_STACK_OVERFLOW, "STACK OVERFLOW" },
{ EXCEPTION_INVALID_DISPOSITION, "INVALID DISPOSITION" },
{ EXCEPTION_GUARD_PAGE, "GUARD PAGE VIOLATION" },
{ EXCEPTION_INVALID_HANDLE, "INVALID HANDLE" },
{ 0, "UNKNOWN EXCEPTION" }
};
static int already_hit = 0;
#ifndef PTR64
UINT32 code_start, code_size;
#endif
int i;
// if we're hitting this recursively, just exit
if (already_hit)
ExitProcess(100);
already_hit = 1;
// find our man
for (i = 0; exception_table[i].code != 0; i++)
if (info->ExceptionRecord->ExceptionCode == exception_table[i].code)
break;
// print the exception type and address
fprintf(stderr, "\n-----------------------------------------------------\n");
fprintf(stderr, "Exception at EIP=%08X%s: %s\n", (UINT32)info->ExceptionRecord->ExceptionAddress,
lookup_symbol((UINT32)info->ExceptionRecord->ExceptionAddress), exception_table[i].string);
// for access violations, print more info
if (info->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
fprintf(stderr, "While attempting to %s memory at %08X\n",
info->ExceptionRecord->ExceptionInformation[0] ? "write" : "read",
(UINT32)info->ExceptionRecord->ExceptionInformation[1]);
// print the state of the CPU
fprintf(stderr, "-----------------------------------------------------\n");
#ifdef PTR64
fprintf(stderr, "RAX=%p RBX=%p RCX=%p RDX=%p\n",
(void *)info->ContextRecord->Rax,
(void *)info->ContextRecord->Rbx,
(void *)info->ContextRecord->Rcx,
(void *)info->ContextRecord->Rdx);
fprintf(stderr, "RSI=%p RDI=%p RBP=%p RSP=%p\n",
(void *)info->ContextRecord->Rsi,
(void *)info->ContextRecord->Rdi,
(void *)info->ContextRecord->Rbp,
(void *)info->ContextRecord->Rsp);
fprintf(stderr, " R8=%p R9=%p R10=%p R11=%p\n",
(void *)info->ContextRecord->R8,
(void *)info->ContextRecord->R9,
(void *)info->ContextRecord->R10,
(void *)info->ContextRecord->R11);
fprintf(stderr, "R12=%p R13=%p R14=%p R15=%p\n",
(void *)info->ContextRecord->R12,
(void *)info->ContextRecord->R13,
(void *)info->ContextRecord->R14,
(void *)info->ContextRecord->R15);
#else
fprintf(stderr, "EAX=%p EBX=%p ECX=%p EDX=%p\n",
(void *)info->ContextRecord->Eax,
(void *)info->ContextRecord->Ebx,
(void *)info->ContextRecord->Ecx,
(void *)info->ContextRecord->Edx);
fprintf(stderr, "ESI=%p EDI=%p EBP=%p ESP=%p\n",
(void *)info->ContextRecord->Esi,
(void *)info->ContextRecord->Edi,
(void *)info->ContextRecord->Ebp,
(void *)info->ContextRecord->Esp);
#endif
#ifndef PTR64
// crawl the stack for a while
if (get_code_base_size(&code_start, &code_size))
{
char prev_symbol[1024], curr_symbol[1024];
//.........这里部分代码省略.........
示例9: main
int main(int argc, char **argv)
{
struct cmdline_args args = {0};
int ret = 0;
setvbuf(stderr, NULL, _IOFBF, 0);
setvbuf(stdout, NULL, _IOFBF, 0);
opdb_reset();
ctrlc_init();
args.devarg.vcc_mv = 3000;
args.devarg.requested_serial = NULL;
if (parse_cmdline_args(argc, argv, &args) < 0)
goto fail_parse;
if (args.flags & OPT_EMBEDDED)
input_module = &input_async;
if (input_module->init() < 0)
goto fail_input;
output_set_embedded(args.flags & OPT_EMBEDDED);
if (sockets_init() < 0) {
ret = -1;
goto fail_sockets;
}
printc_dbg("%s\n", version_text);
if (setup_driver(&args) < 0) {
ret = -1;
goto fail_driver;
}
if (device_probe_id(device_default) < 0)
printc_err("warning: device ID probe failed\n");
simio_init();
if (!(args.flags & OPT_NO_RC))
process_rc_file(args.alt_config);
/* Process commands */
if (optind < argc) {
while (optind < argc) {
if (process_command(argv[optind++]) < 0) {
ret = -1;
break;
}
}
} else {
reader_loop();
}
simio_exit();
device_destroy();
stab_exit();
fail_driver:
sockets_exit();
fail_sockets:
input_module->exit();
fail_input:
fail_parse:
/* We need to do this on Windows, because in embedded mode we
* may still have a running background thread for input. If so,
* returning from main() won't cause the process to terminate.
*/
#if defined(__Windows__) || defined(__CYGWIN__)
ExitProcess(ret);
#endif
return ret;
}
示例10: WorkerThread
DWORD
WorkerThread(
PVOID ThreadIndex
)
{
DWORD Me;
PDWORD MyCellVectorBase;
PDWORD CurrentCellVector;
DWORD MyRecalcValue;
DWORD MyNumberOfCells;
DWORD i;
BOOL MemoryContention;
Me = (DWORD)ThreadIndex;
MyRecalcValue = 0;
MyCellVectorBase = ThreadWork[Me].CellVector;
MyNumberOfCells = ThreadWork[Me].NumberOfCells;
MemoryContention = fMemoryContention;
//
// Signal that I am ready to go
//
if ( !SetEvent(ThreadReadyDoneEvents[Me]) ) {
fprintf(stderr,"MTBNCH: (1) SetEvent(ThreadReadyDoneEvent[%d]) Failed %d\n",Me,GetLastError());
ExitProcess(1);
}
//
// Wait for the master to release us to do the recalc
//
i = WaitForSingleObject(hStartOfRace,INFINITE);
if ( i == WAIT_FAILED ) {
fprintf(stderr,"MTBNCH: Thread %d Wait for start of recalc Failed %d\n",Me,GetLastError());
ExitProcess(1);
}
//
// perform the recalc operation
//
for (i=0, CurrentCellVector = MyCellVectorBase; i<MyNumberOfCells; i++ ) {
MyRecalcValue += *CurrentCellVector++;
if ( MemoryContention ) {
InterlockedIncrement(&ContentionValue);
}
}
ThreadWork[Me].RecalcResult = MyRecalcValue;
//
// Signal that I am done and then wait for further instructions
//
if ( !SetEvent(ThreadReadyDoneEvents[Me]) ) {
fprintf(stderr,"MTBNCH: (2) SetEvent(ThreadReadyDoneEvent[%d]) Failed %d\n",Me,GetLastError());
ExitProcess(1);
}
i = WaitForSingleObject(hEndOfRace,INFINITE);
if ( i == WAIT_FAILED ) {
fprintf(stderr,"MTBNCH: Thread %d Wait for end of recalc Failed %d\n",Me,GetLastError());
ExitProcess(1);
}
return MyRecalcValue;
}
示例11: main
int _CRTAPI1
main(
int argc,
char *argv[],
char *envp[]
)
{
DWORD StartTicks, EndTicks;
DWORD i;
BOOL fShowUsage;
char c, *p, *whocares;
PDWORD CellVector;
DWORD NumberOfDwords;
DWORD DwordsPerThread;
DWORD ThreadId;
LPSTR Answer;
fShowUsage = FALSE;
fMemoryContention = FALSE;
if (argc <= 1) {
goto showUsage;
}
while (--argc) {
p = *++argv;
if (*p == '/' || *p == '-') {
while (c = *++p)
switch (toupper( c )) {
case '?':
fShowUsage = TRUE;
goto showUsage;
break;
case 'M':
if (!argc--) {
fShowUsage = TRUE;
goto showUsage;
}
argv++;
Mb = strtoul(*argv,&whocares,10);
break;
case 'C':
fMemoryContention = TRUE;
break;
case 'T':
if (!argc--) {
fShowUsage = TRUE;
goto showUsage;
}
argv++;
NumberOfThreads = strtoul(*argv,&whocares,10);
if ( NumberOfThreads > MAX_THREADS ) {
fShowUsage = TRUE;
goto showUsage;
}
break;
default:
fprintf( stderr, "MTBNCH: Invalid switch - /%c\n", c );
goto showUsage;
break;
}
}
}
showUsage:
if ( fShowUsage ) {
fprintf(stderr,"usage: MTBNCH\n" );
fprintf(stderr," [-?] display this message\n" );
fprintf(stderr," [-t n] use n threads for benchmark (less than 32)\n" );
fprintf(stderr," [-m n] use an n Mb spreadsheet size (default 4)\n" );
fprintf(stderr," [-c] cause memory contention on each loop iteration\n" );
ExitProcess(1);
}
//
// Prepare the race events. These are manual reset events.
//
hStartOfRace = CreateEvent(NULL,TRUE,FALSE,NULL);
hEndOfRace = CreateEvent(NULL,TRUE,FALSE,NULL);
if ( !hStartOfRace || !hEndOfRace ) {
fprintf(stderr,"MTBNCH: Race Event Creation Failed\n");
ExitProcess(1);
}
//
// Prepare the ready done events. These are auto clearing events
//
for(i=0; i<NumberOfThreads; i++ ) {
ThreadReadyDoneEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
if ( !ThreadReadyDoneEvents[i] ) {
fprintf(stderr,"MTBNCH: Ready Done Event Creation Failed %d\n",GetLastError());
ExitProcess(1);
}
//.........这里部分代码省略.........
示例12: WinProcCallback
//
// WinProcCallback
//
INT_PTR WINAPI WinProcCallback(
HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
// Routine Description:
// Simple Windows callback for handling messages.
// This is where all the work is done because the example
// is using a window to process messages. This logic would be handled
// differently if registering a service instead of a window.
// Parameters:
// hWnd - the window handle being registered for events.
// message - the message being interpreted.
// wParam and lParam - extended information provided to this
// callback by the message sender.
// For more information regarding these parameters and return value,
// see the documentation for WNDCLASSEX and CreateWindowEx.
{
LRESULT lRet = 1;
static HDEVNOTIFY hDeviceNotify;
static HWND hEditWnd;
static ULONGLONG msgCount = 0;
switch (message)
{
case WM_CREATE:
//
// This is the actual registration., In this example, registration
// should happen only once, at application startup when the window
// is created.
//
// If you were using a service, you would put this in your main code
// path as part of your service initialization.
//
if (!DoRegisterDeviceInterfaceToHwnd(
WceusbshGUID,
hWnd,
&hDeviceNotify))
{
// Terminate on failure.
ErrorHandler(TEXT("DoRegisterDeviceInterfaceToHwnd"));
ExitProcess(1);
}
//
// Make the child window for output.
//
hEditWnd = CreateWindow(TEXT("EDIT"),// predefined class
NULL, // no window title
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 0, 0, // set size in WM_SIZE message
hWnd, // parent window
(HMENU)1, // edit control ID
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
NULL); // pointer not needed
if (hEditWnd == NULL)
{
// Terminate on failure.
ErrorHandler(TEXT("CreateWindow: Edit Control"));
ExitProcess(1);
}
// Add text to the window.
SendMessage(hEditWnd, WM_SETTEXT, 0,
(LPARAM)TEXT("Registered for USB device notification...\n"));
break;
case WM_SETFOCUS:
SetFocus(hEditWnd);
break;
case WM_SIZE:
// Make the edit control the size of the window's client area.
MoveWindow(hEditWnd,
0, 0, // starting x- and y-coordinates
LOWORD(lParam), // width of client area
HIWORD(lParam), // height of client area
TRUE); // repaint window
break;
case WM_DEVICECHANGE:
{
//
// This is the actual message from the interface via Windows messaging.
// This code includes some additional decoding for this particular device type
// and some common validation checks.
//
//.........这里部分代码省略.........
示例13: WinMainCRTStartup
// this is a simplified entry point ...
void __stdcall WinMainCRTStartup()
{
ExitProcess(WinMain(GetModuleHandle(NULL), NULL, NULL, 0));
}
示例14: switch
LRESULT WindowImplBase::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
styleValue &= ~( WS_CAPTION );
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
RECT rcClient;
::GetClientRect(*this, &rcClient);
::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, \
rcClient.bottom - rcClient.top, SWP_FRAMECHANGED);
m_PaintManager.Init(m_hWnd);
m_PaintManager.AddPreMessageFilter(this);
CDialogBuilder builder;
CDuiString strResourcePath=m_PaintManager.GetInstancePath();
strResourcePath+=GetSkinFolder().GetData();
m_PaintManager.SetResourcePath(strResourcePath.GetData());
switch(GetResourceType())
{
case UILIB_ZIP:
m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true);
break;
case UILIB_ZIPRESOURCE:
{
HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("WDKJ001"));
if( hResource == NULL )
return 0L;
DWORD dwSize = 0;
HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource);
if( hGlobal == NULL )
{
#if defined(WIN32) && !defined(UNDER_CE)
::FreeResource(hResource);
#endif
return 0L;
}
dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource);
if( dwSize == 0 )
return 0L;
m_lpResourceZIPBuffer = new BYTE[ dwSize ];
if (m_lpResourceZIPBuffer != NULL)
{
::CopyMemory(m_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize);
}
#if defined(WIN32) && !defined(UNDER_CE)
::FreeResource(hResource);
#endif
m_PaintManager.SetResourceZip(m_lpResourceZIPBuffer, dwSize);
}
break;
}
CControlUI* pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager);
ASSERT(pRoot);
if (pRoot==NULL)
{
MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR);
ExitProcess(1);
return 0;
}
m_PaintManager.AttachDialog(pRoot);
m_PaintManager.AddNotifier(this);
m_PaintManager.SetBackgroundTransparent(TRUE);
InitWindow();
return 0;
}
示例15: DebugBreakDo
static void DebugBreakDo()
{
__debugbreak();
ExitProcess(0);
}