本文整理汇总了C++中SetErrorMode函数的典型用法代码示例。如果您正苦于以下问题:C++ SetErrorMode函数的具体用法?C++ SetErrorMode怎么用?C++ SetErrorMode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetErrorMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
int retCode = 1; // by default it's error
#ifdef DEBUG
// Memory leak detection (only enable _CRTDBG_LEAK_CHECK_DF for
// regular termination so that leaks aren't checked on exceptions,
// aborts, etc. where some clean-up might not take place)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF);
//_CrtSetBreakAlloc(421);
TryLoadMemTrace();
#endif
DisableDataExecution();
// ensure that C functions behave consistently under all OS locales
// (use Win32 functions where localized input or output is desired)
setlocale(LC_ALL, "C");
// don't show system-provided dialog boxes when accessing files on drives
// that are not mounted (e.g. a: drive without floppy or cd rom drive
// without a cd).
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
#if defined(DEBUG) || defined(SVN_PRE_RELEASE_VER)
if (str::StartsWith(lpCmdLine, "/tester")) {
extern int TesterMain(); // in Tester.cpp
return TesterMain();
}
if (str::StartsWith(lpCmdLine, "/regress")) {
extern int RegressMain(); // in Regress.cpp
return RegressMain();
}
#endif
#ifdef SUPPORTS_AUTO_UPDATE
if (str::StartsWith(lpCmdLine, "-autoupdate")) {
bool quit = AutoUpdateMain();
if (quit)
return 0;
}
#endif
srand((unsigned int)time(NULL));
// load uiautomationcore.dll before installing crash handler (i.e. initializing
// dbghelp.dll), so that we get function names/offsets in GetCallstack()
uia::Initialize();
#ifdef DEBUG
dbghelp::RememberCallstackLogs();
#endif
SetupCrashHandler();
ScopedOle ole;
InitAllCommonControls();
ScopedGdiPlus gdiPlus(true);
mui::Initialize();
uitask::Initialize();
prefs::Load();
CommandLineInfo i(GetCommandLine());
SetCurrentLang(i.lang ? i.lang : gGlobalPrefs->uiLanguage);
// This allows ad-hoc comparison of gdi, gdi+ and gdi+ quick when used
// in layout
#if 0
RedirectIOToConsole();
BenchEbookLayout(L"C:\\kjk\\downloads\\pg12.mobi");
system("pause");
goto Exit;
#endif
if (i.showConsole) {
RedirectIOToConsole();
RedirectDllIOToConsole();
}
if (i.makeDefault)
AssociateExeWithPdfExtension();
if (i.pathsToBenchmark.Count() > 0) {
BenchFileOrDir(i.pathsToBenchmark);
if (i.showConsole)
system("pause");
}
if (i.exitImmediately)
goto Exit;
gCrashOnOpen = i.crashOnOpen;
gPolicyRestrictions = GetPolicies(i.restrictedUse);
GetFixedPageUiColors(gRenderCache.textColor, gRenderCache.backgroundColor);
DebugGdiPlusDevice(gUseGdiRenderer);
if (!RegisterWinClass())
goto Exit;
CrashIf(hInstance != GetModuleHandle(NULL));
if (!InstanceInit(nCmdShow))
goto Exit;
if (i.hwndPluginParent) {
//.........这里部分代码省略.........
示例2: ms_load_plugins
int ms_load_plugins(const char *dir){
int num=0;
#if defined(WIN32) && !defined(_WIN32_WCE)
WIN32_FIND_DATA FileData;
HANDLE hSearch;
char szDirPath[1024];
char szPluginFile[1024];
BOOL fFinished = FALSE;
const char *tmp=getenv("DEBUG");
BOOL debug=(tmp!=NULL && atoi(tmp)==1);
snprintf(szDirPath, sizeof(szDirPath), "%s", dir);
// Start searching for .dll files in the current directory.
snprintf(szDirPath, sizeof(szDirPath), "%s\\*.dll", dir);
hSearch = FindFirstFile(szDirPath, &FileData);
if (hSearch == INVALID_HANDLE_VALUE)
{
ms_message("no plugin (*.dll) found in %s.", szDirPath);
return 0;
}
snprintf(szDirPath, sizeof(szDirPath), "%s", dir);
while (!fFinished)
{
/* load library */
HINSTANCE os_handle;
UINT em;
if (!debug) em = SetErrorMode (SEM_FAILCRITICALERRORS);
snprintf(szPluginFile, sizeof(szPluginFile), "%s\\%s", szDirPath, FileData.cFileName);
os_handle = LoadLibraryEx (szPluginFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (os_handle==NULL)
{
ms_message("Fail to load plugin %s with altered search path: error %i",szPluginFile,GetLastError());
os_handle = LoadLibraryEx (szPluginFile, NULL, 0);
}
if (!debug) SetErrorMode (em);
if (os_handle==NULL)
ms_error("Fail to load plugin %s", szPluginFile);
else{
init_func_t initroutine;
char szPluginName[256];
char szMethodName[256];
char *minus;
snprintf(szPluginName, 256, "%s", FileData.cFileName);
/*on mingw, dll names might be libsomething-3.dll. We must skip the -X.dll stuff*/
minus=strchr(szPluginName,'-');
if (minus) *minus='\0';
else szPluginName[strlen(szPluginName)-4]='\0'; /*remove .dll*/
snprintf(szMethodName, 256, "%s_init", szPluginName);
initroutine = (init_func_t) GetProcAddress (os_handle, szMethodName);
if (initroutine!=NULL){
initroutine();
ms_message("Plugin loaded (%s)", szPluginFile);
num++;
}else{
ms_warning("Could not locate init routine of plugin %s. Should be %s",
szPluginFile, szMethodName);
}
}
if (!FindNextFile(hSearch, &FileData)) {
if (GetLastError() == ERROR_NO_MORE_FILES){
fFinished = TRUE;
}
else
{
ms_error("couldn't find next plugin dll.");
fFinished = TRUE;
}
}
}
/* Close the search handle. */
FindClose(hSearch);
#elif HAVE_DLOPEN
DIR *ds;
struct dirent *de;
char *fullpath;
ds=opendir(dir);
if (ds==NULL){
ms_message("Cannot open directory %s: %s",dir,strerror(errno));
return -1;
}
while( (de=readdir(ds))!=NULL){
if ((de->d_type==DT_REG && strstr(de->d_name,PLUGINS_EXT)!=NULL)
|| (de->d_type==DT_UNKNOWN && strstr(de->d_name,PLUGINS_EXT)==de->d_name+strlen(de->d_name)-strlen(PLUGINS_EXT))) {
void *handle;
fullpath=ms_strdup_printf("%s/%s",dir,de->d_name);
ms_message("Loading plugin %s...",fullpath);
if ( (handle=dlopen(fullpath,RTLD_NOW))==NULL){
ms_warning("Fail to load plugin %s : %s",fullpath,dlerror());
}else {
char *initroutine_name=ms_malloc0(strlen(de->d_name)+10);
char *p;
void *initroutine=NULL;
strcpy(initroutine_name,de->d_name);
p=strstr(initroutine_name,PLUGINS_EXT);
if (p!=NULL){
//.........这里部分代码省略.........
示例3: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char commandLine[MAX_STRING_CHARS] = { 0 };
char cwd[MAX_OSPATH];
// should never get a previous instance in Win32
if (hPrevInstance)
{
return EXIT_FAILURE;
}
#ifdef EXCEPTION_HANDLER
WinSetExceptionVersion(Q3_VERSION);
#endif
g_wv.hInstance = hInstance;
#if 1
commandLine[0] = '\0';
Sys_ParseArgs(__argc, __argv);
Sys_BuildCommandLine(__argc, __argv, commandLine, sizeof(commandLine));
#else
Q_strncpyz(commandLine, lpCmdLine, sizeof(commandLine));
#endif
#ifndef DEDICATED
Sys_SetProcessProperties();
//show the splash screen
Sys_Splash(qtrue);
#endif
#ifdef USE_WINDOWS_CONSOLE
// done before Com/Sys_Init since we need this for error output
Sys_CreateConsole();
#endif
#ifdef DEDICATED
Sys_ShowConsoleWindow(1, qtrue);
#endif
// no abort/retry/fail errors
SetErrorMode(SEM_FAILCRITICALERRORS);
// get the initial time base
Sys_Milliseconds();
Com_Init(commandLine);
NET_Init();
Sys_Splash(qfalse);
_getcwd(cwd, sizeof(cwd));
Com_Printf("Working directory: %s\n", cwd);
// hide the early console since we've reached the point where we
// have a working graphics subsystems
#ifndef LEGACY_DEBUG
if (!com_dedicated->integer && !com_viewlog->integer)
{
Sys_ShowConsoleWindow(0, qfalse);
}
#endif
// main game loop
Sys_GameLoop();
// never gets here
return EXIT_SUCCESS;
}
示例4: main
/*
==================
WinMain
==================
*/
int main(int argc, char *argv[]) {
const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) );
Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 );
win32.hInstance = GetModuleHandle(NULL);
// done before Com/Sys_Init since we need this for error output
Sys_CreateConsole();
// no abort/retry/fail errors
SetErrorMode( SEM_FAILCRITICALERRORS );
#ifdef DEBUG
// disable the painfully slow MS heap check every 1024 allocs
_CrtSetDbgFlag( 0 );
#endif
if ( argc > 1 ) {
common->Init( argc-1, &argv[1] );
} else {
common->Init( 0, NULL );
}
// hide or show the early console as necessary
if ( win32.win_viewlog.GetInteger() || com_skipRenderer.GetBool() || idAsyncNetwork::serverDedicated.GetInteger() ) {
Sys_ShowConsole( 1, true );
} else {
Sys_ShowConsole( 0, false );
}
#ifdef SET_THREAD_AFFINITY
// give the main thread an affinity for the first cpu
SetThreadAffinityMask( GetCurrentThread(), 1 );
#endif
::SetCursor( hcurSave );
// Launch the script debugger
if ( strstr( GetCommandLine(), "+debugger" ) ) {
// DebuggerClientInit( lpCmdLine );
return 0;
}
::SetFocus( win32.hWnd );
// main game loop
while( 1 ) {
Win_Frame();
#ifdef ID_ALLOW_TOOLS
if ( com_editors ) {
if ( com_editors & EDITOR_GUI ) {
// GUI editor
GUIEditorRun();
} else if ( com_editors & EDITOR_RADIANT ) {
// Level Editor
RadiantRun();
}
else if (com_editors & EDITOR_MATERIAL ) {
//BSM Nerve: Add support for the material editor
MaterialEditorRun();
}
else {
if ( com_editors & EDITOR_LIGHT ) {
// in-game Light Editor
LightEditorRun();
}
if ( com_editors & EDITOR_SOUND ) {
// in-game Sound Editor
SoundEditorRun();
}
if ( com_editors & EDITOR_DECL ) {
// in-game Declaration Browser
DeclBrowserRun();
}
if ( com_editors & EDITOR_AF ) {
// in-game Articulated Figure Editor
AFEditorRun();
}
if ( com_editors & EDITOR_PARTICLE ) {
// in-game Particle Editor
ParticleEditorRun();
}
if ( com_editors & EDITOR_SCRIPT ) {
// in-game Script Editor
ScriptEditorRun();
}
if ( com_editors & EDITOR_PDA ) {
// in-game PDA Editor
PDAEditorRun();
}
}
}
//.........这里部分代码省略.........
示例5: WinMain
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE /*hPrevInst*/, LPSTR lpszArgs, int nWndMode)
{
/**************************************
*
* W i n M a i n
*
**************************************
*
* Functional description
* Run the server with NT named
* pipes and/or TCP/IP sockets.
*
**************************************/
hInst = hThisInst;
// We want server to crash without waiting for feedback from the user
try
{
if (!Config::getBugcheckAbort())
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
}
catch (Firebird::fatal_exception& e)
{
MessageBox(NULL, e.what(), "Firebird server failure",
MB_OK | MB_ICONHAND | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY);
return STARTUP_ERROR; // see /jrd/common.h
}
catch (Firebird::status_exception& e)
{
TEXT buffer[BUFFER_LARGE];
const ISC_STATUS* vector = e.value();
if (! (vector && fb_interpret(buffer, sizeof(buffer), &vector)))
{
strcpy(buffer, "Unknown internal failure");
}
MessageBox(NULL, buffer, "Firebird server failure",
MB_OK | MB_ICONHAND | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY);
return STARTUP_ERROR; // see /jrd/common.h
}
#ifdef SUPERSERVER
server_flag = SRVR_multi_client;
#else
server_flag = 0;
#endif
#ifdef SUPERSERVER
SetProcessAffinityMask(GetCurrentProcess(), static_cast<DWORD>(Config::getCpuAffinityMask()));
#endif
protocol_inet[0] = 0;
protocol_wnet[0] = 0;
strcpy(instance, FB_DEFAULT_INSTANCE);
const HANDLE connection_handle = parse_args(lpszArgs, &server_flag);
#ifdef SUPERSERVER
// get priority class from the config file
int priority = Config::getProcessPriorityLevel();
// override it, if necessary
if (server_flag & SRVR_high_priority) {
priority = 1;
}
// set priority class
if (priority > 0) {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
else if (priority < 0) {
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
}
#endif
TEXT mutex_name[MAXPATHLEN];
fb_utils::snprintf(mutex_name, sizeof(mutex_name), SERVER_MUTEX, instance);
fb_utils::prefix_kernel_object_name(mutex_name, sizeof(mutex_name));
CreateMutex(ISC_get_security_desc(), FALSE, mutex_name);
// Initialize the service
ISC_signal_init();
Firebird::FpeControl::maskAll();
int nReturnValue = 0;
ISC_STATUS_ARRAY status_vector;
fb_utils::init_status(status_vector);
fb_shutdown_callback(0, wait_threads, fb_shut_finish, NULL);
if (connection_handle != INVALID_HANDLE_VALUE)
{
rem_port* port = 0;
if (server_flag & SRVR_inet)
{
port = INET_reconnect((SOCKET) connection_handle, status_vector);
//.........这里部分代码省略.........
示例6: ListView_DeleteAllItems
void
FileTransfer::ShowClientItems(char *path)
{
if (strlen(path) == 0) {
//Show Logical Drives
ListView_DeleteAllItems(m_hwndFTClientList);
m_FTClientItemInfo.Free();
int LengthDrivesString = 0;
char DrivesString[256];
char DriveName[rfbMAX_PATH] = "?:";
LengthDrivesString = GetLogicalDriveStrings(256, DrivesString);
if ((LengthDrivesString == 0) || (LengthDrivesString > 256)) {
BlockingFileTransferDialog(TRUE);
strcpy(m_ClientPathTmp, m_ClientPath);
return;
} else {
strcpy(m_ClientPath, m_ClientPathTmp);
SetWindowText(m_hwndFTClientPath, m_ClientPath);
for (int i=0; i<256; i++) {
DriveName[0] = DrivesString[i];
char txt[16];
strcpy(txt, m_FTClientItemInfo.folderText);
m_FTClientItemInfo.Add(DriveName, txt, 0);
DriveName[0] = '\0';
i+=3;
if ((DrivesString[i] == '\0') && (DrivesString[i+1] == '\0')) break;
}
m_FTClientItemInfo.Sort();
ShowListViewItems(m_hwndFTClientList, &m_FTClientItemInfo);
}
} else {
//Show Files
HANDLE m_handle;
int n = 0;
WIN32_FIND_DATA m_FindFileData;
strcat(path, "\\*");
SetErrorMode(SEM_FAILCRITICALERRORS);
m_handle = FindFirstFile(path, &m_FindFileData);
DWORD LastError = GetLastError();
SetErrorMode(0);
if (m_handle == INVALID_HANDLE_VALUE) {
if (LastError != ERROR_SUCCESS && LastError != ERROR_FILE_NOT_FOUND) {
strcpy(m_ClientPathTmp, m_ClientPath);
FindClose(m_handle);
BlockingFileTransferDialog(TRUE);
return;
}
path[strlen(path) - 2] = '\0';
strcpy(m_ClientPath, m_ClientPathTmp);
SetWindowText(m_hwndFTClientPath, m_ClientPath);
FindClose(m_handle);
ListView_DeleteAllItems(m_hwndFTClientList);
BlockingFileTransferDialog(TRUE);
return;
}
ListView_DeleteAllItems(m_hwndFTClientList);
m_FTClientItemInfo.Free();
char buffer[16];
while(1) {
if ((strcmp(m_FindFileData.cFileName, ".") != 0) &&
(strcmp(m_FindFileData.cFileName, "..") != 0)) {
if (!(m_FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(buffer, "%d", m_FindFileData.nFileSizeLow);
LARGE_INTEGER li;
li.LowPart = m_FindFileData.ftLastWriteTime.dwLowDateTime;
li.HighPart = m_FindFileData.ftLastWriteTime.dwHighDateTime;
li.QuadPart = (li.QuadPart - 116444736000000000) / 10000000;
m_FTClientItemInfo.Add(m_FindFileData.cFileName, buffer, li.LowPart);
} else {
strcpy(buffer, m_FTClientItemInfo.folderText);
m_FTClientItemInfo.Add(m_FindFileData.cFileName, buffer, 0);
}
}
if (!FindNextFile(m_handle, &m_FindFileData)) break;
}
FindClose(m_handle);
m_FTClientItemInfo.Sort();
ShowListViewItems(m_hwndFTClientList, &m_FTClientItemInfo);
path[strlen(path) - 2] = '\0';
strcpy(m_ClientPath, m_ClientPathTmp);
SetWindowText(m_hwndFTClientPath, m_ClientPath);
}
BlockingFileTransferDialog(TRUE);
}
示例7: hb_fsDiskSpace
double hb_fsDiskSpace( const char * pszPath, HB_USHORT uiType )
{
char szPathBuf[ 2 ];
double dSpace = 0.0;
if( uiType > HB_DISK_TOTAL )
uiType = HB_DISK_AVAIL;
if( ! pszPath )
{
szPathBuf[ 0 ] = HB_OS_PATH_DELIM_CHR;
szPathBuf[ 1 ] = '\0';
pszPath = szPathBuf;
}
#if defined( HB_OS_WIN )
{
LPCTSTR lpPath;
LPTSTR lpFree;
lpPath = HB_FSNAMECONV( pszPath, &lpFree );
{
UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
HB_BOOL fResult;
#if ! defined( HB_OS_WIN_CE ) && ! defined( HB_OS_WIN_64 )
/* NOTE: We need to call this function dynamically to maintain support
Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
static P_GDFSE s_pGetDiskFreeSpaceEx = NULL;
static HB_BOOL s_fInit = HB_FALSE;
if( ! s_fInit )
{
HMODULE hModule = GetModuleHandle( HB_WINAPI_KERNEL32_DLL() );
if( hModule )
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
HB_WINAPI_GETPROCADDRESST( hModule, "GetDiskFreeSpaceEx" );
s_fInit = HB_TRUE;
}
if( ! s_pGetDiskFreeSpaceEx )
{
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) ? HB_TRUE : HB_FALSE;
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
switch( uiType )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
}
}
}
else
#endif
{
#if defined( _MSC_VER ) || defined( __LCC__ ) || \
( defined( __GNUC__ ) && ! defined( __RSXNT__ ) )
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).LowPart + \
( double ) (v).HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#else
/* NOTE: Borland doesn't seem to deal with the un-named
struct that is part of ULARGE_INTEGER
[pt] */
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).u.LowPart + \
( double ) (v).u.HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif
//.........这里部分代码省略.........
示例8: wWinMain
INT WINAPI wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ PWSTR lpCmdLine,
_In_ INT nCmdShow
)
{
LONG result;
#ifdef DEBUG
PHP_BASE_THREAD_DBG dbg;
#endif
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
#ifndef DEBUG
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
#endif
PhInstanceHandle = (HINSTANCE)NtCurrentPeb()->ImageBaseAddress;
if (!NT_SUCCESS(PhInitializePhLib()))
return 1;
if (!PhInitializeAppSystem())
return 1;
PhInitializeCommonControls();
if (PhCurrentTokenQueryHandle)
{
PTOKEN_USER tokenUser;
if (NT_SUCCESS(PhGetTokenUser(PhCurrentTokenQueryHandle, &tokenUser)))
{
PhCurrentUserName = PhGetSidFullName(tokenUser->User.Sid, TRUE, NULL);
PhFree(tokenUser);
}
}
PhLocalSystemName = PhGetSidFullName(&PhSeLocalSystemSid, TRUE, NULL);
// There has been a report of the above call failing.
if (!PhLocalSystemName)
PhLocalSystemName = PhCreateString(L"NT AUTHORITY\\SYSTEM");
PhApplicationFileName = PhGetApplicationFileName();
PhApplicationDirectory = PhGetApplicationDirectory();
// Just in case
if (!PhApplicationFileName)
PhApplicationFileName = PhCreateString(L"ProcessHacker.exe");
if (!PhApplicationDirectory)
PhApplicationDirectory = PhReferenceEmptyString();
PhpProcessStartupParameters();
PhSettingsInitialization();
PhpEnablePrivileges();
if (PhStartupParameters.RunAsServiceMode)
{
RtlExitUserProcess(PhRunAsServiceStart(PhStartupParameters.RunAsServiceMode));
}
PhpInitializeSettings();
// Activate a previous instance if required.
if (PhGetIntegerSetting(L"AllowOnlyOneInstance") &&
!PhStartupParameters.NewInstance &&
!PhStartupParameters.ShowOptions &&
!PhStartupParameters.CommandMode &&
!PhStartupParameters.PhSvc)
{
PhActivatePreviousInstance();
}
if (PhGetIntegerSetting(L"EnableKph") && !PhStartupParameters.NoKph && !PhIsExecutingInWow64())
PhInitializeKph();
if (PhStartupParameters.CommandMode && PhStartupParameters.CommandType && PhStartupParameters.CommandAction)
{
NTSTATUS status;
status = PhCommandModeStart();
if (!NT_SUCCESS(status) && !PhStartupParameters.Silent)
{
PhShowStatus(NULL, L"Unable to execute the command", status, 0);
}
RtlExitUserProcess(status);
}
#ifdef DEBUG
dbg.ClientId = NtCurrentTeb()->ClientId;
dbg.StartAddress = wWinMain;
dbg.Parameter = NULL;
InsertTailList(&PhDbgThreadListHead, &dbg.ListEntry);
TlsSetValue(PhDbgThreadDbgTlsIndex, &dbg);
#endif
PhInitializeAutoPool(&BaseAutoPool);
//.........这里部分代码省略.........
示例9: NOTE
HRESULT CLoadDirectDraw::LoadDirectDraw(LPSTR szDevice)
{
PDRAWCREATE pDrawCreate;
PDRAWENUM pDrawEnum;
LPDIRECTDRAWENUMERATEEXA pDrawEnumEx;
HRESULT hr = NOERROR;
NOTE("Entering DoLoadDirectDraw");
// Is DirectDraw already loaded
if (m_pDirectDraw) {
NOTE("Already loaded");
ASSERT(m_hDirectDraw);
return NOERROR;
}
// Make sure the library is available
if(!m_hDirectDraw)
{
UINT ErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX);
m_hDirectDraw = LoadLibrary(TEXT("DDRAW.DLL"));
SetErrorMode(ErrorMode);
if (m_hDirectDraw == NULL) {
DbgLog((LOG_ERROR,1,TEXT("Can't load DDRAW.DLL")));
NOTE("No library");
return E_NOINTERFACE;
}
}
// Get the DLL address for the creator function
pDrawCreate = (PDRAWCREATE)GetProcAddress(m_hDirectDraw,"DirectDrawCreate");
// force ANSI, we assume it
pDrawEnum = (PDRAWENUM)GetProcAddress(m_hDirectDraw,"DirectDrawEnumerateA");
pDrawEnumEx = (LPDIRECTDRAWENUMERATEEXA)GetProcAddress(m_hDirectDraw,
"DirectDrawEnumerateExA");
// We don't NEED DirectDrawEnumerateEx, that's just for multimon stuff
if (pDrawCreate == NULL || pDrawEnum == NULL) {
DbgLog((LOG_ERROR,1,TEXT("Can't get functions: Create=%x Enum=%x"),
pDrawCreate, pDrawEnum));
NOTE("No entry point");
ReleaseDirectDraw();
return E_NOINTERFACE;
}
DbgLog((LOG_TRACE,3,TEXT("Creating DDraw for device %s"),
szDevice ? szDevice : "<NULL>"));
// Create a DirectDraw display provider for this device, using the fancy
// multimon-aware version, if it exists
if (pDrawEnumEx)
m_pDirectDraw = DirectDrawCreateFromDeviceEx(szDevice, pDrawCreate,
pDrawEnumEx);
else
m_pDirectDraw = DirectDrawCreateFromDevice(szDevice, pDrawCreate,
pDrawEnum);
if (m_pDirectDraw == NULL) {
DbgLog((LOG_ERROR,1,TEXT("Can't create DDraw")));
NOTE("No instance");
ReleaseDirectDraw();
return E_NOINTERFACE;
}
return NOERROR;
}
示例10: SetErrorMode
void *dlopen( const char *file, int mode )
{
HMODULE hModule;
UINT uMode;
current_error = NULL;
/* Do not let Windows display the critical-error-handler message box */
uMode = SetErrorMode( SEM_FAILCRITICALERRORS );
if( file == 0 )
{
/* POSIX says that if the value of file is 0, a handle on a global
* symbol object must be provided. That object must be able to access
* all symbols from the original program file, and any objects loaded
* with the RTLD_GLOBAL flag.
* The return value from GetModuleHandle( ) allows us to retrieve
* symbols only from the original program file. For objects loaded with
* the RTLD_GLOBAL flag, we create our own list later on.
*/
hModule = GetModuleHandle( NULL );
if( !hModule )
save_err_ptr_str( file );
}
else
{
char lpFileName[MAX_PATH];
int i;
/* MSDN says backslashes *must* be used instead of forward slashes. */
for( i = 0 ; i < sizeof(lpFileName)-1 ; i++ )
{
if( !file[i] )
break;
else if( file[i] == '/' )
lpFileName[i] = '\\';
else
lpFileName[i] = file[i];
}
lpFileName[i] = '\0';
/* POSIX says the search path is implementation-defined.
* LOAD_WITH_ALTERED_SEARCH_PATH is used to make it behave more closely
* to UNIX's search paths (start with system folders instead of current
* folder).
*/
hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH );
/* If the object was loaded with RTLD_GLOBAL, add it to list of global
* objects, so that its symbols may be retrieved even if the handle for
* the original program file is passed. POSIX says that if the same
* file is specified in multiple invocations, and any of them are
* RTLD_GLOBAL, even if any further invocations use RTLD_LOCAL, the
* symbols will remain global.
*/
if( !hModule )
save_err_str( lpFileName );
else if( (mode & RTLD_GLOBAL) )
global_add( hModule );
}
/* Return to previous state of the error-mode bit flags. */
SetErrorMode( uMode );
return (void *) hModule;
}
示例11: evtxtools_signal_attach
/* Attaches a signal handler for Ctrl+C or Ctrl+Break signals
* Returns 1 if successful or -1 on error
*/
int evtxtools_signal_attach(
void (*signal_handler)( evtxtools_signal_t ),
libcerror_error_t **error )
{
static char *function = "evtxtools_signal_attach";
if( signal_handler == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid signal handler.",
function );
return( -1 );
}
evtxtools_signal_signal_handler = signal_handler;
if( SetConsoleCtrlHandler(
evtxtools_signal_handler,
TRUE ) == 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_SET_FAILED,
"%s: unable to attach signal handler.",
function );
return( -1 );
}
if( SetConsoleCtrlHandler(
NULL,
FALSE ) == 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_SET_FAILED,
"%s: unable to attach break signal.",
function );
return( -1 );
}
#if defined( _MSC_VER )
evtxtools_signal_initialize_memory_debug();
#endif
SetErrorMode(
SEM_FAILCRITICALERRORS );
#if defined( LOCALE_SUPPORT )
/* Allow subsequent threads to have their own locale.
* If the application is single threaded this call has
* no practical effect.
*/
_configthreadlocale(
_ENABLE_PER_THREAD_LOCALE );
/* Set the current thread locale to the user default
* ANSI code page.
*/
setlocale(
LC_ALL,
"" );
/* Set the the code page used by multibyte functions
* to use the same code page as the previous call to setlocale.
*/
_setmbcp(
_MB_CP_LOCALE );
#endif /* defined( LOCALE_SUPPORT ) */
return( 1 );
}
示例12: main
int
main(
int argc,
char *argv[])
{
char msg[300];
DWORD dwWritten;
int chars;
/*
* Make sure children (cl.exe and link.exe) are kept quiet.
*/
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
/*
* Make sure the compiler and linker aren't effected by the outside world.
*/
SetEnvironmentVariable("CL", "");
SetEnvironmentVariable("LINK", "");
if (argc > 1 && *argv[1] == '-') {
switch (*(argv[1]+1)) {
case 'c':
if (argc != 3) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -c <compiler option>\n"
"Tests for whether cl.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
}
return CheckForCompilerFeature(argv[2]);
case 'l':
if (argc != 3) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -l <linker option>\n"
"Tests for whether link.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
}
return CheckForLinkerFeature(argv[2]);
case 'f':
if (argc == 2) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -f <string> <substring>\n"
"Find a substring within another\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
} else if (argc == 3) {
/*
* If the string is blank, there is no match.
*/
return 0;
} else {
return IsIn(argv[2], argv[3]);
}
case 'g':
if (argc == 2) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -g <file> <string>\n"
"grep for a #define\n"
"exitcodes: integer of the found string (no decimals)\n",
argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
}
return GrepForDefine(argv[2], argv[3]);
case 's':
if (argc == 2) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -s <substitutions file> <file>\n"
"Perform a set of string map type substutitions on a file\n"
"exitcodes: 0\n",
argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 2;
}
return SubstituteFile(argv[2], argv[3]);
case 'V':
if (argc != 4) {
chars = snprintf(msg, sizeof(msg) - 1,
"usage: %s -V filename matchstring\n"
"Extract a version from a file:\n"
"eg: pkgIndex.tcl \"package ifneeded http\"",
argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
&dwWritten, NULL);
return 0;
}
printf("%s\n", GetVersionFromFile(argv[2], argv[3]));
//.........这里部分代码省略.........
示例13: SetErrorMode
void CLocalTreeView::Refresh()
{
wxLogNull nullLog;
const wxString separator = wxFileName::GetPathSeparator();
std::list<t_dir> dirsToCheck;
#ifdef __WXMSW__
int prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
wxTreeItemIdValue tmp;
wxTreeItemId child = GetFirstChild(m_drives, tmp);
while (child)
{
if (IsExpanded(child))
{
wxString drive = GetItemText(child);
int pos = drive.Find(_T(" "));
if (pos != -1)
drive = drive.Left(pos);
t_dir dir;
dir.dir = drive + separator;
dir.item = child;
dirsToCheck.push_back(dir);
}
child = GetNextSibling(child);
}
#else
t_dir dir;
dir.dir = separator;
dir.item = GetRootItem();
dirsToCheck.push_back(dir);
#endif
CFilterManager filter;
while (!dirsToCheck.empty())
{
t_dir dir = dirsToCheck.front();
dirsToCheck.pop_front();
// Step 1: Check if directory exists
CLocalFileSystem local_filesystem;
if (!local_filesystem.BeginFindFiles(dir.dir, true))
{
// Dir does exist (listed in parent) but may not be accessible.
// Recurse into children anyhow, they might be accessible again.
wxTreeItemIdValue value;
wxTreeItemId child = GetFirstChild(dir.item, value);
while (child)
{
t_dir subdir;
subdir.dir = dir.dir + GetItemText(child) + separator;
subdir.item = child;
dirsToCheck.push_back(subdir);
child = GetNextSibling(child);
}
continue;
}
// Step 2: Enumerate subdirectories on disk and sort them
std::list<wxString> dirs;
wxString file;
const wxLongLong size(-1);
bool was_link;
bool is_dir;
int attributes;
wxDateTime date;
while (local_filesystem.GetNextFile(file, was_link, is_dir, 0, &date, &attributes))
{
if (file == _T(""))
{
wxGetApp().DisplayEncodingWarning();
continue;
}
if (filter.FilenameFiltered(file, dir.dir, true, size, true, attributes, date.IsValid() ? &date : 0))
continue;
dirs.push_back(file);
}
dirs.sort(sortfunc);
bool inserted = false;
// Step 3: Merge list of subdirectories with subtree.
wxTreeItemId child = GetLastChild(dir.item);
std::list<wxString>::reverse_iterator iter = dirs.rbegin();
while (child || iter != dirs.rend())
{
int cmp;
if (child && iter != dirs.rend())
#ifdef __WXMSW__
cmp = GetItemText(child).CmpNoCase(*iter);
#else
//.........这里部分代码省略.........
示例14: SetErrorMode
bool QLibraryPrivate::load_sys()
{
//avoid 'Bad Image' message box
UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
// We make the following attempts at locating the library:
//
// WinCE
// if (loadHints & QLibrary::ImprovedSearchHeuristics)
// if (absolute)
// fileName
// fileName + ".dll"
// else
// fileName + ".dll"
// fileName
// QFileInfo(fileName).absoluteFilePath()
// else
// QFileInfo(fileName).absoluteFilePath();
// fileName
// fileName + ".dll"
//
// Windows
// if (loadHints & QLibrary::ImprovedSearchHeuristics)
// if (absolute)
// fileName
// fileName + ".dll"
// else
// fileName + ".dll"
// fileName
// else
// fileName
// fileName + ".dll"
//
// NB If it's a plugin we do not ever try the ".dll" extension
QStringList attempts;
QFileSystemEntry fsEntry(fileName);
if (loadHints & QLibrary::ImprovedSearchHeuristics) {
if (pluginState != IsAPlugin)
attempts.append(fileName + QLatin1String(".dll"));
// If the fileName is an absolute path we try that first, otherwise we
// use the system-specific suffix first
if (fsEntry.isAbsolute()) {
attempts.prepend(fileName);
} else {
attempts.append(fileName);
#if defined(Q_OS_WINCE)
attempts.append(QFileInfo(fileName).absoluteFilePath());
#endif
}
} else {
#ifdef Q_OS_WINCE
attempts.append(QFileInfo(fileName).absoluteFilePath());
#else
attempts.append(fileName);
#endif
if (pluginState != IsAPlugin) {
#if defined(Q_OS_WINCE)
attempts.append(fileName);
#endif
attempts.append(fileName + QLatin1String(".dll"));
}
}
Q_FOREACH (const QString &attempt, attempts) {
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
// If we have a handle or the last error is something other than "unable
// to find the module", then bail out
if (pHnd || ::GetLastError() != ERROR_MOD_NOT_FOUND)
break;
}
示例15: ReplInit
DBGSTATIC NET_API_STATUS
ReplInit(
VOID
)
{
NET_API_STATUS NetStatus;
// init global variable ..
// this needs to be done because the service can be stopped and started;
// still the service .exe running and the global data live forever.
// BUGBUG: memory leak of old values?
ReplConfigExportList = NULL;
ReplConfigImportList = NULL;
ReplGlobalClientTerminateEvent = NULL;
ReplGlobalMasterTerminateEvent = NULL;
ReplGlobalExportStartupEvent = NULL;
ReplGlobalImportStartupEvent = NULL;
ReplGlobalClientThreadHandle = NULL;
ReplGlobalMasterThreadHandle = NULL;
ReplGlobalUninstallUicCode = 0;
ReplGlobalIsServiceStopping = FALSE;
ReplGlobalCheckpoint = 1;
// Init lock for config data.
ReplConfigLock = NetpCreateLock(
CONFIG_DATA_LOCK_LEVEL, (LPTSTR) TEXT("config data") );
NetpAssert( ReplConfigLock != NULL );
// Init client list lock (needed by import lock/unlock APIs even if
// import side not running). Ditto for master list lock.
RCGlobalClientListLock = NetpCreateLock(
CLIENT_LIST_LOCK_LEVEL,
(LPTSTR) TEXT("client list") );
NetpAssert( RCGlobalClientListLock != NULL );
RCGlobalDuplListLock = NetpCreateLock(
DUPL_LIST_LOCK_LEVEL,
(LPTSTR) TEXT("dupl list") );
NetpAssert( RCGlobalDuplListLock != NULL );
RMGlobalListLock = NetpCreateLock(
MASTER_LIST_LOCK_LEVEL,
(LPTSTR) TEXT("master list") );
NetpAssert( RMGlobalListLock != NULL); // BUGBUG: out of memory?
// Create startup events.
ReplGlobalExportStartupEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if( ReplGlobalExportStartupEvent == NULL) {
return (GetLastError());
}
ReplGlobalImportStartupEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if( ReplGlobalImportStartupEvent == NULL) {
return (GetLastError());
}
//
// Create termination events.
//
ReplGlobalClientTerminateEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if( ReplGlobalClientTerminateEvent == NULL) {
return (GetLastError());
}
ReplGlobalMasterTerminateEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (ReplGlobalMasterTerminateEvent == NULL) {
return (GetLastError());
}
//
// Disable the dreaded "net name deleted" popup (and all other hard
// error popups).
//
(VOID) SetErrorMode( SEM_FAILCRITICALERRORS );
//
// Get local domain name, computer name, etc.
//
//.........这里部分代码省略.........