您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wcsrchr函数代码示例

51自学网 2021-06-03 09:54:04
  C++
这篇教程C++ wcsrchr函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wcsrchr函数的典型用法代码示例。如果您正苦于以下问题:C++ wcsrchr函数的具体用法?C++ wcsrchr怎么用?C++ wcsrchr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wcsrchr函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Close

// ---BOOL CAvpFileFindW::FindFile(LPCWSTR pstrName /* = NULL */,	DWORD dwUnused /* = 0 */) {	Close();	m_pNextInfo = new WIN32_FIND_DATAW;	m_bGotLast = FALSE;	if (pstrName == NULL)		pstrName = L"*.*";/*	if ( (wcslen(pstrName) + 1) > _countof(((WIN32_FIND_DATAW*) m_pNextInfo)->cFileName) )		// Это ошибка, конечно. В этом случае мы все равно ничего не найдем. Но, наверное, нужно выполнять		// поиск с переходом в каталог		return FALSE;	wcscpy(((WIN32_FIND_DATAW*) m_pNextInfo)->cFileName, pstrName);*/#if defined(_UNICODE)	m_hContext = ::FindFirstFile(pstrName, (WIN32_FIND_DATAW*) m_pNextInfo);#else	if ( g_bUnicodePlatform )		m_hContext = ::FindFirstFileW(pstrName, (WIN32_FIND_DATAW*) m_pNextInfo);	else {		WIN32_FIND_DATAA rcContext;		//::WContext2AContext( (WIN32_FIND_DATAW*) m_pNextInfo, &rcContext );		CAPointer<char> pConverted = ::UnicodeToMbcs( pstrName );		m_hContext = ::FindFirstFileA( pConverted, &rcContext );		::AContext2WContext( &rcContext, (WIN32_FIND_DATAW*) m_pNextInfo );	}#endif	if (m_hContext == INVALID_HANDLE_VALUE)	{		DWORD dwTemp = ::GetLastError();		Close();		::SetLastError(dwTemp);		return FALSE;	}#if 0 // Dont use this technique - //?/ problem	LPWSTR pstrRoot = m_strRoot;	LPCWSTR pstr = NULL;#if defined(_UNICODE)	pstr = _tfullpath(pstrRoot, pstrName, _countof(m_strRoot));#else	if ( g_bUnicodePlatform )		pstr = _wfullpath(pstrRoot, pstrName, _countof(m_strRoot));	else {		CAPointer<char> pConverted = ::UnicodeToMbcs( pstrName );		CHAR strRoot[_MAX_PATH];		LPCSTR pAStr = _fullpath(strRoot, pConverted, _countof(strRoot));		if ( pAStr ) {			::MbcsToUnicode( strRoot, pstrRoot, _countof(m_strRoot) );			pstr = pstrRoot;		}	}#endif	// passed name isn't a valid path but was found by the API	if (pstr == NULL)	{		Close();		::SetLastError(ERROR_INVALID_NAME);		return FALSE;	}	else {		// find the last forward or backward whack		LPWSTR pstrBack  = wcsrchr(pstrRoot, L'//');		LPWSTR pstrFront = wcsrchr(pstrRoot, L'/');		if (pstrFront != NULL || pstrBack != NULL) {			if (pstrFront == NULL)				pstrFront = pstrRoot;			if (pstrBack == NULL)				pstrBack = pstrRoot;			// from the start to the last whack is the root			if (pstrFront >= pstrBack)				*pstrFront = L'/0';			else				*pstrBack = L'/0';		}	}#endif	return TRUE;}
开发者ID:hackshields,项目名称:antivirus,代码行数:84,


示例2: search_path_join_test

/* * Helper function for search_path */static wchar_t* search_path_join_test(const wchar_t* dir,                                      int dir_len,                                      const wchar_t* name,                                      int name_len,                                      const wchar_t* ext,                                      int ext_len,                                      const wchar_t* cwd,                                      int cwd_len) {  wchar_t *result, *result_pos;  DWORD attrs;  if (dir_len >= 1 && (dir[0] == L'/' || dir[0] == L'//')) {    /* It's a full path without drive letter, use cwd's drive letter only */    cwd_len = 2;  } else if (dir_len >= 2 && dir[1] == L':' &&      (dir_len < 3 || (dir[2] != L'/' && dir[2] != L'//'))) {    /* It's a relative path with drive letter (ext.g. D:../some/file)     * Replace drive letter in dir by full cwd if it points to the same drive,     * otherwise use the dir only.     */    if (cwd_len < 2 || _wcsnicmp(cwd, dir, 2) != 0) {      cwd_len = 0;    } else {      dir += 2;      dir_len -= 2;    }  } else if (dir_len > 2 && dir[1] == L':') {    /* It's an absolute path with drive letter     * Don't use the cwd at all     */    cwd_len = 0;  }  /* Allocate buffer for output */  result = result_pos =      (wchar_t*)malloc(sizeof(wchar_t) * (cwd_len + 1 + dir_len + 1 + name_len + 1 + ext_len + 1));  /* Copy cwd */  wcsncpy(result_pos, cwd, cwd_len);  result_pos += cwd_len;  /* Add a path separator if cwd didn't end with one */  if (cwd_len && wcsrchr(L"///:", result_pos[-1]) == NULL) {    result_pos[0] = L'//';    result_pos++;  }  /* Copy dir */  wcsncpy(result_pos, dir, dir_len);  result_pos += dir_len;  /* Add a separator if the dir didn't end with one */  if (dir_len && wcsrchr(L"///:", result_pos[-1]) == NULL) {    result_pos[0] = L'//';    result_pos++;  }  /* Copy filename */  wcsncpy(result_pos, name, name_len);  result_pos += name_len;  /* Copy extension */  if (ext_len) {    result_pos[0] = L'.';    result_pos++;    wcsncpy(result_pos, ext, ext_len);    result_pos += ext_len;  }  /* Null terminator */  result_pos[0] = L'/0';  attrs = GetFileAttributesW(result);  if (attrs != INVALID_FILE_ATTRIBUTES &&     !(attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT))) {    return result;  }  free(result);  return NULL;}
开发者ID:changloong,项目名称:gool,代码行数:85,


