本文整理汇总了C++中SKIPLEN函数的典型用法代码示例。如果您正苦于以下问题:C++ SKIPLEN函数的具体用法?C++ SKIPLEN怎么用?C++ SKIPLEN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SKIPLEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConfirmCloseConsoles
// IDYES - Close All consoles
// IDNO - Close active console only
// IDCANCEL - As is
int ConfirmCloseConsoles(const ConfirmCloseParam& Parm)
{
DontEnable de;
wchar_t szText[512], *pszText;
int nBtn = IDCANCEL;
static LONG lCounter = 0;
LONG l = InterlockedIncrement(&lCounter);
if (l > 1)
{
if (l == 2)
{
_ASSERTE(FALSE && "Confirm stack overflow!");
}
goto wrap;
}
if (Parm.rpLeaveConEmuOpened) *Parm.rpLeaveConEmuOpened = false;
// Use TaskDialog?
if (gOSVer.dwMajorVersion >= 6)
{
// must be already initialized: CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
wchar_t szMessage[128];
lstrcpyn(szMessage,
Parm.asSingleConsole ? Parm.asSingleConsole : Parm.bForceKill ? L"Confirm killing?" : L"Confirm closing?",
countof(szMessage));
wchar_t szWWW[MAX_PATH];
_wsprintf(szWWW, SKIPLEN(countof(szWWW)) L"<a href=\"%s\">%s</a>", gsHomePage, gsHomePage);
wchar_t szCloseAll[MAX_PATH*2];
wchar_t *pszText;
if (Parm.asSingleConsole)
{
wcscpy_c(szCloseAll, L"Yes\n");
pszText = szCloseAll + _tcslen(szCloseAll);
lstrcpyn(pszText, Parm.asSingleTitle, min(MAX_PATH,(countof(szCloseAll)-(pszText-szCloseAll))));
pszText += _tcslen(pszText);
}
else
{
_wsprintf(szCloseAll, SKIPLEN(countof(szCloseAll))
(Parm.bGroup && (Parm.nConsoles>1))
? ((Parm.bGroup == ConfirmCloseParam::eGroup)
? L"Close group (%u console%s)"
: L"Close (%u console%s)")
: L"Close all %u console%s.",
Parm.nConsoles, (Parm.nConsoles>1)?L"s":L"");
pszText = szCloseAll + _tcslen(szCloseAll);
}
if ((Parm.asSingleConsole == NULL) || (Parm.nOperations || Parm.nUnsavedEditors))
{
//if (nOperations)
{
_wsprintf(pszText, SKIPLEN(countof(szCloseAll)-(pszText-szCloseAll)) L"\nIncomplete operations: %i", Parm.nOperations);
pszText += _tcslen(pszText);
}
//if (nUnsavedEditors)
{
_wsprintf(pszText, SKIPLEN(countof(szCloseAll)-(pszText-szCloseAll)) L"\nUnsaved editor windows: %i", Parm.nUnsavedEditors);
pszText += _tcslen(pszText);
}
}
wchar_t szCloseOne[MAX_PATH];
wcscpy_c(szCloseOne, L"Close active console only");
if (Parm.nConsoles > 1)
{
CVConGuard VCon;
int iCon = gpConEmu->GetActiveVCon(&VCon);
if (iCon >= 0)
{
pszText = szCloseOne + _tcslen(szCloseOne);
_wsprintf(pszText, SKIPLEN(countof(szCloseOne)-(pszText-szCloseOne)) L"\n#%u: ", (iCon+1));
pszText += _tcslen(pszText);
lstrcpyn(pszText, VCon->RCon()->GetTitle(true), countof(szCloseOne)-(pszText-szCloseOne));
}
}
const wchar_t* szCancel = L"Cancel\nDon't close anything";
int nButtonPressed = 0;
TASKDIALOGCONFIG config = {sizeof(config)};
TASKDIALOG_BUTTON buttons[] = {
{ IDYES, szCloseAll },
{ IDNO, szCloseOne },
{ IDCANCEL, szCancel },
};
config.cButtons = countof(buttons);
if (Parm.nConsoles <= 1)
{
buttons[1] = buttons[2];
config.cButtons--;
//.........这里部分代码省略.........
示例2: ComspecDone
//.........这里部分代码省略.........
// Тут нужна реальная, а не скорректированная информация!
if (!gbNonGuiMode)
{
// Если GUI не сможет через сервер вернуть высоту буфера - это нужно сделать нам!
lbRc1 = GetConsoleScreenBufferInfo(hOut1 = GetStdHandle(STD_OUTPUT_HANDLE), &sbi1);
if (!lbRc1)
dwErr1 = GetLastError();
xf_dump_chk();
}
//PRAGMA_ERROR("Размер должен возвращать сам GUI, через серверный ConEmuC!");
#ifdef SHOW_STARTED_MSGBOX
MessageBox(GetConEmuHWND(2), L"ConEmuC (comspec mode) is about to TERMINATE", L"ConEmuC.ComSpec", 0);
#endif
#ifdef _DEBUG
xf_dump_chk();
xf_validate(NULL);
#endif
if (!gbNonGuiMode && (gpSrv->dwParentFarPID != 0))
{
//// Вернуть размер буфера (высота И ширина)
//if (gpSrv->sbi.dwSize.X && gpSrv->sbi.dwSize.Y) {
// SMALL_RECT rc = {0};
// SetConsoleSize(0, gpSrv->sbi.dwSize, rc, "ComspecDone");
//}
//ConOutCloseHandle()
CONSOLE_SCREEN_BUFFER_INFO l_csbi = {{0}};
lbRc2 = GetConsoleScreenBufferInfo(hOut2 = GetStdHandle(STD_OUTPUT_HANDLE), &l_csbi);
CESERVER_REQ *pOut = SendStopped(&l_csbi);
if (pOut)
{
if (!pOut->StartStopRet.bWasBufferHeight)
{
//gpSrv->sbi.dwSize = pIn->StartStop.sbi.dwSize;
lbRc1 = FALSE; // Консольное приложение самостоятельно сбросило буферный режим. Не дергаться...
}
else
{
lbRc1 = TRUE;
}
ExecuteFreeResult(pOut);
pOut = NULL;
}
if (!gbWasBufferHeight)
{
lbRc2 = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi2);
#ifdef _DEBUG
if (sbi2.dwSize.Y > 200)
{
wchar_t szTitle[128];
_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuC (PID=%i)", GetCurrentProcessId());
MessageBox(NULL, L"BufferHeight was not turned OFF", szTitle, MB_SETFOREGROUND|MB_SYSTEMMODAL);
}
#endif
if (lbRc1 && lbRc2 && sbi2.dwSize.Y == sbi1.dwSize.Y)
{
// GUI не смог вернуть высоту буфера...
// Это плохо, т.к. фар высоту буфера не меняет и будет сильно глючить на N сотнях строк...
int nNeedHeight = gpSrv->sbi.dwSize.Y;
if (nNeedHeight < 10)
{
nNeedHeight = (sbi2.srWindow.Bottom-sbi2.srWindow.Top+1);
}
if (sbi2.dwSize.Y != nNeedHeight)
{
_ASSERTE(sbi2.dwSize.Y == nNeedHeight);
PRINT_COMSPEC(L"Error: BufferHeight was not changed from %i\n", sbi2.dwSize.Y);
SMALL_RECT rc = {0};
sbi2.dwSize.Y = nNeedHeight;
if (gpLogSize) LogSize(&sbi2.dwSize, 0, ":ComspecDone.RetSize.before");
SetConsoleSize(0, sbi2.dwSize, rc, "ComspecDone.Force");
if (gpLogSize) LogSize(NULL, 0, ":ComspecDone.RetSize.after");
}
}
}
}
if (gpSrv->pszPreAliases) {
free(gpSrv->pszPreAliases);
gpSrv->pszPreAliases = NULL;
}
//SafeCloseHandle(ghCtrlCEvent);
//SafeCloseHandle(ghCtrlBreakEvent);
}
示例3: main
int main(int argc, char** argv)
{
gn_argc = argc; gp_argv = argv;
int iRc = 0;
HMODULE hConEmu = NULL;
wchar_t szErrInfo[200];
DWORD dwErr;
typedef int (__stdcall* ConsoleMain2_t)(BOOL abAlternative);
ConsoleMain2_t lfConsoleMain2;
#ifdef _DEBUG
HMODULE hConEmuHk = GetModuleHandle(WIN3264TEST(L"ConEmuHk.dll",L"ConEmuHk64.dll"));
_ASSERTE(hConEmuHk==NULL && "Hooks must not be loaded into ConEmuC[64].exe!");
#endif
#if defined(SHOW_STARTED_MSGBOX)
if (!IsDebuggerPresent())
{
wchar_t szTitle[100]; _wsprintf(szTitle, SKIPLEN(countof(szTitle)) WIN3264TEST(L"ConEmuC",L"ConEmuC64") L" Loaded (PID=%i)", GetCurrentProcessId());
const wchar_t* pszCmdLine = GetCommandLineW();
MessageBox(NULL,pszCmdLine,szTitle,0);
}
#endif
// Обязательно, иначе по CtrlC мы свалимся
SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true);
#ifdef _DEBUG
UnitTests();
#endif
// Some command we can process internally
if (ProcessCommandLine(iRc, hConEmu))
{
// Done, exiting
goto wrap;
}
// Otherwise - do the full cycle
if (!hConEmu)
hConEmu = LoadLibrary(WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
dwErr = GetLastError();
if (!hConEmu)
{
_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
L"Can't load library \"%s\", ErrorCode=0x%08X\n",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"),
dwErr);
_wprintf(szErrInfo);
_ASSERTE(FALSE && "LoadLibrary failed");
iRc = CERR_CONEMUHK_NOTFOUND;
goto wrap;
}
// Загрузить функи из ConEmuHk
lfConsoleMain2 = (ConsoleMain2_t)GetProcAddress(hConEmu, "ConsoleMain2");
gfHandlerRoutine = (PHANDLER_ROUTINE)GetProcAddress(hConEmu, "HandlerRoutine");
if (!lfConsoleMain2 || !gfHandlerRoutine)
{
dwErr = GetLastError();
_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
L"Procedure \"%s\" not found in library \"%s\"",
lfConsoleMain2 ? L"HandlerRoutine" : L"ConsoleMain2",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
_wprintf(szErrInfo);
_ASSERTE(FALSE && "GetProcAddress failed");
FreeLibrary(hConEmu);
iRc = CERR_CONSOLEMAIN_NOTFOUND;
goto wrap;
}
// Main dll entry point for Server & ComSpec
iRc = lfConsoleMain2(0/*WorkMode*/);
// Exiting
gfHandlerRoutine = NULL;
//FreeLibrary(hConEmu); -- Shutdown Server/Comspec уже выполнен
wrap:
//-- bottle neck: relatively long deinitialization
ExitProcess(iRc);
return iRc;
}
示例4: if
//.........这里部分代码省略.........
}
DWORD curStyle = GetWindowLong(hWnd, GWL_STYLE);
if ((curStyle & CRITICAL_DCWND_STYLES) != (pVCon->mn_WndDCStyle & CRITICAL_DCWND_STYLES))
{
// DC window styles was changed externally!
bInFixStyle = true;
_ASSERTEX(((curStyle & CRITICAL_DCWND_STYLES) != (pVCon->mn_WndDCStyle & CRITICAL_DCWND_STYLES)));
SetWindowLongPtr(hWnd, GWL_STYLE, (LONG_PTR)(DWORD_PTR)pVCon->mn_WndDCStyle);
bInFixStyle = false;
}
}
if (messg >= WM_MOUSEFIRST && messg <= WM_MOUSELAST)
{
POINT pt = {LOWORD(lParam),HIWORD(lParam)};
MapWindowPoints(hWnd, hParent, &pt, 1);
lParam = MAKELONG(pt.x,pt.y);
}
result = gpConEmu->WndProc(hParent, messg, wParam, lParam);
}
break;
case WM_IME_NOTIFY:
break;
case WM_INPUTLANGCHANGE:
case WM_INPUTLANGCHANGEREQUEST:
{
#ifdef _DEBUG
if (IsDebuggerPresent())
{
WCHAR szMsg[128];
_wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"InChild %s(CP:%i, HKL:0x%08X)\n",
(messg == WM_INPUTLANGCHANGE) ? L"WM_INPUTLANGCHANGE" : L"WM_INPUTLANGCHANGEREQUEST",
(DWORD)wParam, (DWORD)lParam);
DEBUGSTRLANG(szMsg);
}
#endif
result = DefWindowProc(hWnd, messg, wParam, lParam);
} break;
#ifdef _DEBUG
case WM_WINDOWPOSCHANGING:
{
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
result = DefWindowProc(hWnd, messg, wParam, lParam);
}
return result;
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
result = DefWindowProc(hWnd, messg, wParam, lParam);
}
break;
#endif
case WM_SETCURSOR:
{
gpConEmu->WndProc(hWnd, messg, wParam, lParam);
//if (!result)
// result = DefWindowProc(hWnd, messg, wParam, lParam);
}
// If an application processes this message, it should return TRUE to halt further processing or FALSE to continue.
break;
示例5: switch
bool CConEmuUpdate::QueryConfirmation(CConEmuUpdate::UpdateStep step, LPCWSTR asParm)
{
if (mb_RequestTerminate)
{
return false;
}
bool lbRc = false;
wchar_t* pszMsg = NULL;
size_t cchMax;
switch (step)
{
case us_ConfirmDownload:
{
cchMax = _tcslen(asParm)+300;
pszMsg = (wchar_t*)malloc(cchMax*sizeof(*pszMsg));
if (mb_ManualCallMode == 2)
{
lbRc = true;
}
else if (mp_Set->isUpdateConfirmDownload || mb_ManualCallMode)
{
wchar_t* pszDup = lstrdup(asParm);
wchar_t* pszFile = pszDup ? wcsrchr(pszDup, L'/') : NULL;
if (pszFile)
{
pszFile[1] = 0;
pszFile = (wchar_t*)(asParm + (pszFile - pszDup + 1));
asParm = pszDup;
}
_wsprintf(pszMsg, SKIPLEN(cchMax) L"New %s version available: %s\n\nVersions on server\n%s\n\n%s\n%s\n\nDownload?",
(mp_Set->isUpdateUseBuilds==1) ? L"stable" : (mp_Set->isUpdateUseBuilds==3) ? L"preview" : L"developer",
ms_NewVersion,
ms_VerOnServer,
asParm ? asParm : L"",
pszFile ? pszFile : L"");
SafeFree(pszDup);
m_UpdateStep = step;
lbRc = QueryConfirmationInt(pszMsg);
}
else
{
_wsprintf(pszMsg, SKIPLEN(cchMax) L"New %s version available: %s\nClick here to download",
(mp_Set->isUpdateUseBuilds==1) ? L"stable" : (mp_Set->isUpdateUseBuilds==3) ? L"preview" : L"developer",
ms_NewVersion);
Icon.ShowTrayIcon(pszMsg, tsa_Source_Updater);
lbRc = false;
}
}
break;
case us_ConfirmUpdate:
cchMax = 512;
pszMsg = (wchar_t*)malloc(cchMax*sizeof(*pszMsg));
_wsprintf(pszMsg, SKIPLEN(cchMax)
L"Do you want to close ConEmu and\n"
L"update to %s version %s?",
mb_DroppedMode ? L"dropped" : (mp_Set->isUpdateUseBuilds==1) ? L"new stable"
: (mp_Set->isUpdateUseBuilds==3) ? L"new preview" : L"new developer", ms_NewVersion);
m_UpdateStep = step;
lbRc = QueryConfirmationInt(pszMsg);
break;
default:
_ASSERTE(step==us_ConfirmDownload);
lbRc = false;
}
SafeFree(pszMsg);
return lbRc;
}
示例6: IsBackgroundValid
// вызывается при получении нового Background (CECMD_SETBACKGROUND) из плагина
// и для очистки при закрытии (рестарте) консоли
SetBackgroundResult CBackground::SetPluginBackgroundImageData(CESERVER_REQ_SETBACKGROUND* apImgData, bool&/*OUT*/ bUpdate)
{
if (!this) return esbr_Unexpected;
//if (!isMainThread())
//{
//// При вызове из серверной нити (только что пришло из плагина)
//if (mp_RCon->isConsoleClosing())
// return esbr_ConEmuInShutdown;
bool bIsEmf = false;
UINT nSize = IsBackgroundValid(apImgData, &bIsEmf);
if (!nSize)
{
_ASSERTE(FALSE && "!IsBackgroundValid(apImgData, NULL)");
return esbr_InvalidArg;
}
if (!apImgData->bEnabled)
{
//mb_BkImgDelete = TRUE;
mb_BkImgExist = FALSE;
NeedBackgroundUpdate();
//Update(true/*bForce*/);
bUpdate = true;
return gpSet->isBgPluginAllowed ? esbr_OK : esbr_PluginForbidden;
}
#ifdef _DEBUG
if ((GetKeyState(VK_SCROLL) & 1))
{
static UINT nBackIdx = 0;
wchar_t szFileName[32];
_wsprintf(szFileName, SKIPLEN(countof(szFileName)) L"PluginBack_%04u.bmp", nBackIdx++);
char szAdvInfo[512];
BITMAPINFOHEADER* pBmp = (BITMAPINFOHEADER*)((&apImgData->bmp)+1);
_wsprintfA(szAdvInfo, SKIPLEN(countof(szAdvInfo)) "\r\nnType=%i, bEnabled=%i,\r\nWidth=%i, Height=%i, Bits=%i, Encoding=%i\r\n",
apImgData->nType, apImgData->bEnabled,
pBmp->biWidth, pBmp->biHeight, pBmp->biBitCount, pBmp->biCompression);
HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (hFile != INVALID_HANDLE_VALUE)
{
DWORD cbWrite;
WriteFile(hFile, &apImgData->bmp, apImgData->bmp.bfSize, &cbWrite, 0);
WriteFile(hFile, szAdvInfo, lstrlenA(szAdvInfo), &cbWrite, 0);
CloseHandle(hFile);
}
}
#endif
// // Поскольку вызов асинхронный (сразу возвращаем в плагин), то нужно сделать копию данных
// CESERVER_REQ_SETBACKGROUND* pCopy = (CESERVER_REQ_SETBACKGROUND*)malloc(nSize);
// if (!pCopy)
// return esbr_Unexpected;
// memmove(pCopy, apImgData, nSize);
// // Запомнить последний актуальный, и послать в главную нить
// mp_LastImgData = pCopy;
// mb_BkImgDelete = FALSE;
// gpConEmu->PostSetBackground(this, pCopy);
// return gpSet->isBgPluginAllowed ? esbr_OK : esbr_PluginForbidden;
//}
//// Если вызов пришел во время закрытия консоли - игнорировать
//if (mp_RCon->isConsoleClosing())
////// Этот apImgData уже не актуален. Во время обработки сообщения пришел новый Background.
//// || (mp_LastImgData && mp_LastImgData != apImgData))
//{
// free(apImgData);
// return esbr_Unexpected;
//}
// Ссылку на актуальный - не сбрасываем. Она просто информационная, и есть возможность наколоться с многопоточностью
//mp_LastImgData = NULL;
//UINT nSize = IsBackgroundValid(apImgData);
//if (!nSize)
//{
// // Не допустимый apImgData. Вроде такого быть не должно - все уже проверено
// _ASSERTE(IsBackgroundValid(apImgData) != 0);
// //free(apImgData);
// return esbr_InvalidArg;
//}
//MSectionLock SBK; SBK.Lock(&csBkImgData);
//_ASSERTE(isMainThread());
if (!mcs_BkImgData)
mcs_BkImgData = new MSection();
MSectionLock SC;
SC.Lock(mcs_BkImgData, TRUE);
if (bIsEmf)
//.........这里部分代码省略.........
示例7: PlugServerCommand
BOOL WINAPI PlugServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ* &ppReply, DWORD &pcbReplySize, DWORD &pcbMaxReplySize, LPARAM lParam)
{
BOOL lbRc = FALSE;
//HANDLE hPipe = (HANDLE)ahPipe;
//CESERVER_REQ *pIn=NULL;
//BYTE cbBuffer[64]; // Для большей части команд нам хватит
//DWORD cbRead = 0, cbWritten = 0, dwErr = 0;
BOOL fSuccess = FALSE;
MSectionThread SCT(csTabs);
// Send a message to the pipe server and read the response.
//fSuccess = ReadFile(hPipe, cbBuffer, sizeof(cbBuffer), &cbRead, NULL);
//dwErr = GetLastError();
//if (!fSuccess && (dwErr != ERROR_MORE_DATA))
//{
// _ASSERTE("ReadFile(pipe) failed"==NULL);
// CloseHandle(hPipe);
// return 0;
//}
//pIn = (CESERVER_REQ*)cbBuffer; // Пока cast, если нужно больше - выделим память
//_ASSERTE(pIn->hdr.cbSize>=sizeof(CESERVER_REQ_HDR) && cbRead>=sizeof(CESERVER_REQ_HDR));
//_ASSERTE(pIn->hdr.nVersion == CESERVER_REQ_VER);
if (pIn->hdr.cbSize < sizeof(CESERVER_REQ_HDR) || /*in.nSize < cbRead ||*/ pIn->hdr.nVersion != CESERVER_REQ_VER)
{
//CloseHandle(hPipe);
gpPlugServer->BreakConnection(pInst);
return FALSE;
}
//int nAllSize = pIn->hdr.cbSize;
//pIn = (CESERVER_REQ*)Alloc(nAllSize,1);
//_ASSERTE(pIn!=NULL);
//if (!pIn)
//{
// CloseHandle(hPipe);
// return 0;
//}
//memmove(pIn, cbBuffer, cbRead);
//_ASSERTE(pIn->hdr.nVersion==CESERVER_REQ_VER);
//LPBYTE ptrData = ((LPBYTE)pIn)+cbRead;
//nAllSize -= cbRead;
//while(nAllSize>0)
//{
// //_tprintf(TEXT("%s\n"), chReadBuf);
// // Break if TransactNamedPipe or ReadFile is successful
// if (fSuccess)
// break;
// // Read from the pipe if there is more data in the message.
// fSuccess = ReadFile(
// hPipe, // pipe handle
// ptrData, // buffer to receive reply
// nAllSize, // size of buffer
// &cbRead, // number of bytes read
// NULL); // not overlapped
// // Exit if an error other than ERROR_MORE_DATA occurs.
// if (!fSuccess && ((dwErr = GetLastError()) != ERROR_MORE_DATA))
// break;
// ptrData += cbRead;
// nAllSize -= cbRead;
//}
//TODO("Может возникнуть ASSERT, если консоль была закрыта в процессе чтения");
//_ASSERTE(nAllSize==0);
//if (nAllSize>0)
//{
// if (((LPVOID)cbBuffer) != ((LPVOID)pIn))
// Free(pIn);
// CloseHandle(hPipe);
// return 0; // удалось считать не все данные
//}
UINT nDataSize = pIn->hdr.cbSize - sizeof(CESERVER_REQ_HDR);
// Все данные из пайпа получены, обрабатываем команду и возвращаем (если нужно) результат
//fSuccess = WriteFile( hPipe, pOut, pOut->nSize, &cbWritten, NULL);
if (pIn->hdr.nCmd == CMD_LANGCHANGE)
{
_ASSERTE(nDataSize>=4); //-V112
// LayoutName: "00000409", "00010409", ...
// А HKL от него отличается, так что передаем DWORD
// HKL в x64 выглядит как: "0x0000000000020409", "0xFFFFFFFFF0010409"
DWORD hkl = pIn->dwData[0];
DWORD dwLastError = 0;
HKL hkl1 = NULL, hkl2 = NULL;
if (hkl)
{
WCHAR szLoc[10]; _wsprintf(szLoc, SKIPLEN(countof(szLoc)) L"%08x", hkl);
//.........这里部分代码省略.........
示例8: ExpandEnvironmentStrings
// В asDir могут быть переменные окружения.
wchar_t* CConEmuUpdate::CreateTempFile(LPCWSTR asDir, LPCWSTR asFileNameTempl, HANDLE& hFile)
{
wchar_t szFile[MAX_PATH*2+2];
wchar_t szName[128];
if (!asDir || !*asDir)
asDir = L"%TEMP%\\ConEmu";
if (!asFileNameTempl || !*asFileNameTempl)
asFileNameTempl = L"ConEmu.tmp";
if (wcschr(asDir, L'%'))
{
DWORD nExp = ExpandEnvironmentStrings(asDir, szFile, MAX_PATH);
if (!nExp || (nExp >= MAX_PATH))
{
ReportError(L"CreateTempFile.ExpandEnvironmentStrings(%s) failed, code=%u", asDir, GetLastError());
return NULL;
}
}
else
{
lstrcpyn(szFile, asDir, MAX_PATH);
}
// Checking %TEMP% for valid path
LPCWSTR pszColon1, pszColon2;
if ((pszColon1 = wcschr(szFile, L':')) != NULL)
{
if ((pszColon2 = wcschr(pszColon1+1, L':')) != NULL)
{
ReportError(L"Invalid download path (%%TEMP%% variable?)\n%s", szFile, 0);
return NULL;
}
}
int nLen = lstrlen(szFile);
if (nLen <= 0)
{
ReportError(L"CreateTempFile.asDir(%s) failed, path is null", asDir, 0);
return NULL;
}
if (szFile[nLen-1] != L'\\')
{
szFile[nLen++] = L'\\'; szFile[nLen] = 0;
}
wchar_t* pszFilePart = szFile + nLen;
wchar_t* pszDirectory = lstrdup(szFile);
LPCWSTR pszName = PointToName(asFileNameTempl);
_ASSERTE(pszName == asFileNameTempl);
if (!pszName || !*pszName || (*pszName == L'.'))
{
_ASSERTE(pszName && *pszName && (*pszName != L'.'));
pszName = L"ConEmu";
}
LPCWSTR pszExt = PointToExt(pszName);
if (pszExt == NULL)
{
_ASSERTE(pszExt != NULL);
pszExt = L".tmp";
}
lstrcpyn(szName, pszName, countof(szName)-16);
wchar_t* psz = wcsrchr(szName, L'.');
if (psz)
*psz = 0;
wchar_t* pszResult = NULL;
DWORD dwErr = 0;
for (UINT i = 0; i <= 9999; i++)
{
_wcscpy_c(pszFilePart, MAX_PATH, szName);
if (i)
_wsprintf(pszFilePart+_tcslen(pszFilePart), SKIPLEN(16) L"(%u)", i);
_wcscat_c(pszFilePart, MAX_PATH, pszExt);
hFile = CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_TEMPORARY, NULL);
//ERROR_PATH_NOT_FOUND?
if (!hFile || (hFile == INVALID_HANDLE_VALUE))
{
dwErr = GetLastError();
// на первом обломе - попытаться создать директорию, может ее просто нет?
if ((dwErr == ERROR_PATH_NOT_FOUND) && (i == 0))
{
if (!MyCreateDirectory(pszDirectory))
{
ReportError(L"CreateTempFile.asDir(%s) failed", asDir, 0);
goto wrap;
}
}
}
if (hFile && hFile != INVALID_HANDLE_VALUE)
{
psz = lstrdup(szFile);
//.........这里部分代码省略.........
示例9: ReloadFarInfoW995
BOOL ReloadFarInfoW995(/*BOOL abFull*/)
{
if (!InfoW995 || !FSFW995) return FALSE;
if (!gpFarInfo)
{
_ASSERTE(gpFarInfo!=NULL);
return FALSE;
}
// Заполнить gpFarInfo->
//BYTE nFarColors[col_LastIndex]; // Массив цветов фара
//DWORD nFarInterfaceSettings;
//DWORD nFarPanelSettings;
//DWORD nFarConfirmationSettings;
//BOOL bFarPanelAllowed, bFarLeftPanel, bFarRightPanel; // FCTL_CHECKPANELSEXIST, FCTL_GETPANELSHORTINFO,...
//CEFAR_SHORT_PANEL_INFO FarLeftPanel, FarRightPanel;
DWORD ldwConsoleMode = 0; GetConsoleMode(/*ghConIn*/GetStdHandle(STD_INPUT_HANDLE), &ldwConsoleMode);
#ifdef _DEBUG
static DWORD ldwDbgMode = 0;
if (IsDebuggerPresent())
{
if (ldwDbgMode != ldwConsoleMode)
{
wchar_t szDbg[128]; _wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"Far.ConEmuW: ConsoleMode(STD_INPUT_HANDLE)=0x%08X\n", ldwConsoleMode);
OutputDebugStringW(szDbg);
ldwDbgMode = ldwConsoleMode;
}
}
#endif
gpFarInfo->nFarConsoleMode = ldwConsoleMode;
LoadFarColorsW995(gpFarInfo->nFarColors);
//_ASSERTE(FPS_SHOWCOLUMNTITLES==0x20 && FPS_SHOWSTATUSLINE==0x40); //-V112
LoadFarSettingsW995(&gpFarInfo->FarInterfaceSettings, &gpFarInfo->FarPanelSettings);
//gpFarInfo->nFarConfirmationSettings =
// (DWORD)InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_GETCONFIRMATIONS, 0);
gpFarInfo->bMacroActive = IsMacroActiveW995();
ActlKeyMacro area = {MCMD_GETAREA};
INT_PTR nArea = InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_KEYMACRO, &area);
switch(nArea)
{
case MACROAREA_SHELL:
case MACROAREA_INFOPANEL:
case MACROAREA_QVIEWPANEL:
case MACROAREA_TREEPANEL:
case MACROAREA_SEARCH:
gpFarInfo->nMacroArea = fma_Panels;
break;
case MACROAREA_VIEWER:
gpFarInfo->nMacroArea = fma_Viewer;
break;
case MACROAREA_EDITOR:
gpFarInfo->nMacroArea = fma_Editor;
break;
case MACROAREA_DIALOG:
case MACROAREA_DISKS:
case MACROAREA_FINDFOLDER:
case MACROAREA_AUTOCOMPLETION:
case MACROAREA_MAINMENU:
case MACROAREA_MENU:
case MACROAREA_USERMENU:
gpFarInfo->nMacroArea = fma_Dialog;
break;
default:
gpFarInfo->nMacroArea = fma_Unknown;
}
gpFarInfo->bFarPanelAllowed = InfoW995->Control(PANEL_NONE, FCTL_CHECKPANELSEXIST, 0, 0);
gpFarInfo->bFarPanelInfoFilled = FALSE;
gpFarInfo->bFarLeftPanel = FALSE;
gpFarInfo->bFarRightPanel = FALSE;
// -- пока, во избежание глюков в FAR при неожиданных запросах информации о панелях
//if (FALSE == (gpFarInfo->bFarPanelAllowed)) {
// gpConMapInfo->bFarLeftPanel = FALSE;
// gpConMapInfo->bFarRightPanel = FALSE;
//} else {
// PanelInfo piA = {}, piP = {};
// BOOL lbActive = InfoW995->Control(PANEL_ACTIVE, FCTL_GETPANELINFO, 0, (LONG_PTR)&piA);
// BOOL lbPassive = InfoW995->Control(PANEL_PASSIVE, FCTL_GETPANELINFO, 0, (LONG_PTR)&piP);
// if (!lbActive && !lbPassive)
// {
// gpConMapInfo->bFarLeftPanel = FALSE;
// gpConMapInfo->bFarRightPanel = FALSE;
// } else {
// PanelInfo *ppiL = NULL;
// PanelInfo *ppiR = NULL;
// if (lbActive) {
// if (piA.Flags & PFLAGS_PANELLEFT) ppiL = &piA; else ppiR = &piA;
// }
// if (lbPassive) {
// if (piP.Flags & PFLAGS_PANELLEFT) ppiL = &piP; else ppiR = &piP;
// }
// gpConMapInfo->bFarLeftPanel = ppiL!=NULL;
// gpConMapInfo->bFarRightPanel = ppiR!=NULL;
//.........这里部分代码省略.........
示例10: PrepareHookModule
int PrepareHookModule(wchar_t (&szModule)[MAX_PATH+16])
{
int iRc = -251;
wchar_t szNewPath[MAX_PATH+16] = {}, szAddName[32] = {}, szVer[2] = {};
INT_PTR nLen = 0;
bool bAlreadyExists = false;
// Copy szModule to CSIDL_LOCAL_APPDATA and return new path
HRESULT hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szNewPath);
if ((hr != S_OK) || !*szNewPath)
{
iRc = -251;
goto wrap;
}
szVer[0] = MVV_4a[0];
_wsprintf(szAddName, SKIPLEN(countof(szAddName))
L"\\" CEDEFTERMDLLFORMAT /*L"ConEmuHk%s.%02u%02u%02u%s.dll"*/,
WIN3264TEST(L"",L"64"), MVV_1, MVV_2, MVV_3, szVer);
nLen = lstrlen(szNewPath);
if (szNewPath[nLen-1] != L'\\')
{
szNewPath[nLen++] = L'\\'; szNewPath[nLen] = 0;
}
if ((nLen + lstrlen(szAddName) + 8) >= countof(szNewPath))
{
iRc = -252;
goto wrap;
}
wcscat_c(szNewPath, L"ConEmu");
if (!DirectoryExists(szNewPath))
{
if (!CreateDirectory(szNewPath, NULL))
{
iRc = -253;
goto wrap;
}
}
wcscat_c(szNewPath, szAddName);
if ((bAlreadyExists = FileExists(szNewPath)) && FileCompare(szNewPath, szModule))
{
// OK, file exists and match the required
}
else
{
if (bAlreadyExists)
{
_ASSERTE(FALSE && "Continue to overwrite existing ConEmuHk in AppLocal");
// Try to delete or rename old version
if (!DeleteFile(szNewPath))
{
//SYSTEMTIME st; GetLocalTime(&st);
wchar_t szBakPath[MAX_PATH+32]; wcscpy_c(szBakPath, szNewPath);
wchar_t* pszExt = (wchar_t*)PointToExt(szBakPath);
msprintf(pszExt, 16, L".%u.dll", GetTickCount());
DeleteFile(szBakPath);
MoveFile(szNewPath, szBakPath);
}
}
if (!CopyFile(szModule, szNewPath, FALSE))
{
iRc = -254;
goto wrap;
}
}
wcscpy_c(szModule, szNewPath);
iRc = 0;
wrap:
return iRc;
}
示例11: _ASSERTE
//// Эта функция пайп не закрывает!
//void CGuiServer::GuiServerThreadCommand(HANDLE hPipe)
BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ* &ppReply, DWORD &pcbReplySize, DWORD &pcbMaxReplySize, LPARAM lParam)
{
BOOL lbRc = FALSE;
CGuiServer* pGSrv = (CGuiServer*)lParam;
if (!pGSrv)
{
_ASSERTE(((CGuiServer*)lParam)!=NULL);
pGSrv = &gpConEmu->m_GuiServer;
}
if (pIn->hdr.bAsync)
pGSrv->mp_GuiServer->BreakConnection(pInst);
gpSetCls->debugLogCommand(pIn, TRUE, timeGetTime(), 0, pGSrv ? pGSrv->ms_ServerPipe : NULL);
#ifdef _DEBUG
UINT nDataSize = pIn->hdr.cbSize - sizeof(CESERVER_REQ_HDR);
#endif
// Все данные из пайпа получены, обрабатываем команду и возвращаем (если нужно) результат
#ifdef ALLOW_WINE_MSG
if (gbIsWine)
{
wchar_t szMsg[128];
msprintf(szMsg, countof(szMsg), L"CGuiServer::GuiServerCommand.\nGUI TID=%u\nSrcPID=%u, SrcTID=%u, Cmd=%u",
GetCurrentThreadId(), pIn->hdr.nSrcPID, pIn->hdr.nSrcThreadId, pIn->hdr.nCmd);
MessageBox(szMsg, MB_ICONINFORMATION);
}
#endif
switch (pIn->hdr.nCmd)
{
case CECMD_NEWCMD:
{
// Приходит из другой копии ConEmu.exe, когда она запущена с ключом /single, /showhide, /showhideTSA
DEBUGSTR(L"GUI recieved CECMD_NEWCMD\n");
if (gpSetCls->isAdvLogging)
{
size_t cchAll = 120 + _tcslen(pIn->NewCmd.szConEmu) + _tcslen(pIn->NewCmd.szCurDir) + _tcslen(pIn->NewCmd.szCommand);
wchar_t* pszInfo = (wchar_t*)malloc(cchAll*sizeof(*pszInfo));
if (pszInfo)
{
_wsprintf(pszInfo, SKIPLEN(cchAll) L"CECMD_NEWCMD: Wnd=x%08X, Act=%u, ConEmu=%s, Dir=%s, Cmd=%s",
(DWORD)(DWORD_PTR)pIn->NewCmd.hFromConWnd, pIn->NewCmd.ShowHide,
pIn->NewCmd.szConEmu, pIn->NewCmd.szCurDir, pIn->NewCmd.szCommand);
gpConEmu->LogString(pszInfo);
free(pszInfo);
}
}
BOOL bAccepted = FALSE;
if (pIn->NewCmd.szConEmu[0])
{
bAccepted = (lstrcmpi(gpConEmu->ms_ConEmuExeDir, pIn->NewCmd.szConEmu) == 0);
}
else
{
bAccepted = TRUE;
}
if (bAccepted)
{
bool bCreateTab = (pIn->NewCmd.ShowHide == sih_None || pIn->NewCmd.ShowHide == sih_StartDetached);
gpConEmu->OnMinimizeRestore(bCreateTab ? sih_SetForeground : pIn->NewCmd.ShowHide);
// Может быть пусто
if (bCreateTab && pIn->NewCmd.szCommand[0])
{
RConStartArgs *pArgs = new RConStartArgs;
pArgs->bDetached = (pIn->NewCmd.ShowHide == sih_StartDetached);
pArgs->pszSpecialCmd = lstrdup(pIn->NewCmd.szCommand);
if (pIn->NewCmd.szCurDir[0] == 0)
{
_ASSERTE(pIn->NewCmd.szCurDir[0] != 0);
}
else
{
pArgs->pszStartupDir = lstrdup(pIn->NewCmd.szCurDir);
}
if (gpSet->isMulti || CVConGroup::isDetached())
{
gpConEmu->PostCreateCon(pArgs);
}
else
{
// Если хотят в одном окне - только одну консоль
gpConEmu->CreateWnd(pArgs);
SafeDelete(pArgs);
}
}
else
{
_ASSERTE(pIn->NewCmd.ShowHide==sih_ShowMinimize || pIn->NewCmd.ShowHide==sih_ShowHideTSA || pIn->NewCmd.ShowHide==sih_Show);
}
//.........这里部分代码省略.........
示例12: _tcslen
//.........这里部分代码省略.........
//}
// OK
size_t nLen = (pszExt - pszName) - lnPackPref;
wmemmove(ms_NewVersion, pszName+lnPackPref, nLen);
ms_NewVersion[nLen] = 0;
}
else if ((lstrcmpni(pszName, pszSetupPref, lnSetupPref) == 0)
&& (lstrcmpi(pszExt, L".exe") == 0)
&& (((pszExt - pszName) - lnSetupPref + 1) < sizeof(ms_NewVersion)))
{
// Must be installed with "Setupper"
if (mp_Set->UpdateDownloadSetup() != 1)
{
MBoxError(L"ConEmu was not installed with setup! Can't update!");
goto wrap;
}
// OK
size_t nLen = (pszExt - pszName) - lnSetupPref;
wmemmove(ms_NewVersion, pszName+lnSetupPref, nLen);
ms_NewVersion[nLen] = 0;
}
else
{
AssertMsg(L"Invalid asDownloadedPackage (2)");
goto wrap;
}
// Сразу проверим, как нужно будет запускаться
bNeedRunElevation = NeedRunElevation();
_wsprintf(ms_CurVersion, SKIPLEN(countof(ms_CurVersion)) L"%02u%02u%02u%s", (MVV_1%100),MVV_2,MVV_3,_T(MVV_4a));
//ms_NewVersion
// StartLocalUpdate - запуск обновления из локального пакета
mb_InetMode = false;
mb_DroppedMode = true;
pszLocalPackage = CreateTempFile(mp_Set->szUpdateDownloadPath, PointToName(asDownloadedPackage), hTarget);
if (!pszLocalPackage)
goto wrap;
lbDownloadRc = DownloadFile(asDownloadedPackage, pszLocalPackage, hTarget, nLocalCRC, TRUE);
CloseHandle(hTarget);
if (!lbDownloadRc)
goto wrap;
if (mb_RequestTerminate)
goto wrap;
pszBatchFile = CreateBatchFile(pszLocalPackage);
if (!pszBatchFile)
goto wrap;
if (!QueryConfirmation(us_ConfirmUpdate))
{
goto wrap;
}
Assert(mb_ManualCallMode==TRUE);
示例13: _ASSERTE
bool CBackgroundInfo::LoadBackgroundFile(bool abShowErrors)
{
// Пустой путь - значит БЕЗ обоев
if (!*ms_BgImage)
{
return true;
}
//_ASSERTE(isMainThread());
_ASSERTE(isMainThread());
bool lRes = false;
BY_HANDLE_FILE_INFORMATION inf = {0};
BITMAPFILEHEADER* pBkImgData = NULL;
if (wcspbrk(ms_BgImage, L"%\\.") == NULL)
{
// May be "Solid color"
COLORREF clr = (COLORREF)-1;
if (GetColorRef(ms_BgImage, &clr))
{
pBkImgData = CreateSolidImage(clr, 128, 128);
}
}
if (!pBkImgData)
{
wchar_t* exPath = ExpandEnvStr(ms_BgImage);
if (!exPath || !*exPath)
{
if (abShowErrors)
{
wchar_t szError[MAX_PATH*2];
DWORD dwErr = GetLastError();
_wsprintf(szError, SKIPLEN(countof(szError)) L"Can't expand environment strings:\r\n%s\r\nError code=0x%08X\r\nImage loading failed",
ms_BgImage, dwErr);
MBoxA(szError);
}
SafeFree(exPath);
return false;
}
pBkImgData = LoadImageEx(exPath, inf);
SafeFree(exPath);
}
if (pBkImgData)
{
ftBgModified = inf.ftLastWriteTime;
nBgModifiedTick = GetTickCount();
//NeedBackgroundUpdate();
//MSectionLock SBG; SBG.Lock(&mcs_BgImgData);
SafeFree(mp_BgImgData);
mb_IsBackgroundImageValid = true;
mp_BgImgData = pBkImgData;
lRes = true;
}
return lRes;
}
示例14: Sleep
DWORD CConEmuUpdate::CheckProcInt()
{
BOOL lbDownloadRc = FALSE, lbExecuteRc = FALSE;
LPCWSTR pszUpdateVerLocationSet = mp_Set->UpdateVerLocation();
wchar_t *pszUpdateVerLocation = NULL, *pszLocalPackage = NULL, *pszBatchFile = NULL;
bool bTempUpdateVerLocation = false;
wchar_t szSection[64], szItem[64];
wchar_t szSourceFull[1024];
wchar_t szTemplFilename[128];
wchar_t *pszSource, *pszEnd, *pszFileName;
DWORD nSrcLen, nSrcCRC, nLocalCRC = 0;
bool lbSourceLocal;
//INT_PTR nShellRc = 0;
#ifdef _DEBUG
// Чтобы успел сервер проинититься и не ругался под отладчиком...
if (!mb_ManualCallMode)
Sleep(2500);
#endif
_ASSERTE(m_UpdateStep==us_NotStarted);
m_UpdateStep = us_Check;
DeleteBadTempFiles();
//120315 - OK, положим в архив и 64битный гуй
//#ifdef _WIN64
//if (mp_Set->UpdateDownloadSetup() == 2)
//{
// if (mb_ManualCallMode)
// {
// ReportError(L"64bit versions of ConEmu may be updated with ConEmuSetup.exe only!", 0);
// }
// goto wrap;
//}
//#endif
// This implies Inet.Deinit(false) too
if (!Inet.Init(this))
{
goto wrap;
}
_wsprintf(ms_CurVersion, SKIPLEN(countof(ms_CurVersion)) L"%02u%02u%02u%s", (MVV_1%100),MVV_2,MVV_3,_T(MVV_4a));
// Загрузить информацию о файлах обновления
if (IsLocalFile(pszUpdateVerLocationSet))
{
pszUpdateVerLocation = (wchar_t*)pszUpdateVerLocationSet;
}
else
{
HANDLE hInfo = NULL;
BOOL bInfoRc;
DWORD crc;
TODO("Было бы хорошо избавиться от *ini-файла* и парсить данные в памяти");
pszUpdateVerLocation = CreateTempFile(mp_Set->szUpdateDownloadPath/*L"%TEMP%"*/, L"ConEmuVersion.ini", hInfo);
if (!pszUpdateVerLocation)
goto wrap;
bTempUpdateVerLocation = true;
bInfoRc = DownloadFile(pszUpdateVerLocationSet, pszUpdateVerLocation, hInfo, crc);
CloseHandle(hInfo);
if (!bInfoRc)
{
if (!mb_ManualCallMode)
{
DeleteFile(pszUpdateVerLocation);
SafeFree(pszUpdateVerLocation);
}
goto wrap;
}
}
// Проверить версии
_wcscpy_c(szSection, countof(szSection),
(mp_Set->isUpdateUseBuilds==1) ? sectionConEmuStable :
(mp_Set->isUpdateUseBuilds==3) ? sectionConEmuPreview
: sectionConEmuDevel);
_wcscpy_c(szItem, countof(szItem), (mp_Set->UpdateDownloadSetup()==1) ? L"location_exe" : L"location_arc");
if (!GetPrivateProfileString(szSection, L"version", L"", ms_NewVersion, countof(ms_NewVersion), pszUpdateVerLocation) || !*ms_NewVersion)
{
ReportBrokenIni(szSection, L"version", pszUpdateVerLocationSet);
goto wrap;
}
// URL may not contain file name at all, compile it (predefined)
_wsprintf(szTemplFilename, SKIPLEN(countof(szTemplFilename))
(mp_Set->UpdateDownloadSetup()==1) ? L"ConEmuSetup.%s.exe" : L"ConEmuPack.%s.7z",
ms_NewVersion);
if (!GetPrivateProfileString(szSection, szItem, L"", szSourceFull, countof(szSourceFull), pszUpdateVerLocation) || !*szSourceFull)
{
ReportBrokenIni(szSection, szItem, pszUpdateVerLocationSet);
goto wrap;
}
GetVersionsFromIni(pszUpdateVerLocation, ms_VerOnServer, ms_CurVerInfo);
//.........这里部分代码省略.........
示例15: RequestTerminate
CConEmuUpdate::~CConEmuUpdate()
{
if (mh_CheckThread)
{
DWORD nWait;
if ((nWait = WaitForSingleObject(mh_CheckThread, 0)) == WAIT_TIMEOUT)
{
RequestTerminate();
nWait = WaitForSingleObject(mh_CheckThread, UPDATETHREADTIMEOUT);
}
if (nWait != WAIT_OBJECT_0)
{
TerminateThread(mh_CheckThread, 100);
}
CloseHandle(mh_CheckThread);
mh_CheckThread = NULL;
}
//if (mh_StopThread)
//{
// CloseHandle(mh_StopThread);
// mh_StopThread = NULL;
//}
DeleteBadTempFiles();
Inet.Deinit(true);
SafeFree(ms_LastErrorInfo);
if (mp_LastErrorSC)
{
delete mp_LastErrorSC;
mp_LastErrorSC = NULL;
}
if (m_UpdateStep == us_ExitAndUpdate && mpsz_PendingBatchFile)
{
WaitAllInstances();
wchar_t *pszCmd = lstrdup(L"cmd.exe"); // Мало ли что в ComSpec пользователь засунул...
size_t cchParmMax = lstrlen(mpsz_PendingBatchFile)+16;
wchar_t *pszParm = (wchar_t*)calloc(cchParmMax,sizeof(*pszParm));
// Обязательно двойное окавычивание. cmd.exe отбрасывает кавычки,
// и при наличии разделителей (пробелы, скобки,...) получаем проблемы
_wsprintf(pszParm, SKIPLEN(cchParmMax) L"/c \"\"%s\"\"", mpsz_PendingBatchFile);
// Наверное на Elevated процесс это не распространится, но для четкости - взведем флажок
SetEnvironmentVariable(ENV_CONEMU_INUPDATE, ENV_CONEMU_INUPDATE_YES);
// ghWnd уже закрыт
INT_PTR nShellRc = (INT_PTR)ShellExecute(NULL, bNeedRunElevation ? L"runas" : L"open", pszCmd, pszParm, NULL, SW_SHOWMINIMIZED);
if (nShellRc <= 32)
{
wchar_t szErrInfo[MAX_PATH*4];
_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
L"Failed to start update batch\n%s\nError code=%i", mpsz_PendingBatchFile, (int)nShellRc);
MessageBoxW(NULL, szErrInfo, L"ConEmu", MB_ICONSTOP|MB_SYSTEMMODAL);
DeleteFile(mpsz_PendingBatchFile);
if (!(mp_Set && mp_Set->isUpdateLeavePackages))
DeleteFile(mpsz_PendingPackageFile);
}
SafeFree(pszCmd);
SafeFree(pszParm);
}
SafeFree(mpsz_PendingBatchFile);
SafeFree(mpsz_PendingPackageFile);
if (mp_Set)
{
delete mp_Set;
mp_Set = NULL;
}
}