示例3: DllMain

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/){    // --CHANGED by Anton Likhtarov for resource support    rs::hInst = hInstance;    // --END	WSADATA			wData;	WORD			wVersion = MAKEWORD(1,1);    if (dwReason == DLL_PROCESS_ATTACH)    {	    if( WSAStartup(wVersion, &wData) )	    {		    return FALSE;	    }		hMlang = LoadLibrary(L"mlang.dll");		fConvertINetMultiByteToUnicode = (HRESULT (__stdcall *)(LPDWORD, DWORD, LPCSTR, LPINT, LPWSTR, LPINT))			GetProcAddress(hMlang, "ConvertINetMultiByteToUnicode");		HKEY hKeyDB, hKeyCP;		wchar_t cp_subkey[256], cp_fullpath[256];		if (RegOpenKeyEx(HKEY_CLASSES_ROOT, L"MIME//DataBase//Codepage", 0, KEY_READ, &hKeyDB) == ERROR_SUCCESS) {			DWORD n_cps;			RegQueryInfoKey(hKeyDB,NULL,NULL,NULL,&n_cps,NULL,NULL,NULL,NULL,NULL,NULL,NULL);      			for (int i = 0; i < n_cps; i++) {				DWORD dwSize = sizeof(cp_subkey);				RegEnumKeyEx(hKeyDB,i,cp_subkey,&dwSize,NULL,NULL,NULL,NULL);				UINT cp = _wtoi(cp_subkey);								swprintf(cp_fullpath, L"MIME//DataBase//Codepage//%ls", cp_subkey);				if (RegOpenKeyEx(HKEY_CLASSES_ROOT, cp_fullpath, 0, KEY_READ, &hKeyCP) != ERROR_SUCCESS)					continue;								wstring cp_name;				GetStringRegKey(hKeyCP, L"WebCharset", cp_name);				if (cp_name.length() == 0)					GetStringRegKey(hKeyCP, L"BodyCharset", cp_name);				if (cp_name.length() > 0 && cp_name[0] != L'_') {					transform(cp_name.begin(), cp_name.end(), cp_name.begin(), ::towlower);					CPNames[cp] = cp_name;					CPIDs[cp_name] = cp;				}			}			RegCloseKey(hKeyDB);		}		MudCodePage = GetACP();        InitializeCriticalSection(&secSubstSection);        InitializeCriticalSection(&secHotkeys);        InitializeCriticalSection(&secStatusSection);//vls-begin// #system        InitializeCriticalSection(&secSystemExec);        InitializeCriticalSection(&secSystemList);//vls-end////vls-begin// script files        InitializeCriticalSection(&secScriptFiles);        InitializeCriticalSection(&secReadingConfig);        eventReadingConfig = CreateEvent(NULL, TRUE, FALSE, NULL);        eventReadingHasUse = CreateEvent(NULL, TRUE, FALSE, NULL);        eventReadingFirst = CreateEvent(NULL, TRUE, FALSE, NULL);//vls-end//        eventAllObjectEvent = CreateEvent(NULL, FALSE, FALSE, NULL );        SetEvent(eventAllObjectEvent );        eventMudEmuTextArrives = CreateEvent(NULL, TRUE, FALSE, NULL );//vls-begin// base dir        GetModuleFileName(NULL, szBASE_DIR, MAX_PATH);        wchar_t *p = wcsrchr(szBASE_DIR, L'//');        if (p) *p = '/0';        wcscpy(szSETTINGS_DIR, szBASE_DIR);        wcscat(szSETTINGS_DIR, L"//settings");//vls-end//        _Module.Init(ObjectMap, hInstance, &LIBID_TTCOREEXLib);        DisableThreadLibraryCalls(hInstance);		hPingThread = CreateThread(NULL, 0, &PingThread, NULL, 0, &dwPingThreadID);		strLastCommand[0] = L'/0';		last_line[0] = L'/0';    }    else if (dwReason == DLL_PROCESS_DETACH){//vls-begin// multiple output        StopLogging();//vls-end////vls-begin// bugfix        CloseHandle(eventMudEmuTextArrives);//vls-end////vls-begin// script files        CloseHandle(eventReadingFirst);        CloseHandle(eventReadingHasUse);        CloseHandle(eventReadingConfig);//.........这里部分代码省略.........
开发者ID:konelav,项目名称:jmc,代码行数:101,


示例4: FindMediaFileCch

//--------------------------------------------------------------------------------------// Helper function to try to find the location of a media file//--------------------------------------------------------------------------------------HRESULT FindMediaFileCch( WCHAR* strDestPath, int cchDest, LPCWSTR strFilename ){    bool bFound = false;    if( NULL == strFilename || strFilename[0] == 0 || NULL == strDestPath || cchDest < 10 )        return E_INVALIDARG;    // Get the exe name, and exe path    WCHAR strExePath[MAX_PATH] = {0};    WCHAR strExeName[MAX_PATH] = {0};    WCHAR* strLastSlash = NULL;    GetModuleFileName( NULL, strExePath, MAX_PATH );    strExePath[MAX_PATH - 1] = 0;    strLastSlash = wcsrchr( strExePath, TEXT( '//' ) );    if( strLastSlash )    {        StringCchCopy( strExeName, MAX_PATH, &strLastSlash[1] );        // Chop the exe name from the exe path        *strLastSlash = 0;        // Chop the .exe from the exe name        strLastSlash = wcsrchr( strExeName, TEXT( '.' ) );        if( strLastSlash )            *strLastSlash = 0;    }    StringCchCopy( strDestPath, cchDest, strFilename );    if( GetFileAttributes( strDestPath ) != 0xFFFFFFFF )        return S_OK;    // Search all parent directories starting at ./ and using strFilename as the leaf name    WCHAR strLeafName[MAX_PATH] = {0};    StringCchCopy( strLeafName, MAX_PATH, strFilename );    WCHAR strFullPath[MAX_PATH] = {0};    WCHAR strFullFileName[MAX_PATH] = {0};    WCHAR strSearch[MAX_PATH] = {0};    WCHAR* strFilePart = NULL;    GetFullPathName( L".", MAX_PATH, strFullPath, &strFilePart );    if( strFilePart == NULL )        return E_FAIL;    while( strFilePart != NULL && *strFilePart != '/0' )    {        StringCchPrintf( strFullFileName, MAX_PATH, L"%s//%s", strFullPath, strLeafName );        if( GetFileAttributes( strFullFileName ) != 0xFFFFFFFF )        {            StringCchCopy( strDestPath, cchDest, strFullFileName );            bFound = true;            break;        }        StringCchPrintf( strFullFileName, MAX_PATH, L"%s//%s//%s", strFullPath, strExeName, strLeafName );        if( GetFileAttributes( strFullFileName ) != 0xFFFFFFFF )        {            StringCchCopy( strDestPath, cchDest, strFullFileName );            bFound = true;            break;        }        StringCchPrintf( strSearch, MAX_PATH, L"%s//..", strFullPath );        GetFullPathName( strSearch, MAX_PATH, strFullPath, &strFilePart );    }    if( bFound )        return S_OK;    // On failure, return the file as the path but also return an error code    StringCchCopy( strDestPath, cchDest, strFilename );    return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );}
开发者ID:KNeal,项目名称:Oculus,代码行数:76,


示例5: Report

// Resolve - Creates a nicely formatted rendition of the CallStack, including//   symbolic information (function names and line numbers) if available. and //   saves it for later retrieval. This is almost identical to Callstack::dump above.////   Note: The symbol handler must be initialized prior to calling this//     function.////  - showInternalFrames (IN): If true, then all frames in the CallStack will be//      dumped. Otherwise, frames internal to the heap will not be dumped.////  Return Value:////    None.//void CallStack::resolve(BOOL showInternalFrames){    if (m_resolved)    {        // already resolved, no need to do it again        // resolving twice may report an incorrect module for the stack frames        // if the memory was leaked in a dynamic library that was already unloaded.        return;    }    if (m_status & CALLSTACK_STATUS_INCOMPLETE) {        // This call stack appears to be incomplete. Using StackWalk64 may be        // more reliable.        Report(L"    HINT: The following call stack may be incomplete. Setting /"StackWalkMethod/"/n"            L"      in the vld.ini file to /"safe/" instead of /"fast/" may result in a more/n"            L"      complete stack trace./n");    }    IMAGEHLP_LINE64  sourceInfo = { 0 };    sourceInfo.SizeOfStruct = sizeof(IMAGEHLP_LINE64);    BYTE symbolBuffer [sizeof(SYMBOL_INFO) + MAX_SYMBOL_NAME_SIZE] = { 0 };        WCHAR callingModuleName [MAX_PATH] = L"";    WCHAR lowerCaseName [MAX_PATH];    const size_t max_line_length = MAXREPORTLENGTH + 1;    m_resolvedCapacity = m_size * max_line_length;    m_resolved = new WCHAR[m_resolvedCapacity];    const size_t allocedBytes = m_resolvedCapacity * sizeof(WCHAR);    ZeroMemory(m_resolved, allocedBytes);        // Iterate through each frame in the call stack.    for (UINT32 frame = 0; frame < m_size; frame++)    {        // Try to get the source file and line number associated with        // this program counter address.        SIZE_T programCounter = (*this)[frame];        g_symbolLock.Enter();        BOOL             foundline = FALSE;        DWORD            displacement = 0;        // It turns out that calls to SymGetLineFromAddrW64 may free the very memory we are scrutinizing here        // in this method. If this is the case, m_Resolved will be null after SymGetLineFromAddrW64 returns.         // When that happens there is nothing we can do except crash.        DbgTrace(L"dbghelp32.dll %i: SymGetLineFromAddrW64/n", GetCurrentThreadId());        foundline = SymGetLineFromAddrW64(g_currentProcess, programCounter, &displacement, &sourceInfo);        assert(m_resolved != NULL);        if (foundline && !showInternalFrames) {            wcscpy_s(lowerCaseName, sourceInfo.FileName);            _wcslwr_s(lowerCaseName, wcslen(lowerCaseName) + 1);            if (isInternalModule(lowerCaseName)) {                // Don't show frames in files internal to the heap.                g_symbolLock.Leave();                continue;            }        }        // Initialize structures passed to the symbol handler.        SYMBOL_INFO* functionInfo = (SYMBOL_INFO*)&symbolBuffer;        functionInfo->SizeOfStruct = sizeof(SYMBOL_INFO);        functionInfo->MaxNameLen = MAX_SYMBOL_NAME_LENGTH;        // Try to get the name of the function containing this program        // counter address.        DWORD64          displacement64 = 0;        LPWSTR           functionName;        DbgTrace(L"dbghelp32.dll %i: SymFromAddrW/n", GetCurrentThreadId());        if (SymFromAddrW(g_currentProcess, programCounter, &displacement64, functionInfo)) {            functionName = functionInfo->Name;        }        else {            // GetFormattedMessage( GetLastError() );            functionName = L"(Function name unavailable)";            displacement64 = 0;        }        g_symbolLock.Leave();        HMODULE hCallingModule = GetCallingModule(programCounter);        LPWSTR moduleName = L"(Module name unavailable)";        if (hCallingModule &&             GetModuleFileName(hCallingModule, callingModuleName, _countof(callingModuleName)) > 0)        {            moduleName = wcsrchr(callingModuleName, L'//');            if (moduleName == NULL)                moduleName = wcsrchr(callingModuleName, L'/');//.........这里部分代码省略.........
开发者ID:CocacolaSh,项目名称:SpellEditor,代码行数:101,


示例6: CodeSet_Init

//.........这里部分代码省略.........         }      }      if (!DynBuf_Append(&dbpath, ICU_DATA_FILE, strlen(ICU_DATA_FILE)) ||          !DynBuf_Append(&dbpath, "/0", 1)) {         goto exit;      }      /*       * Check for file existence.       */      attribs = GetFileAttributesA(DynBuf_Get(&dbpath));      if ((INVALID_FILE_ATTRIBUTES == attribs) ||          (attribs & FILE_ATTRIBUTE_DIRECTORY)) {         goto exit;      }      path = (char *) DynBuf_Detach(&dbpath);   } else {      /*       * Data file must be in the directory of the current module       * (i.e. the module that contains CodeSet_Init()).       */      HMODULE hModule = W32Util_GetModuleByAddress((void *) CodeSet_Init);      if (!hModule) {         goto exit;      }      modPath = CodeSetGetModulePath(hModule);      if (!modPath) {         goto exit;      }      lastSlash = wcsrchr(modPath, DIRSEPC_W);      if (!lastSlash) {         goto exit;      }      *lastSlash = L'/0';      if (!DynBuf_Append(&dbpath, modPath,                         wcslen(modPath) * sizeof(utf16_t)) ||          !DynBuf_Append(&dbpath, DIRSEPS_W,                         wcslen(DIRSEPS_W) * sizeof(utf16_t)) ||          !DynBuf_Append(&dbpath, ICU_DATA_FILE_W,                         wcslen(ICU_DATA_FILE_W) * sizeof(utf16_t)) ||          !DynBuf_Append(&dbpath, L"/0", 2)) {         goto exit;      }      /*       * Since u_setDataDirectory can't handle UTF-16, we would have to       * now convert this path to local encoding. But that fails when       * the module is in a path containing characters not in the       * local encoding (see 282524). So we'll memory-map the file       * instead and call udata_setCommonData() below.       */      wpath = (utf16_t *) DynBuf_Get(&dbpath);      hFile = CreateFileW(wpath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0,                          NULL);      if (INVALID_HANDLE_VALUE == hFile) {         goto exit;      }      hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);      if (NULL == hMapping) {         goto exit;
开发者ID:nolange,项目名称:pkg-open-vm-tools,代码行数:67,


示例7: os_wsplitpath

/*--------------------------------------------------------------------------*/char *getScilabDirectory(BOOL UnixStyle){    char *SciPathName = NULL;    wchar_t* wcSciPathName = NULL;    wchar_t ScilabModuleName[MAX_PATH + 1];    wchar_t drive[_MAX_DRIVE];    wchar_t dir[_MAX_DIR];    wchar_t fname[_MAX_FNAME];    wchar_t ext[_MAX_EXT];    wchar_t *DirTmp = NULL;    if (!GetModuleFileNameW ((HINSTANCE)GetModuleHandleW(L"core"), (wchar_t*) ScilabModuleName, MAX_PATH))    {        return NULL;    }    os_wsplitpath(ScilabModuleName, drive, dir, fname, ext);    if (dir[wcslen(dir) - 1] == L'//')    {        dir[wcslen(dir) - 1] = L'/0';    }    DirTmp = wcsrchr (dir, L'//');    if (wcslen(dir) - wcslen(DirTmp) > 0)    {        dir[wcslen(dir) - wcslen(DirTmp)] = L'/0';    }    else    {        return NULL;    }    wcSciPathName = (wchar_t*)MALLOC((int)( wcslen(drive) + wcslen(dir) + 5) * sizeof(wchar_t));    if (wcSciPathName)    {        _wmakepath(wcSciPathName, drive, dir, NULL, NULL);        if ( UnixStyle )        {            int i = 0;            for (i = 0; i < (int)wcslen(wcSciPathName); i++)            {                if (wcSciPathName[i] == L'//')                {                    wcSciPathName[i] = L'/';                }            }        }        wcSciPathName[wcslen(wcSciPathName) - 1] = '/0';        SciPathName = wide_string_to_UTF8(wcSciPathName);        FREE(wcSciPathName);        wcSciPathName = NULL;    }    if (SciPathName)    {        setSCI(SciPathName);    }    return SciPathName;}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:65,


示例8: m_skv

CNamedHKey::CNamedHKey(    BSTR          bstrRegFullKeyValueName,    SPLITKEYVALUE skv /* =KEYANDVALUE */)    : m_skv(skv){    m_hk = m_hkNonRemote = NULL;    m_bstrRegFullKeyValueName = bstrRegFullKeyValueName;    m_ptszComputername = m_ptszKeyname = m_ptszValuename = NULL;    m_lErr = ERROR_SUCCESS;    if (bstrRegFullKeyValueName == NULL)    {        _Cleanup(ERROR_INVALID_DATA);        return;    }    // check for leading "//computername/"    if (bstrRegFullKeyValueName[0] == L'//'        &&  bstrRegFullKeyValueName[1] == L'//')    {        BSTR bstrHKey = wcschr(bstrRegFullKeyValueName + 2, L'//');        // no '/' terminating computername or zero-length computername?        if (bstrHKey == NULL  ||  bstrHKey == bstrRegFullKeyValueName + 2)        {            _Cleanup(ERROR_INVALID_DATA);            return;        }        m_ptszComputername = TcsNDup(bstrRegFullKeyValueName,                                     bstrHKey - bstrRegFullKeyValueName);        if (m_ptszComputername == NULL)        {            _Cleanup(ERROR_OUTOFMEMORY);            return;        }        bstrRegFullKeyValueName = bstrHKey + 1;    }    // Parse out the leading HKEY_xxx    if ((m_hkNonRemote = _ParseHKeyRoot(bstrRegFullKeyValueName)) == NULL)    {        _Cleanup(ERROR_INVALID_HANDLE);        return;    }    if (m_skv == KEYONLY)    {        // do not split into Key/Value pair        m_ptszKeyname = TcsNDup(bstrRegFullKeyValueName);        m_ptszValuename = NULL;    }    else if (m_skv == KEYANDVALUE)    {        // Look for last '/' to split off Valuename        BSTR bstrValue = wcsrchr(bstrRegFullKeyValueName, L'//');                // Have name of form "HKLM/foo"; i.e., only one component?        if (bstrValue == NULL)        {            m_ptszKeyname = TcsNDup(OLESTR(""));            m_ptszValuename = TcsNDup(bstrRegFullKeyValueName);        }        else        {            m_ptszKeyname = TcsNDup(bstrRegFullKeyValueName,                                    bstrValue - bstrRegFullKeyValueName);            m_ptszValuename = TcsNDup(bstrValue + 1);        }        if (m_ptszValuename == NULL)        {            _Cleanup(ERROR_OUTOFMEMORY);            return;        }    }    else    {        _Cleanup(ERROR_INVALID_DATA);        return;    }        if (m_ptszKeyname == NULL)    {        _Cleanup(ERROR_OUTOFMEMORY);        return;    }    // Open the key on a remote registry?    if (m_ptszComputername == NULL)    {        m_hk = m_hkNonRemote;        m_hkNonRemote = NULL;    }    else    {        m_lErr = ::RegConnectRegistry(m_ptszComputername,                                      m_hkNonRemote, &m_hk);                if (m_lErr != ERROR_SUCCESS)//.........这里部分代码省略.........
开发者ID:georgevreilly,项目名称:sample-ASP-components,代码行数:101,


示例9: DeleteEmptyDirectory

static HRESULT DeleteEmptyDirectory(    __in LEGACY_FILE_TYPE fileType,    __in_z LPCWSTR wzPath    ){    HRESULT hr = S_OK;    LPWSTR sczParentDirectory = NULL;    DWORD dwIndex = 0;    LPWSTR pwcLastBackslash = NULL;    // If it's an individual file and it exists, no point trying to delete any directories for it    if (LEGACY_FILE_PLAIN == fileType)    {        if (FileExistsEx(wzPath, NULL))        {            ExitFunction1(hr = S_OK);        }    }    else    {        // It's a directory, so delete children first        hr = DeleteEmptyDirectoryChildren(wzPath);        // This code is just an FYI that the directory was not empty and so wasn't deleted. It's not an error, so ignore it.        if (FAILED(hr))        {            ExitFunction1(hr = S_OK);        }        ExitOnFailure(hr, "Failed to check for empty directories and delete them at path: %ls", wzPath);    }    hr = StrAllocString(&sczParentDirectory, wzPath, 0);    ExitOnFailure(hr, "Failed to allocate copy of directory");    // Eliminate any trailing backslashes from the directory first, if there are any    dwIndex = lstrlenW(sczParentDirectory);    if (0 == dwIndex)    {        hr = E_INVALIDARG;        ExitOnFailure(hr, "Unexpected empty parent directory encountered while deleting empty directories");    }    --dwIndex; // Start at the last character of the string    while (dwIndex > 0 && sczParentDirectory[dwIndex] == L'//')    {        sczParentDirectory[dwIndex] = L'/0';        --dwIndex;    }    if (0 == dwIndex)    {        hr = E_INVALIDARG;        ExitOnFailure(hr, "Parent directory was entirely composed of backslashes!");    }    // Now delete any empty parent directories we see as well    while (NULL != (pwcLastBackslash = wcsrchr(sczParentDirectory, L'//')))    {        hr = DirEnsureDelete(sczParentDirectory, FALSE, FALSE);        if (FAILED(hr))        {            LogErrorString(hr, "Failed to check for empty parent directories and delete them at directory: %ls", sczParentDirectory);            hr = S_OK;            break;        }        *pwcLastBackslash = L'/0';    }LExit:    ReleaseStr(sczParentDirectory);    return hr;}
开发者ID:firegiant,项目名称:wix4,代码行数:74,


示例10: wcsncpy_s

HRESULT ConfigParser::SetOutputFile(const WCHAR* outputFile, const WCHAR* openMode){    // If present, replace the {PID} token with the process ID    const WCHAR* pidStr = nullptr;    WCHAR buffer[_MAX_PATH];    if ((pidStr = wcsstr(outputFile, L"{PID}")) != nullptr)    {        size_t pidStartPosition = pidStr - outputFile;        WCHAR* pDest = buffer;        size_t bufferLen = _MAX_PATH;        // Copy the filename before the {PID} token        wcsncpy_s(pDest, bufferLen, outputFile, pidStartPosition);        pDest += pidStartPosition;        bufferLen = bufferLen - pidStartPosition;        // Copy the PID        _ultow_s(GetCurrentProcessId(), pDest, /*bufferSize=*/_MAX_PATH - pidStartPosition, /*radix=*/10);#pragma prefast(suppress: 26014, "ultow string length is smaller than 256")        pDest += wcslen(pDest);        bufferLen = bufferLen - wcslen(pDest);        // Copy the rest of the string.#pragma prefast(suppress: 26014, "Overwriting pDset's null terminator is intentional since the string being copied is null terminated")        wcscpy_s(pDest, bufferLen, outputFile + pidStartPosition + /*length of {PID}*/ 5);        outputFile = buffer;    }    wchar_t fileName[_MAX_PATH];    wchar_t moduleName[_MAX_PATH];    GetModuleFileName(0, moduleName, _MAX_PATH);    _wsplitpath_s(moduleName, nullptr, 0, nullptr, 0, fileName, _MAX_PATH, nullptr, 0);    if (_wcsicmp(fileName, L"WWAHost") == 0 || _wcsicmp(fileName, L"ByteCodeGenerator") == 0 ||        _wcsicmp(fileName, L"spartan") == 0 || _wcsicmp(fileName, L"spartan_edge") == 0 ||        _wcsicmp(fileName, L"MicrosoftEdge") == 0 || _wcsicmp(fileName, L"MicrosoftEdgeCP") == 0)    {        // we need to output to %temp% directory in wwa. we don't have permission otherwise.        if (GetEnvironmentVariable(L"temp", fileName, _MAX_PATH) != 0)        {            wcscat_s(fileName, _MAX_PATH, L"//");            const wchar_t * fileNameOnly = wcsrchr(outputFile, L'//');            // if outputFile is full path we just need filename, discard the path            wcscat_s(fileName, _MAX_PATH, fileNameOnly == nullptr ? outputFile : fileNameOnly);        }        else        {            AssertMsg(FALSE, "Get temp environment failed");        }        outputFile = fileName;    }    FILE *fp;    if ((fp = _wfsopen(outputFile, openMode, _SH_DENYWR)) != nullptr)    {        Output::SetOutputFile(fp);        return S_OK;    }    AssertMsg(false, "Could not open file for logging output.");    return E_FAIL;}
开发者ID:Cellule,项目名称:ChakraCore,代码行数:64,


示例11: DeleteEmptyRegistryKeys

static HRESULT DeleteEmptyRegistryKeys(    __in LEGACY_SYNC_PRODUCT_SESSION *pSyncProductSession    ){    HRESULT hr = S_OK;    const LEGACY_REGISTRY_KEY *rgRegKeys = pSyncProductSession->product.rgRegKeys;    const DWORD cRegKeys = pSyncProductSession->product.cRegKeys;    DWORD dwIndex = 0;    LPWSTR pwcLastBackslash = NULL;    LPWSTR sczParentKey = NULL;    for (DWORD i = 0; i < cRegKeys; ++i)    {        hr = DeleteEmptyRegistryKeyChildren(rgRegKeys[i].dwRoot, rgRegKeys[i].sczKey);        // This code is just an FYI that the key was not empty and so wasn't deleted. It's not an error, so ignore it.        if (HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY) == hr)        {            hr = S_OK;            continue;        }        ExitOnFailure(hr, "Failed to check for empty keys and delete them at root: %u, subkey: %ls", rgRegKeys[i].dwRoot, rgRegKeys[i].sczKey);        hr = StrAllocString(&sczParentKey, rgRegKeys[i].sczKey, 0);        ExitOnFailure(hr, "Failed to allocate copy of subkey");        // Eliminate any trailing backslashes from the key first, if there are any        dwIndex = lstrlenW(sczParentKey);        if (0 == dwIndex)        {            hr = E_INVALIDARG;            ExitOnFailure(hr, "Unexpected empty parent key encountered while deleting empty registry keys");        }        --dwIndex; // Start at the last character of the string        while (dwIndex > 0 && sczParentKey[dwIndex] == L'//')        {            sczParentKey[dwIndex] = L'/0';            --dwIndex;        }        if (0 == dwIndex)        {            hr = E_INVALIDARG;            ExitOnFailure(hr, "Parent key was entirely composed of backslashes!");        }        // Now delete any empty parent keys we see as well        while (NULL != (pwcLastBackslash = wcsrchr(sczParentKey, L'//')))        {            hr = RegDelete(ManifestConvertToRootKey(rgRegKeys[i].dwRoot), sczParentKey, REG_KEY_DEFAULT, FALSE);            // This code is just an FYI that the key was not empty and so wasn't deleted. It's not an error, so ignore it.            if (FAILED(hr))            {                LogErrorString(hr, "Failed to check for empty parent keys and delete them at root: %u, subkey: %ls", rgRegKeys[i].dwRoot, sczParentKey);                hr = S_OK;                break;            }            *pwcLastBackslash = L'/0';        }    }LExit:    ReleaseStr(sczParentKey);    return hr;}
开发者ID:firegiant,项目名称:wix4,代码行数:67,


示例12: OpenRegistryHandlesFromSymbolicLink

//.........这里部分代码省略.........                               &GuidString,                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,                               ClassesKey,                               NULL);    Status = ZwOpenKey(GuidKeyRealP,                       DesiredAccess | KEY_ENUMERATE_SUB_KEYS,                       &ObjectAttributes);    ZwClose(ClassesKey);    if (!NT_SUCCESS(Status))    {        DPRINT1("Failed to open %wZ%wZ (%x)/n", &BaseKeyU, &GuidString, Status);        goto cleanup;    }    SubKeyName.MaximumLength = SymbolicLinkName->Length + sizeof(WCHAR);    SubKeyName.Length = 0;    SubKeyName.Buffer = ExAllocatePool(PagedPool, SubKeyName.MaximumLength);    if (!SubKeyName.Buffer)    {        Status = STATUS_INSUFFICIENT_RESOURCES;        goto cleanup;    }    RtlAppendUnicodeStringToString(&SubKeyName,                                   SymbolicLinkName);    SubKeyName.Buffer[SubKeyName.Length / sizeof(WCHAR)] = UNICODE_NULL;    SubKeyName.Buffer[0] = L'#';    SubKeyName.Buffer[1] = L'#';    SubKeyName.Buffer[2] = L'?';    SubKeyName.Buffer[3] = L'#';    ReferenceString.Buffer = wcsrchr(SubKeyName.Buffer, '//');    if (ReferenceString.Buffer != NULL)    {        ReferenceString.Buffer[0] = L'#';        SubKeyName.Length = (USHORT)((ULONG_PTR)(ReferenceString.Buffer) - (ULONG_PTR)SubKeyName.Buffer);        ReferenceString.Length = SymbolicLinkName->Length - SubKeyName.Length;    }    else    {        RtlInitUnicodeString(&ReferenceString, L"#");    }    InitializeObjectAttributes(&ObjectAttributes,                               &SubKeyName,                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,                               *GuidKeyRealP,                               NULL);    Status = ZwOpenKey(DeviceKeyRealP,                       DesiredAccess | KEY_ENUMERATE_SUB_KEYS,                       &ObjectAttributes);    if (!NT_SUCCESS(Status))    {        DPRINT1("Failed to open %wZ%wZ//%wZ/n", &BaseKeyU, &GuidString, &SubKeyName);        goto cleanup;    }    InitializeObjectAttributes(&ObjectAttributes,                               &ReferenceString,                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,                               *DeviceKeyRealP,                               NULL);    Status = ZwOpenKey(InstanceKeyRealP,
开发者ID:killvxk,项目名称:NT_OS,代码行数:67,


示例13: wcscpy_s

DXResourceHandle CDXShaderManager::CreateResource(void* pShaderDesc, WCHAR* szCustomKey){    DXResourceKey key;    DXResourceMapInsertResult insertResult;    DXResourceHandle returnValue;    DXShaderDesc* pDesc;    CDXShader* pShader;    pDesc = (DXShaderDesc*)pShaderDesc;    pShader = nullptr;    // Custom key given? Well and good. But it's better not to provide a    // custom key for shaders.    if (szCustomKey)    {        wcscpy_s(key.m_szName, DX_MAX_RESOURCE_KEY_NAME, szCustomKey);    }    else // No? Process a key name of format %FILE%_%ENTRY%_%PROFILE%    {        WCHAR szFileName[DX_MAX_FILE_NAME];        WCHAR* pFileName;        WCHAR* pDot;        // Find the last slash.        pFileName = wcsrchr(pDesc->szFileName, '//');        // If not found, then only the file name is present.        if (!pFileName)        {            pFileName = pDesc->szFileName;        }        // Copy the file name to a local variable.        wcscpy_s(szFileName, DX_MAX_FILE_NAME, pFileName);        // Find the extension full stop.        pDot = wcsrchr(szFileName, '.');        // We don't need the file extension.        if (pDot)        {            *pDot = 0;        }        // Format our key name: %FILE%_%ENTRY%_%PROFILE%        // So keep file and function names small.        wsprintf(key.m_szName, L"%s_%s_%s", szFileName, pDesc->szEntryPoint, pDesc->szShaderLevel);    }    // Try to insert the shader with the key into the map.    insertResult = InsertResource(key, pShader);    if (insertResult.second) // New resource inserted?    {        HRESULT hr = S_OK;        // New shader resource on the heap.        pShader = new CDXShader();        // Create the resource. NOTE: This does not create the resource        // in the graphics memory. It only prepares the resource so that it        // can be created anytime using Recreate() method.        DX_V(pShader->Create(pShaderDesc));        if (FAILED(hr)) // Failed?        {            DX_DEBUG_OUTPUT2(L"Failed on a shader: FILE:%s, ENTRY: %s.", pDesc->szFileName, pDesc->szEntryPoint);            // Free the memory.            DX_SAFE_DELETE(pShader);            return returnValue;        }        // Success!        insertResult.first->second = pShader;        AddMemoryUsage(pShader->GetSize());    }    else // Existing element returned.    {        pShader = (CDXShader*)insertResult.first->second;    }    pShader->AddRef();    returnValue.key = key;    returnValue.pResource = pShader;    return returnValue;}
开发者ID:ab316,项目名称:TrumpSuit,代码行数:80,


示例14: CheckThreads

BOOLCheckThreads (    __in DWORD ProcId    )/*++Routine Description:    Enumerates all threads (or optionally only threads for one    process) in the system.  It the calls the WCT API on each of them.Arguments:    ProcId--Specifies the process ID to analyze.  If '0' all processes        in the system will be checked.Return Value:    TRUE if processes could be checked; FALSE if a general failure    occurred.--*/{    DWORD processes[1024];    DWORD numProcesses;    DWORD i;    // Try to enable the SE_DEBUG_NAME privilege for this process.  We    // continue even if this fails--we just won't be able to retrieve    // wait chains for processes not owned by the current user.    if (!GrantDebugPrivilege())    {        printf("Couldn't enable debug privilege");    }    // Get a list of all processes currently running.    if (EnumProcesses(processes, sizeof(processes), &numProcesses) == FALSE)    {        printf("Couldn't enumerate processes");        return FALSE;    }    for (i = 0; i < numProcesses / sizeof(DWORD); i++)    {        HANDLE process;        HANDLE snapshot;        if (processes[i] == GetCurrentProcessId())        {            continue;        }        // If the caller specified a Process ID, check if we have a match.        if (ProcId != 0)        {            if (processes[i] != ProcId)            {                continue;            }        }        // Get a handle to this process.        process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processes[i]);        if (process)        {            WCHAR file[MAX_PATH];            printf("Process 0x%x - ", processes[i]);            // Retrieve the EXE's name and print it.            if (GetProcessImageFileName(process, file, ARRAYSIZE(file)) > 0)            {                PCWSTR filePart = wcsrchr(file, L'//');                if (filePart)                {                    filePart++;                }                else                {                    filePart = file;                }                printf("%S", filePart);            }            printf("/n----------------------------------/n");            // Get a snapshot of this process.  This allows us to            // enumerate its threads.            snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,                                                processes[i]);            if (snapshot)            {                THREADENTRY32 thread;                thread.dwSize = sizeof(thread);                // Walk the thread list and print the wait chain                // for each.                if (Thread32First(snapshot, &thread))                {//.........这里部分代码省略.........
开发者ID:FrankAlbis,项目名称:Win7_SDK_Samples,代码行数:101,


示例15: InitDbgHelp

static bool InitDbgHelp(){	static bool doinit = true;	static bool ret = false;	if(!doinit)		return ret;	doinit = false;	HMODULE module = NULL;		// can't reliably co-exist with dbghelp already being used in the process	if(GetModuleHandleA("dbghelp.dll") != NULL)	{		ret = false;		return false;	}	else	{		wchar_t path[MAX_PATH] = {0};		GetModuleFileNameW(GetModuleHandleA("renderdoc.dll"), path, MAX_PATH-1);		wchar_t *slash = wcsrchr(path, '//');		if(slash)		{			*slash = 0;		}		else		{			slash = wcsrchr(path, '/');			if(slash == 0)			{				ret = false;				return false;			}			*slash = 0;		}#if defined(WIN64)		wcscat_s(path, L"/pdblocate/x64/dbghelp.dll");#else		wcscat_s(path, L"/pdblocate/x86/dbghelp.dll");#endif		module = LoadLibraryW(path);	}	if(!module)	{		RDCWARN("Couldn't open dbghelp.dll");		ret = false;		return false;	}	dynSymInitializeW = (PSYMINITIALIZEW)GetProcAddress(module, "SymInitializeW");	dynSymEnumerateModules64W = (PSYMENUMERATEMODULES64W)GetProcAddress(module, "SymEnumerateModulesW64");	dynSymGetModuleInfo64W = (PSYMGETMODULEINFO64W)GetProcAddress(module, "SymGetModuleInfoW64");		if(!dynSymInitializeW ||		!dynSymEnumerateModules64W ||		!dynSymGetModuleInfo64W)	{		RDCERR("Couldn't get some dbghelp function");		ret = false;		return ret;	}	dynSymInitializeW(GetCurrentProcess(), L".", TRUE);		HMODULE hModule = NULL;	GetModuleHandleEx(		GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,		(LPCTSTR)&dllLocator,		&hModule);	if(hModule != NULL)	{		MODULEINFO modinfo = { 0 };		BOOL result = GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(modinfo));		if(result != FALSE)		{			renderdocBase = modinfo.lpBaseOfDll;			renderdocSize = modinfo.SizeOfImage;		}	}		 	ret = true;	return ret;}
开发者ID:RangerWu,项目名称:renderdoc,代码行数:95,


示例16: Log_Rotate

NTSTATUS Log_Rotate(){	NTSTATUS Status = STATUS_SUCCESS;	HANDLE hFile = NULL;	OBJECT_ATTRIBUTES fAttrs;	UNICODE_STRING FileName;	IO_STATUS_BLOCK StatusBlock = { 0 };	ULONG RotateIndex = 0;	FILE_RENAME_INFORMATION *RenameBuffer = NULL;	LPCWSTR BaseFileName = LogFileName;	ULONG BaseFileNameLength = 0;	if (!LogFileName || !LogFile)		return STATUS_INVALID_DEVICE_STATE;	LPWSTR End1 = wcsrchr(LogFileName, L'//'), End2 = wcsrchr(LogFileName, L'/');	if ((SIZE_T)End1 > (SIZE_T)End2 > 0)		BaseFileName = End1 ? End1 + 1 : LogFileName;	else		BaseFileName = End2 ? End2 + 1 : LogFileName;	BaseFileNameLength = (ULONG)(wcslen(BaseFileName) + 4) * sizeof(WCHAR);	ULONG FileNameLength = (ULONG)(wcslen(LogFileName) + 5) * sizeof(WCHAR);	RenameBuffer = ExAllocatePoolWithTag(PagedPool, FileNameLength + FIELD_OFFSET(FILE_RENAME_INFORMATION, FileName),		LogAllocationTag);	if (!RenameBuffer) {		Status = STATUS_INSUFFICIENT_RESOURCES;		goto Cleanup;	}	RenameBuffer->FileNameLength = BaseFileNameLength;	RenameBuffer->ReplaceIfExists = FALSE;	RenameBuffer->RootDirectory = NULL;	// Rename already rotated files first	Status = StringCbPrintf(RenameBuffer->FileName, FileNameLength, L"%ws.%03d", LogFileName, LogSettings.MaxKeptRotatedFiles);	if (!SUCCEEDED(Status))		goto Cleanup;	RtlInitUnicodeString(&FileName, RenameBuffer->FileName);	InitializeObjectAttributes(&fAttrs, &FileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);	ZwDeleteFile(&fAttrs);	for (RotateIndex = LogSettings.MaxKeptRotatedFiles - 1; RotateIndex > 0; RotateIndex--)	{		Status = StringCbPrintf(RenameBuffer->FileName, FileNameLength, L"%ws.%03d", LogFileName, RotateIndex);		if (!SUCCEEDED(Status))			goto Cleanup;		RtlInitUnicodeString(&FileName, RenameBuffer->FileName);		InitializeObjectAttributes(&fAttrs, &FileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);		Status = ZwOpenFile(&hFile, DELETE, &fAttrs, &StatusBlock, 0, 0);		if (!NT_SUCCESS(Status))			continue;		Status = StringCbPrintf(RenameBuffer->FileName, FileNameLength, L"%ws.%03d", BaseFileName, RotateIndex + 1);		if (!SUCCEEDED(Status))			goto Cleanup;		Status = ZwSetInformationFile(hFile, &StatusBlock, RenameBuffer, FileNameLength + FIELD_OFFSET(FILE_RENAME_INFORMATION, FileName),			FileRenameInformation);		if (!NT_SUCCESS(Status))			goto Cleanup;		ZwClose(hFile);		hFile = NULL;	}	// Rename it	Status = StringCbPrintf(RenameBuffer->FileName, FileNameLength, L"%ws.%03d", BaseFileName, 1);	if (!SUCCEEDED(Status))		goto Cleanup;	// Compress	Status = Log_CompressFile(LogFile);	Status = ZwSetInformationFile(LogFile, &StatusBlock, RenameBuffer, FileNameLength + FIELD_OFFSET(FILE_RENAME_INFORMATION, FileName),		FileRenameInformation);	if (!NT_SUCCESS(Status))		goto Cleanup;	// And start logging into the new file	ZwClose(LogFile);	LogFile = NULL;	Status = Log_StartFileLogging(LogFileName);Cleanup:	if (hFile)		ZwClose(hFile);	if (RenameBuffer)		ExFreePoolWithTag(RenameBuffer, LogAllocationTag);		return Status;}
开发者ID:the-alien,项目名称:evhdparser,代码行数:90,


示例17: GetVersionInfo

//.........这里部分代码省略.........         NULL,         NULL,         REG_NONE,         NULL,         0}    };    UserBuildString.Buffer          = &NameBuffer[OFFSET_BLDSTRING];    UserBuildString.Length          = 0;    UserBuildString.MaximumLength   = MAXVERSIONSTRING * sizeof(WCHAR);    UserTypeString.Buffer           = &NameBuffer[OFFSET_TYPSTRING];    UserTypeString.Length           = 0;    UserTypeString.MaximumLength    = MAXVERSIONSTRING * sizeof(WCHAR);    UserCSDString.Buffer            = &NameBuffer[OFFSET_CSDSTRING];    UserCSDString.Length            = 0;    UserCSDString.MaximumLength     = MAXVERSIONSTRING * sizeof(WCHAR);    Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT,                                    L"",                                    BaseServerRegistryConfigurationTable,                                    NULL,                                    NULL);    if (!NT_SUCCESS(Status)) {        RIPMSG1(RIP_WARNING, "GetVersionInfo failed with status %x", Status);        return;    }    ServerLoadString( hModuleWin, STR_DTBS_PRODUCTID, wszPID, ARRAY_SIZE(wszPID) );    ServerLoadString( hModuleWin, STR_DTBS_PRODUCTPRO, wszPro, ARRAY_SIZE(wszPro) );    ServerLoadString( hModuleWin, STR_DTBS_PRODUCTSRV, wszSrv, ARRAY_SIZE(wszSrv) );    ServerLoadString( hModuleWin, STR_DTBS_PRODUCTBUILD, wszPBuild, ARRAY_SIZE(wszPBuild) );    /*     * Write out Debugging Version message.     */    /*     * Bug 280256 - joejo     * Create new desktop build information strings     */    swprintf(        wszProductName,        wszPID,        ((USER_SHARED_DATA->NtProductType == NtProductWinNt) ? wszPro : wszSrv)        );        if (gfUnsignedDrivers) {        /* This takes precedence */        ServerLoadString( hModuleWin, STR_TESTINGONLY, wszEvaluation, ARRAY_SIZE(wszEvaluation) );    } else if (USER_SHARED_DATA->SystemExpirationDate.QuadPart) {        ServerLoadString(hModuleWin, STR_DTBS_EVALUATION, wszEvaluation,                ARRAY_SIZE(wszEvaluation));    } else {        wszEvaluation[0] = '/0';    }    swprintf(        wszProductBuild,        wszPBuild,        wszEvaluation,        UserBuildString.Buffer        );    if (Verbose) {        ServerLoadString( hModuleWin, STR_SAFEMODE_TITLE1, Title1, ARRAY_SIZE(Title1) );        ServerLoadString( hModuleWin, STR_SAFEMODE_TITLE2, Title2, ARRAY_SIZE(Title2) );        swprintf(            wszT,            UserCSDString.Length == 0 ? Title1 : Title2,            UserBuildString.Buffer,            UserCSDString.Buffer,            USER_SHARED_DATA->NtSystemRoot            );    } else {        PWSTR s = wcsrchr( UserTypeString.Buffer, L' ' );        if (s) {            s += 1;        } else {            s = UserTypeString.Buffer;        }        ServerLoadString( hModuleWin, STR_SAFEMODE_TITLE3, Title1, ARRAY_SIZE(Title1) );        ServerLoadString( hModuleWin, STR_SAFEMODE_TITLE4, Title2, ARRAY_SIZE(Title2) );        swprintf(            wszT,            UserCSDString.Length == 0 ? Title1 : Title2,            UserBuildString.Buffer,            UserCSDString.Buffer,            s            );    }}
开发者ID:conioh,项目名称:os-design,代码行数:101,


示例18: winAccessW

int winAccessW(const wchar_t *path, int mode){    DWORD attr = GetFileAttributesW(path);    if(attr == 0xffffffff) return -1;    if(mode == F_OK) return 0;    if(mode & X_OK)	if(!(attr & FILE_ATTRIBUTE_DIRECTORY)) { /* Directory, so OK */	    /* Look at extension for executables */	    wchar_t *p = wcsrchr(path, '.');	    if(p == NULL ||	       !((wcsicmp(p, L".exe") == 0) || (wcsicmp(p, L".com") == 0) ||		 (wcsicmp(p, L".bat") == 0) || (wcsicmp(p, L".cmd") == 0)) )		return -1;	}    {	/* Now look for file security info */	SECURITY_DESCRIPTOR *sdPtr = NULL;	DWORD size = 0;	GENERIC_MAPPING genMap;	HANDLE hToken = NULL;	DWORD desiredAccess = 0;	DWORD grantedAccess = 0;	BOOL accessYesNo = FALSE;	PRIVILEGE_SET privSet;	DWORD privSetSize = sizeof(PRIVILEGE_SET);	int error;	/* get size */	GetFileSecurityW(path,			 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION			 | DACL_SECURITY_INFORMATION, 0, 0, &size);	error = GetLastError();	if (error != ERROR_INSUFFICIENT_BUFFER) return -1;	sdPtr = (SECURITY_DESCRIPTOR *) alloca(size);	if(!GetFileSecurityW(path,			     OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION			     | DACL_SECURITY_INFORMATION, sdPtr, size, &size))	    return -1;	/*	 * Perform security impersonation of the user and open the	 * resulting thread token.	 */	if(!ImpersonateSelf(SecurityImpersonation)) return -1;	if(!OpenThreadToken(GetCurrentThread (),			    TOKEN_DUPLICATE | TOKEN_QUERY, FALSE,			    &hToken)) return -1;	if (mode & R_OK) desiredAccess |= FILE_GENERIC_READ;	if (mode & W_OK) desiredAccess |= FILE_GENERIC_WRITE;	if (mode & X_OK) desiredAccess |= FILE_GENERIC_EXECUTE;	memset(&genMap, 0x0, sizeof (GENERIC_MAPPING));	genMap.GenericRead = FILE_GENERIC_READ;	genMap.GenericWrite = FILE_GENERIC_WRITE;	genMap.GenericExecute = FILE_GENERIC_EXECUTE;	genMap.GenericAll = FILE_ALL_ACCESS;	if(!AccessCheck(sdPtr, hToken, desiredAccess, &genMap, &privSet,			&privSetSize, &grantedAccess, &accessYesNo)) {	    CloseHandle(hToken);	    return -1;	}	CloseHandle(hToken);	if (!accessYesNo) return -1;	if ((mode & W_OK)	    && !(attr & FILE_ATTRIBUTE_DIRECTORY)	    && (attr & FILE_ATTRIBUTE_READONLY)) return -1;    }    return 0;}
开发者ID:skyguy94,项目名称:R,代码行数:71,


示例19: ViewTree_LoadTree

static BOOLViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID){    DWORD dwIndex;    WCHAR szKeyName[64], szText[MAX_PATH], *pch;    DWORD Size, Value;    PVIEWTREE_ENTRY pAllocated;    // resize s_ViewTreeEntries    Size = (s_ViewTreeEntryCount + 1) * sizeof(VIEWTREE_ENTRY);    pAllocated = (PVIEWTREE_ENTRY)realloc(s_ViewTreeEntries, Size);    if (pAllocated == NULL)        return FALSE;   // failure    else        s_ViewTreeEntries = pAllocated;    PVIEWTREE_ENTRY pEntry = &s_ViewTreeEntries[s_ViewTreeEntryCount];    // dwID, dwParentID, szKeyName    pEntry->dwID = s_ViewTreeEntryCount;    pEntry->dwParentID = dwParentID;    lstrcpynW(pEntry->szKeyName, pszKeyName, _countof(pEntry->szKeyName));    // Text, ResourceID    pEntry->szText[0] = 0;    pEntry->dwResourceID = 0;    szText[0] = 0;    Size = sizeof(szText);    RegQueryValueExW(hKey, L"Text", NULL, NULL, LPBYTE(szText), &Size);    if (szText[0] == L'@')    {        pch = wcsrchr(szText, L',');        if (pch)        {            *pch = 0;            dwIndex = abs(_wtoi(pch + 1));            pEntry->dwResourceID = dwIndex;        }        HINSTANCE hInst = LoadLibraryW(&szText[1]);        LoadStringW(hInst, dwIndex, szText, _countof(szText));        FreeLibrary(hInst);    }    else    {        pEntry->dwResourceID = DWORD(-1);    }    lstrcpynW(pEntry->szText, szText, _countof(pEntry->szText));    // Type    szText[0] = 0;    RegQueryValueExW(hKey, L"Type", NULL, NULL, LPBYTE(szText), &Size);    if (lstrcmpiW(szText, L"checkbox") == 0)        pEntry->dwType = AETYPE_CHECKBOX;    else if (lstrcmpiW(szText, L"radio") == 0)        pEntry->dwType = AETYPE_RADIO;    else if (lstrcmpiW(szText, L"group") == 0)        pEntry->dwType = AETYPE_GROUP;    else        return FALSE;   // failure    pEntry->nIconID = -1;    if (pEntry->dwType == AETYPE_GROUP)    {        // Bitmap (Icon)        UINT nIconIndex = 0;        Size = sizeof(szText);        szText[0] = 0;        RegQueryValueExW(hKey, L"Bitmap", NULL, NULL, LPBYTE(szText), &Size);        WCHAR szExpanded[MAX_PATH];        ExpandEnvironmentStringsW(szText, szExpanded, _countof(szExpanded));        pch = wcsrchr(szExpanded, L',');        if (pch)        {            *pch = 0;            nIconIndex = abs(_wtoi(pch + 1));        }        pEntry->nIconID = ViewTree_AddIcon(szExpanded, nIconIndex);    }    if (pEntry->dwType == AETYPE_GROUP)    {        pEntry->hkeyRoot = NULL;        pEntry->szRegPath[0] = 0;        pEntry->szValueName[0] = 0;        pEntry->dwCheckedValue = 0;        pEntry->bHasUncheckedValue = FALSE;        pEntry->dwUncheckedValue = 0;        pEntry->dwDefaultValue = 0;        pEntry->hItem = NULL;        pEntry->bGrayed = FALSE;        pEntry->bChecked = FALSE;    }    else    {        // HKeyRoot        HKEY HKeyRoot = HKEY_CURRENT_USER;        Size = sizeof(HKeyRoot);        RegQueryValueExW(hKey, L"HKeyRoot", NULL, NULL, LPBYTE(&HKeyRoot), &Size);        pEntry->hkeyRoot = HKeyRoot;//.........这里部分代码省略.........
开发者ID:Moteesh,项目名称:reactos,代码行数:101,


示例20: file_get_desc

//.........这里部分代码省略.........                    return COMPLETE_DIRECTORY_SYMLINK_DESC;                }                else                {                    if ((buf.st_mode & S_IXUSR) ||                            (buf.st_mode & S_IXGRP) ||                            (buf.st_mode & S_IXOTH))                    {                        if (waccess(filename, X_OK) == 0)                        {                            /*                              Weird group permissions and other such                              issues make it non-trivial to find out                              if we can actually execute a file using                              the result from stat. It is much safer                              to use the access function, since it                              tells us exactly what we want to know.                            */                            return COMPLETE_EXEC_LINK_DESC;                        }                    }                }                return COMPLETE_SYMLINK_DESC;            }            else            {                switch (err)                {                    case ENOENT:                    {                        return COMPLETE_ROTTEN_SYMLINK_DESC;                    }                    case ELOOP:                    {                        return COMPLETE_LOOP_SYMLINK_DESC;                    }                }                /*                  On unknown errors we do nothing. The file will be                  given the default 'File' description or one based on the suffix.                */            }        }        else if (S_ISCHR(buf.st_mode))        {            return COMPLETE_CHAR_DESC;        }        else if (S_ISBLK(buf.st_mode))        {            return COMPLETE_BLOCK_DESC;        }        else if (S_ISFIFO(buf.st_mode))        {            return COMPLETE_FIFO_DESC;        }        else if (S_ISSOCK(buf.st_mode))        {            return COMPLETE_SOCKET_DESC;        }        else if (S_ISDIR(buf.st_mode))        {            return COMPLETE_DIRECTORY_DESC;        }        else        {            if ((buf.st_mode & S_IXUSR) ||                    (buf.st_mode & S_IXGRP) ||                    (buf.st_mode & S_IXOTH))            {                if (waccess(filename, X_OK) == 0)                {                    /*                      Weird group permissions and other such issues                      make it non-trivial to find out if we can                      actually execute a file using the result from                      stat. It is much safer to use the access                      function, since it tells us exactly what we want                      to know.                    */                    return COMPLETE_EXEC_DESC;                }            }        }    }    suffix = wcsrchr(filename.c_str(), L'.');    if (suffix != 0 && !wcsrchr(suffix, L'/'))    {        return complete_get_desc_suffix(suffix);    }    return COMPLETE_FILE_DESC ;}
开发者ID:ViciousPotato,项目名称:fish-shell,代码行数:101,


示例21: HttpRequest

void CDropbox::RequestAccountInfo(){	HttpRequest *request = new HttpRequest(hNetlibUser, REQUEST_GET, DROPBOX_API_URL "/account/info");	request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));	mir_ptr<NETLIBHTTPREQUEST> response(request->Send());	delete request;	MCONTACT hContact = CDropbox::GetDefaultContact();	if (response && response->resultCode == HTTP_STATUS_OK)	{		JSONROOT root(response->pData);		if (root)		{			JSONNODE *node = json_get(root, "referral_link");			if (node)			{				ptrW referral_link = ptrW(json_as_string(node));				db_set_ws(hContact, MODULE, "Homepage", referral_link);			}			node = json_get(root, "display_name");			if (node)			{				ptrW display_name = ptrW(json_as_string(node));				wchar_t *sep = wcsrchr(display_name, L' ');				if (sep)				{					db_set_ws(hContact, MODULE, "LastName", sep + 1);					display_name[wcslen(display_name) - wcslen(sep)] = '/0';					db_set_ws(hContact, MODULE, "FirstName", display_name);				}				else				{					db_set_ws(hContact, MODULE, "FirstName", display_name);					db_unset(hContact, MODULE, "LastName");				}			}			node = json_get(root, "country");			if (node)			{				ptrW isocodeW(json_as_string(node));				ptrA isocode(mir_u2a(isocodeW));				if (!strlen(isocode))					db_unset(hContact, MODULE, "Country");				else				{					char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0);					db_set_s(hContact, MODULE, "Country", country);				}			}			node = json_get(root, "quota_info");			JSONNODE *nroot = json_as_node(node);			if (nroot)			{				node = json_get(nroot, "shared");				if (node)					db_set_dw(hContact, MODULE, "SharedQuota", json_as_int(node));				node = json_get(nroot, "normal");				if (node)					db_set_dw(hContact, MODULE, "NormalQuota", json_as_int(node));				node = json_get(nroot, "quota");				if (node)					db_set_dw(hContact, MODULE, "TotalQuota", json_as_int(node));			}		}	}	HandleHttpResponseError(hNetlibUser, response);}
开发者ID:martok,项目名称:miranda-ng,代码行数:74,


示例22: dumpResolved

// dump - Dumps a nicely formatted rendition of the CallStack, including//   symbolic information (function names and line numbers) if available.////   Note: The symbol handler must be initialized prior to calling this//     function.////  - showinternalframes (IN): If true, then all frames in the CallStack will be//      dumped. Otherwise, frames internal to the heap will not be dumped.////  Return Value:////    None.//void CallStack::dump(BOOL showInternalFrames, UINT start_frame) const{    // The stack was dumped already    if (m_resolved)    {        dumpResolved();        return;    }    if (m_status & CALLSTACK_STATUS_INCOMPLETE) {        // This call stack appears to be incomplete. Using StackWalk64 may be        // more reliable.        Report(L"    HINT: The following call stack may be incomplete. Setting /"StackWalkMethod/"/n"            L"      in the vld.ini file to /"safe/" instead of /"fast/" may result in a more/n"            L"      complete stack trace./n");    }    IMAGEHLP_LINE64  sourceInfo = { 0 };    sourceInfo.SizeOfStruct = sizeof(IMAGEHLP_LINE64);    BYTE symbolBuffer [sizeof(SYMBOL_INFO) + MAX_SYMBOL_NAME_SIZE] = { 0 };    WCHAR lowerCaseName [MAX_PATH];    WCHAR callingModuleName [MAX_PATH];    const size_t max_size = MAXREPORTLENGTH + 1;    // Iterate through each frame in the call stack.    for (UINT32 frame = start_frame; frame < m_size; frame++)    {        // Try to get the source file and line number associated with        // this program counter address.        SIZE_T programCounter = (*this)[frame];        g_symbolLock.Enter();        BOOL             foundline = FALSE;        DWORD            displacement = 0;        DbgTrace(L"dbghelp32.dll %i: SymGetLineFromAddrW64/n", GetCurrentThreadId());        foundline = SymGetLineFromAddrW64(g_currentProcess, programCounter, &displacement, &sourceInfo);        if (foundline && !showInternalFrames) {            wcscpy_s(lowerCaseName, sourceInfo.FileName);            _wcslwr_s(lowerCaseName, wcslen(lowerCaseName) + 1);            if (isInternalModule(lowerCaseName)) {                // Don't show frames in files internal to the heap.                g_symbolLock.Leave();                continue;            }        }        // Initialize structures passed to the symbol handler.        SYMBOL_INFO* functionInfo = (SYMBOL_INFO*)&symbolBuffer;        functionInfo->SizeOfStruct = sizeof(SYMBOL_INFO);        functionInfo->MaxNameLen = MAX_SYMBOL_NAME_LENGTH;        // Try to get the name of the function containing this program        // counter address.        DWORD64          displacement64 = 0;        LPWSTR           functionName;        DbgTrace(L"dbghelp32.dll %i: SymFromAddrW/n", GetCurrentThreadId());        if (SymFromAddrW(g_currentProcess, programCounter, &displacement64, functionInfo)) {            functionName = functionInfo->Name;        }        else {            // GetFormattedMessage( GetLastError() );            functionName = L"(Function name unavailable)";            displacement64 = 0;        }        g_symbolLock.Leave();        HMODULE hCallingModule = GetCallingModule(programCounter);        LPWSTR moduleName = L"(Module name unavailable)";        if (hCallingModule &&             GetModuleFileName(hCallingModule, callingModuleName, _countof(callingModuleName)) > 0)        {            moduleName = wcsrchr(callingModuleName, L'//');            if (moduleName == NULL)                moduleName = wcsrchr(callingModuleName, L'/');            if (moduleName != NULL)                moduleName++;            else                moduleName = callingModuleName;        }        // Use static here to increase performance, and avoid heap allocs. Hopefully this won't        // prove to be an issue in thread safety. If it does, it will have to be simply non-static.        static WCHAR stack_line[MAXREPORTLENGTH + 1] = L"";        int NumChars = -1;        // Display the current stack frame's information.//.........这里部分代码省略.........
开发者ID:CocacolaSh,项目名称:SpellEditor,代码行数:101,


示例23: FindComspec

// используется в GUI при загрузке настроекvoid FindComspec(ConEmuComspec* pOpt, bool bCmdAlso /*= true*/){	if (!pOpt)		return;	pOpt->Comspec32[0] = 0;	pOpt->Comspec64[0] = 0;	// Ищем tcc.exe	if (pOpt->csType == cst_AutoTccCmd)	{		HKEY hk;		BOOL bWin64 = IsWindows64();		wchar_t szPath[MAX_PATH+1];		// If tcc.exe can be found near to ConEmu location		LPCWSTR ppszPredefined[] = {			L"%ConEmuBaseDir%//tcc.exe",			L"%ConEmuDir%//tcc.exe",			// Sort of PortableApps locations			L"%ConEmuDir%//..//tcc//tcc.exe",			L"%ConEmuDir%//..//..//tcc//tcc.exe",			// End of predefined list			NULL};		for (INT_PTR i = 0; ppszPredefined[i]; i++)		{			DWORD nExpand = ExpandEnvironmentStrings(ppszPredefined[i], szPath, countof(szPath));			if (nExpand && (nExpand < countof(szPath)))			{				if (FileExists(szPath))				{					wcscpy_c(pOpt->Comspec32, szPath);					wcscpy_c(pOpt->Comspec64, szPath);					break;				}			}		}		// On this step - check "Take Command"!		if (!*pOpt->Comspec32 || !*pOpt->Comspec64)		{			// [HKEY_LOCAL_MACHINE/SOFTWARE/JP Software/Take Command 13.0]			// @="/"C://Program Files//JPSoft//TCMD13//tcmd.exe/""			for (int b = 0; b <= 1; b++)			{				// b==0 - 32bit, b==1 - 64bit				if (b && !bWin64)					continue;				bool bFound = false;				DWORD nOpt = (b == 0) ? (bWin64 ? KEY_WOW64_32KEY : 0) : (bWin64 ? KEY_WOW64_64KEY : 0);				if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE//JP Software", 0, KEY_READ|nOpt, &hk))				{					wchar_t szName[MAX_PATH+1]; DWORD nLen;					for (DWORD k = 0; !bFound && !RegEnumKeyEx(hk, k, szName, &(nLen = countof(szName)-1), 0,0,0,0); k++)					{						HKEY hk2;						if (!RegOpenKeyEx(hk, szName, 0, KEY_READ|nOpt, &hk2))						{							// Just in case, check "Path" too							LPCWSTR rsNames[] = {NULL, L"Path"};							for (size_t n = 0; n < countof(rsNames); n++)							{								ZeroStruct(szPath); DWORD nSize = (countof(szPath)-1)*sizeof(szPath[0]);								if (!RegQueryValueExW(hk2, rsNames[n], NULL, NULL, (LPBYTE)szPath, &nSize) && *szPath)								{									wchar_t* psz, *pszEnd;									psz = (wchar_t*)Unquote(szPath, true);									pszEnd = wcsrchr(psz, L'//');									if (!pszEnd || lstrcmpi(pszEnd, L"//tcmd.exe") || !FileExists(psz))										continue;									lstrcpyn(pszEnd+1, L"tcc.exe", 8);									if (FileExists(psz))									{										bFound = true;										if (b == 0)											wcscpy_c(pOpt->Comspec32, psz);										else											wcscpy_c(pOpt->Comspec64, psz);									}								}							} // for (size_t n = 0; n < countof(rsNames); n++)							RegCloseKey(hk2);						}					} //  for, подключи					RegCloseKey(hk);				} // L"SOFTWARE//JP Software"			} // for (int b = 0; b <= 1; b++)			// Если установлен TCMD - предпочтительно использовать именно его, независимо от битности			if (*pOpt->Comspec32 && !*pOpt->Comspec64)				wcscpy_c(pOpt->Comspec64, pOpt->Comspec32);			else if (*pOpt->Comspec64 && !*pOpt->Comspec32)				wcscpy_c(pOpt->Comspec32, pOpt->Comspec64);		}		// If "Take Command" not installed - try "TCC/LE"		if (!*pOpt->Comspec32 || !*pOpt->Comspec64)		{//.........这里部分代码省略.........
开发者ID:davgit,项目名称:ConEmu,代码行数:101,


示例24: wWinMain

int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE previousInstance, LPTSTR commandLine, int showState){    INT_PTR result;    WCHAR qrexecClientPath[MAX_PATH] = { 0 };    WCHAR *qrexecClientCmdLine;    size_t cchQrexecClientCmdLine;    WCHAR *pathSeparator;    PROCESS_INFORMATION pi;    STARTUPINFO si = { 0 };    DWORD status;    result = DialogBox(        instance, // application instance        MAKEINTRESOURCE(IDD_INPUTBOX), // dialog box resource        NULL, // owner window        InputBoxProc // dialog box window procedure        );    switch (result)    {    case 0:        // cancel        return 0;    case -1:        // error        return 1;    }    // build qrexec-client-vm path, first get our own    if (!GetModuleFileName(NULL, qrexecClientPath, RTL_NUMBER_OF(qrexecClientPath)))    {        status = perror("GetModuleFileName");        ReportError(L"Failed to get " QREXEC_CLIENT_VM L" path");        return status;    }    // cut off file name (qrexec_agent.exe)    pathSeparator = wcsrchr(qrexecClientPath, L'//');    if (!pathSeparator)    {        LogError("Bad executable path");        ReportError(L"Cannot find dir containing " QREXEC_CLIENT_VM);        return ERROR_BAD_PATHNAME;    }    // Leave trailing backslash    pathSeparator++;    *pathSeparator = L'/0';    // append target executable    PathAppend(qrexecClientPath, QREXEC_CLIENT_VM);    cchQrexecClientCmdLine = wcslen(QREXEC_CLIENT_VM) + wcslen((WCHAR *) result) + wcslen(commandLine) + 3;    qrexecClientCmdLine = malloc(cchQrexecClientCmdLine * sizeof(WCHAR));    if (!qrexecClientCmdLine)    {        LogError("malloc failed");        ReportError(L"Out of memory");        return ERROR_NOT_ENOUGH_MEMORY;    }    if (FAILED(StringCchPrintf(qrexecClientCmdLine, cchQrexecClientCmdLine, QREXEC_CLIENT_VM L" %s%c%s",        (WCHAR *) result, QUBES_ARGUMENT_SEPARATOR, commandLine)))    {        LogError("Failed to construct command line");        ReportError(L"Failed to construct command line");        return ERROR_BAD_PATHNAME;    }    LogDebug("executing command: '%s'", qrexecClientCmdLine);    si.cb = sizeof(si);    if (!CreateProcess(qrexecClientPath, qrexecClientCmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))    {        status = perror("CreateProcess");        ReportError(L"Failed to execute qrexec-client-vm.exe");        return status;    }    return ERROR_SUCCESS;}
开发者ID:nrgaway,项目名称:qubes-core-agent-windows,代码行数:81,


示例25: wcsrchr

const wchar_t* CRes::GetName(CString &FileName){	return wcsrchr(FileName.GetString(), _T('/'))+1;}
开发者ID:VaderTi,项目名称:Patcher,代码行数:4,


示例26: memset

BOOL CYYManager::InitFactory(){	WCHAR wzSelfPath[MAX_PATH]; 	memset( wzSelfPath, 0, sizeof(wzSelfPath) );	GetModuleFileNameW( NULL, wzSelfPath, sizeof(wzSelfPath) );	LPWSTR lpInsertPos = wcsrchr( wzSelfPath, L'//' );	*lpInsertPos = L'/0';	lstrcatW( wzSelfPath, L"//pipFactory.dll" );	m_hFactory = LoadLibraryW( wzSelfPath );	if( m_hFactory == NULL ) return FALSE;	m_pfnInitInterface = (PFN_INITYYINTERFACE)GetProcAddress( m_hFactory, "YYPIP_InitInterface" );	if( m_pfnInitInterface == NULL ) return FALSE;	m_pfnGetInterface = (PFN_GETYYINTERFACE)GetProcAddress( m_hFactory, "YYPIP_GetInterface" );	if( m_pfnGetInterface == NULL ) return FALSE;	//call factory init func	if( m_pfnInitInterface() == -1 ) return FALSE;	/////////////////////////////////////////////////////////////////////////	//all game must be call this func to show yy window	m_pfnRunService = (PFN_RUNSERVICE)m_pfnGetInterface( "YYPIP_RunService" );	if( m_pfnRunService == NULL ) return FALSE;	m_pfnLoadInGame = (PFN_LOADINGAME)m_pfnGetInterface( "YYPIP_LoadInGame" );	if( m_pfnLoadInGame == NULL ) return FALSE;	m_pfnFreeGame = (PFN_FREEINGAME)m_pfnGetInterface( "YYPIP_FreeInGame" );	if( m_pfnFreeGame == NULL ) return FALSE;	m_pfnCheckClient = (PFN_CHECKCLIENT)m_pfnGetInterface( "YYPIP_CheckYYClient" );	if( m_pfnCheckClient == NULL ) return FALSE;	m_pfnIsPipSuccess = (PFN_ISPIPSUCCESS)m_pfnGetInterface( "YYPIP_IsPipRunSuccess" );	if( m_pfnIsPipSuccess == NULL ) return FALSE;	/////////////////////////////////////////////////////////////////////////	//sometimes call this func to show yy window	m_pfnMouseInput = (PFN_MOUSEINPUT)m_pfnGetInterface( "YYPIP_MouseInput" );	if( m_pfnMouseInput == NULL ) return FALSE;	m_pfnSetMainWnd = (PFN_SETMAINWND)m_pfnGetInterface( "YYPIP_SetMainWnd" );	if( m_pfnSetMainWnd == NULL ) return FALSE;	m_pfnCreateUI = (PFN_CREATEUI)m_pfnGetInterface( "YYPIP_CreateUI" );	if( m_pfnCreateUI == NULL ) return FALSE;	m_pfnDestoryUI = (PFN_DESTORYUI)m_pfnGetInterface( "YYPIP_DestoryUI" );	if( m_pfnDestoryUI == NULL ) return FALSE;	m_pfnRenderGUI = (PFN_RENDERGUI)m_pfnGetInterface( "YYPIP_RenderGUI" );	if( m_pfnRenderGUI == NULL ) return FALSE;	m_pfnGameWndMsg = (PFN_GAMEWNDMSG)m_pfnGetInterface( "YYPIP_GameWndMessage" );	if( m_pfnGameWndMsg == NULL ) return FALSE;	/////////////////////////////////////////////////////////////////////////	//game used yy voice channel	m_pfnJoinChannel = (PFN_JOINCHANNEL)m_pfnGetInterface( "YYPIP_JoinChannel" );	if( m_pfnJoinChannel == NULL ) return FALSE;	m_pfnSetTeamAdmin = (PFN_SETTEAMADMIN)m_pfnGetInterface( "YYPIP_SetTeamAdmin" );	if( m_pfnSetTeamAdmin == NULL ) return FALSE;	m_pfnSetUserName = (PFN_SETUSERNAME)m_pfnGetInterface( "YYPIP_SetUserName" );	if( m_pfnSetUserName == NULL ) return FALSE;	m_pfnJoinTeam = (PFN_JOINTEAM)m_pfnGetInterface( "YYPIP_JoinTeam" );	if( m_pfnJoinTeam == NULL ) return FALSE;	m_pfnSetTeamDevice = (PFN_SETTEAMDEVICE)m_pfnGetInterface( "YYPIP_SetTeamDevice" );	if( m_pfnSetTeamDevice == NULL ) return FALSE;	m_pfnSetTeamVoice = (PFN_SETTEAMVOICE)m_pfnGetInterface( "YYPIP_SetTeamVoice" );	if( m_pfnSetTeamVoice == NULL ) return FALSE;	m_pfnLockTeamVoice = (PFN_LOCKTEAMVOICE)m_pfnGetInterface( "YYPIP_LockTeamVoice" );	if( m_pfnLockTeamVoice == NULL ) return FALSE;	/////////////////////////////////////////////////////////////////////////	//game to channel yy voice window	m_pfnGetPipShow = (PFN_GETPIPSHOW)m_pfnGetInterface( "YYPIP_GetPipShow" );	if( m_pfnGetPipShow == NULL ) return FALSE;	m_pfnSetPipShow = (PFN_SETPIPSHOW)m_pfnGetInterface( "YYPIP_SetPipShow" );	if( m_pfnSetPipShow == NULL ) return FALSE;	m_pfnSetMsgShow = (PFN_SETMSGSHOW)m_pfnGetInterface( "YYPIP_SetMsgShow" );	if( m_pfnSetMsgShow == NULL ) return FALSE;	m_pfnMouseShow = (PFN_SETMOUSESHOW)m_pfnGetInterface( "YYPIP_SetMouseShow" );	if( m_pfnMouseShow == NULL ) return FALSE;	m_pfnLockWnd = (PFN_LOCKWINDOW)m_pfnGetInterface( "YYPIP_LockWindow" );	if( m_pfnLockWnd == NULL ) return FALSE;	m_pfnMoveWnd = (PFN_MOVEWINDOW)m_pfnGetInterface( "YYPIP_MoveWindow" );//.........这里部分代码省略.........
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:101,


示例27: gf_enum_directory

//.........这里部分代码省略.........	the_dir = opendir(path);	if (the_dir == NULL) {		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot open directory %s for enumeration: %d/n", path, errno));		return GF_IO_ERR;	}	the_file = readdir(the_dir);	while (the_file) {#endif		memset(&file_info, 0, sizeof(GF_FileEnumInfo) );#if defined (_WIN32_WCE)		if (!wcscmp(FindData.cFileName, _T(".") )) goto next;		if (!wcscmp(FindData.cFileName, _T("..") )) goto next;#elif defined(WIN32)		if (!wcscmp(FindData.cFileName, L".")) goto next;		if (!wcscmp(FindData.cFileName, L"..")) goto next;#else		if (!strcmp(the_file->d_name, "..")) goto next;		if (the_file->d_name[0] == '.') goto next;#endif#ifdef WIN32		file_info.directory = (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? GF_TRUE : GF_FALSE;		if (!enum_directory && file_info.directory) goto next;		if (enum_directory && !file_info.directory) goto next;#endif		if (filter) {#if defined (_WIN32_WCE)			short ext[30];			short *sep = wcsrchr(FindData.cFileName, (wchar_t) '.');			if (!sep) goto next;			wcscpy(ext, sep+1);			wcslwr(ext);			if (!wcsstr(w_filter, ext)) goto next;#elif defined(WIN32)			wchar_t ext[30];			wchar_t *sep = wcsrchr(FindData.cFileName, L'.');			if (!sep) goto next;			wcscpy(ext, sep+1);			wcslwr(ext);			if (!wcsstr(w_filter, ext)) goto next;#else			char ext[30];			char *sep = strrchr(the_file->d_name, '.');			if (!sep) goto next;			strcpy(ext, sep+1);			strlwr(ext);			if (!strstr(filter, sep+1)) goto next;#endif		}#if defined(WIN32)		file_info.hidden = (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? GF_TRUE : GF_FALSE;		file_info.system = (FindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? GF_TRUE : GF_FALSE;		file_info.size = MAXDWORD;		file_info.size += 1;		file_info.size *= FindData.nFileSizeHigh;		file_info.size += FindData.nFileSizeLow;		file_info.last_modified = (u64) ((*(LONGLONG *) &FindData.ftLastWriteTime - TIMESPEC_TO_FILETIME_OFFSET) / 10000000);#endif#if defined (_WIN32_WCE)
开发者ID:ARSekkat,项目名称:gpac,代码行数:67,


示例28: GetBinaryTypeW

/* * @implemented */BOOLWINAPIGetBinaryTypeW (    LPCWSTR lpApplicationName,    LPDWORD lpBinaryType){    HANDLE hFile;    DWORD BinType;    if(!lpApplicationName || !lpBinaryType)    {        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    }    hFile = CreateFileW(lpApplicationName, GENERIC_READ, FILE_SHARE_READ, NULL,                        OPEN_EXISTING, 0, 0);    if(hFile == INVALID_HANDLE_VALUE)    {        return FALSE;    }    BinType = InternalGetBinaryType(hFile);    CloseHandle(hFile);    switch(BinType)    {    case BINARY_UNKNOWN:    {        WCHAR *dot;        /*         * guess from filename         */        if(!(dot = wcsrchr(lpApplicationName, L'.')))        {            return FALSE;        }        if(!lstrcmpiW(dot, L".COM"))        {            *lpBinaryType = SCS_DOS_BINARY;            return TRUE;        }        if(!lstrcmpiW(dot, L".PIF"))        {            *lpBinaryType = SCS_PIF_BINARY;            return TRUE;        }        return FALSE;    }    case BINARY_PE_EXE32:    case BINARY_PE_DLL32:    {        *lpBinaryType = SCS_32BIT_BINARY;        return TRUE;    }    case BINARY_PE_EXE64:    case BINARY_PE_DLL64:    {        *lpBinaryType = SCS_64BIT_BINARY;        return TRUE;    }    case BINARY_WIN16:    {        *lpBinaryType = SCS_WOW_BINARY;        return TRUE;    }    case BINARY_OS216:    {        *lpBinaryType = SCS_OS216_BINARY;        return TRUE;    }    case BINARY_DOS:    {        *lpBinaryType = SCS_DOS_BINARY;        return TRUE;    }    case BINARY_UNIX_EXE:    case BINARY_UNIX_LIB:    {        return FALSE;    }    }    DPRINT1("Invalid binary type returned!/n", BinType);    return FALSE;}
开发者ID:RareHare,项目名称:reactos,代码行数:91,


示例29: IsNeedDequote

// Function checks, if we need drop first and last quotation marks// Example: ""7z.exe" /?"// Using cmd.exe rulesbool IsNeedDequote(LPCWSTR asCmdLine, bool abFromCmdCK, LPCWSTR* rsEndQuote/*=NULL*/){	if (rsEndQuote)		*rsEndQuote = NULL;	if (!asCmdLine)		return false;	bool bDeQu = false;	LPCWSTR pszQE, pszSP;	if (asCmdLine[0] == L'"')	{		bDeQu = (asCmdLine[1] == L'"');		// Всегда - нельзя. Иначе парсинг строки запуска некорректно идет		// L"/"C://ConEmu//ConEmuC64.exe/"  /PARENTFARPID=1 /C /"C://GIT//cmdw//ad.cmd CE12.sln & ci -m /"Solution debug build properties/"/""		if (!bDeQu)		{			size_t nLen = lstrlen(asCmdLine);			if (abFromCmdCK)			{				bDeQu = ((asCmdLine[nLen-1] == L'"') && (asCmdLine[nLen-2] == L'"'));			}			if (!bDeQu && (asCmdLine[nLen-1] == L'"'))			{				pszSP = wcschr(asCmdLine+1, L' ');				pszQE = wcschr(asCmdLine+1, L'"');				if (pszSP && pszQE && (pszSP < pszQE)					&& ((pszSP - asCmdLine) < MAX_PATH))				{					CmdArg lsTmp;					lsTmp.Set(asCmdLine+1, pszSP-asCmdLine-1);					bDeQu = (IsFilePath(lsTmp, true) && IsExecutable(lsTmp));				}			}		}	}	if (!bDeQu)		return false;	// Don't dequote?	pszQE = wcsrchr(asCmdLine+2, L'"');	if (!pszQE)		return false;#if 0	LPCWSTR pszQ1 = wcschr(asCmdLine+2, L'"');	if (!pszQ1)		return false;	LPCWSTR pszQE = wcsrchr(pszQ1, L'"');	// Only TWO quotes in asCmdLine?	if (pszQE == pszQ1)	{		// Doesn't contains special symbols?		if (!wcspbrk(asCmdLine+1, L"&<>()@^|"))		{			// Must contains spaces (doubt?)			if (wcschr(asCmdLine+1, L' '))			{				// Cmd also checks this for executable file name. Skip this check?				return false;			}		}	}#endif	// Well, we get here	_ASSERTE(asCmdLine[0]==L'"' && pszQE && *pszQE==L'"' && !wcschr(pszQE+1,L'"'));	// Dequote it!	if (rsEndQuote)		*rsEndQuote = pszQE;	return true;}
开发者ID:shdrach,项目名称:ConEmu,代码行数:75,



注:本文中的wcsrchr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wcsstr函数代码示例
C++ wcspbrk函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。