本文整理汇总了C++中countof函数的典型用法代码示例。如果您正苦于以下问题:C++ countof函数的具体用法?C++ countof怎么用?C++ countof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了countof函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: START_TEST
END_TEST
START_TEST(test_syllable_iterator)
{
ucschar str[] = {
// L L V V T T
0x1107, 0x1107, 0x116e, 0x1166, 0x11af, 0x11a8, // 0
// L V T
0x1108, 0x1170, 0x11b0, // 6
// L L V V T T M
0x1107, 0x1107, 0x116e, 0x1166, 0x11af, 0x11a8, 0x302E, // 9
// L V T M
0x1108, 0x1170, 0x11b0, 0x302F, // 16
// Lf V
0x115f, 0x1161, // 20
// L Vf
0x110c, 0x1160, // 22
// L LVT T
0x1107, 0xbc14, 0x11a8, // 24
// L LV T
0x1100, 0xac00, 0x11a8, // 27
// LVT
0xc00d, // 30
// other
'a', // 31
0 // 32
};
const ucschar* begin = str;
const ucschar* end = str + countof(str) - 1;
const ucschar* s = str;
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 6,
"error: next syllable: L L V V T T");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 9,
"error: next syllable: L V T");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 16,
"error: next syllable: L L V V T T M");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 20,
"error: next syllable: L V T M");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 22,
"error: next syllable: Lf V");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 24,
"error: next syllable: L Vf");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 27,
"error: next syllable: L LVT T");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 30,
"error: next syllable: L LV T");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 31,
"error: next syllable: LVT");
s = hangul_syllable_iterator_next(s, end);
fail_unless(s - str == 32,
"error: next syllable: other");
s = end;
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 31,
"error: prev syllable: other");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 30,
"error: prev syllable: LVT");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 27,
"error: prev syllable: L LV T");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 24,
"error: prev syllable: L LVT T");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 22,
"error: prev syllable: L Vf");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 20,
"error: prev syllable: Lf V");
s = hangul_syllable_iterator_prev(s, begin);
fail_unless(s - str == 16,
"error: prev syllable: L V T M");
//.........这里部分代码省略.........
开发者ID:tizenorg,项目名称:framework.uifw.libhangul,代码行数:101,代码来源:test.c
示例2: g_RegisterCrossSvScript
BOOL g_RegisterCrossSvScript()
{
return g_cScriptManager.RegisterTableFuncs("KCrossSv", KCrossSvScript::arFunction, countof(KCrossSvScript::arFunction));
}
开发者ID:github188,项目名称:yol,代码行数:4,代码来源:kcrossservscript.cpp
示例3: CpiSubscriptionsVerifyInstall
HRESULT CpiSubscriptionsVerifyInstall(
CPI_SUBSCRIPTION_LIST* pList
)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
ICatalogObject* piSubsObj = NULL;
for (CPI_SUBSCRIPTION* pItm = pList->pFirst; pItm; pItm = pItm->pNext)
{
// subscriptions that are being installed
if (!WcaIsInstalling(pItm->isInstalled, pItm->isAction))
continue;
// subscription is supposed to exist
if (CpiIsInstalled(pItm->isInstalled))
{
// if we don't have an id
if (!*pItm->wzID)
{
// find subscriptions with conflicting name
hr = FindObjectForSubscription(pItm, FALSE, TRUE, &piSubsObj);
ExitOnFailure(hr, "Failed to find collection object for subscription");
// if the subscription was found
if (S_OK == hr)
{
// get id from subscription object
hr = CpiGetKeyForObject(piSubsObj, pItm->wzID, countof(pItm->wzID));
ExitOnFailure(hr, "Failed to get id");
}
// if the subscription was not found
else
{
// create a new id
hr = CpiCreateId(pItm->wzID, countof(pItm->wzID));
ExitOnFailure(hr, "Failed to create id");
}
}
}
// subscription is supposed to be created
else
{
// check for conflicts
do {
if (*pItm->wzID)
{
// find subscriptions with conflicting id
hr = FindObjectForSubscription(pItm, TRUE, FALSE, &piSubsObj);
ExitOnFailure(hr, "Failed to find collection object for subscription");
if (S_FALSE == hr)
{
// find subscriptions with conflicting name
hr = FindObjectForSubscription(pItm, FALSE, TRUE, &piSubsObj);
ExitOnFailure(hr, "Failed to find collection object for subscription");
if (S_OK == hr)
// "A subscription with a conflictiong name exists. retry cancel"
er = WcaErrorMessage(msierrComPlusSubscriptionNameConflict, hr, INSTALLMESSAGE_ERROR | MB_RETRYCANCEL, 0);
else
break; // no conflicting entry found, break loop
}
else
// "A subscription with a conflicting id exists. abort retry ignore"
er = WcaErrorMessage(msierrComPlusSubscriptionIdConflict, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0);
}
else
{
// find subscriptions with conflicting name
hr = FindObjectForSubscription(pItm, FALSE, TRUE, &piSubsObj);
ExitOnFailure(hr, "Failed to find collection object for subscription");
if (S_OK == hr)
// "A subscription with a conflictiong name exists. abort retry ignore"
er = WcaErrorMessage(msierrComPlusSubscriptionNameConflict, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0);
else
break; // no conflicting entry found, break loop
}
switch (er)
{
case IDCANCEL:
case IDABORT:
ExitOnFailure1(hr = E_FAIL, "A subscription with a conflictiong name or id exists, key: %S", pItm->wzKey);
break;
case IDRETRY:
break;
case IDIGNORE:
default:
// if we don't have an id, copy id from object
if (!*pItm->wzID)
{
hr = CpiGetKeyForObject(piSubsObj, pItm->wzID, countof(pItm->wzID));
ExitOnFailure(hr, "Failed to get id");
}
hr = S_FALSE; // indicate that this is not a conflict
//.........这里部分代码省略.........
开发者ID:AnalogJ,项目名称:Wix3.6Toolset,代码行数:101,代码来源:cpsubssched.cpp
示例4: HANDLE
MConHandle::operator const HANDLE()
{
if (mpp_OutBuffer && *mpp_OutBuffer && (*mpp_OutBuffer != INVALID_HANDLE_VALUE))
{
LogHandle(Event::e_GetHandlePtr, *mpp_OutBuffer);
return *mpp_OutBuffer;
}
if (mh_Handle == INVALID_HANDLE_VALUE)
{
if (mn_StdMode)
{
mh_Handle = GetStdHandle(mn_StdMode);
LogHandle(Event::e_CreateHandleStd, mh_Handle);
}
else
{
// Чтобы случайно не открыть хэндл несколько раз в разных потоках
MSectionLock CS; CS.Lock(&mcs_Handle, TRUE);
// Во время ожидания хэндл мог быт открыт в другом потоке
if (mh_Handle == INVALID_HANDLE_VALUE)
{
mh_Handle = CreateFileW(ms_Name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (mh_Handle != INVALID_HANDLE_VALUE)
{
mb_OpenFailed = FALSE;
}
else
{
mn_LastError = GetLastError();
if (!mb_OpenFailed)
{
mb_OpenFailed = TRUE; // чтобы ошибка вываливалась только один раз!
char szErrMsg[512], szNameA[10], szSelfFull[MAX_PATH];
const char *pszSelf;
char *pszDot;
if (!GetModuleFileNameA(0,szSelfFull,MAX_PATH))
{
pszSelf = "???";
}
else
{
pszSelf = strrchr(szSelfFull, '\\');
if (pszSelf) pszSelf++; else pszSelf = szSelfFull;
pszDot = strrchr((char*)pszSelf, '.');
if (pszDot) *pszDot = 0;
}
WideCharToMultiByte(CP_OEMCP, 0, ms_Name, -1, szNameA, sizeof(szNameA), 0,0);
_wsprintfA(szErrMsg, SKIPLEN(countof(szErrMsg)) "%s: CreateFile(%s) failed, ErrCode=0x%08X\n", pszSelf, szNameA, mn_LastError);
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (h && h!=INVALID_HANDLE_VALUE)
{
DWORD dwWritten = 0;
WriteFile(h, szErrMsg, lstrlenA(szErrMsg), &dwWritten, 0);
}
}
}
LogHandle(Event::e_CreateHandle, mh_Handle);
}
}
}
LogHandle(Event::e_GetHandle, mh_Handle);
return mh_Handle;
};
开发者ID:1833183060,项目名称:ConEmu,代码行数:75,代码来源:MConHandle.cpp
示例5: DoInjectHooks
int DoInjectHooks(LPWSTR asCmdArg)
{
gbInShutdown = TRUE; // чтобы не возникло вопросов при выходе
gnRunMode = RM_SETHOOK64;
LPWSTR pszNext = asCmdArg;
LPWSTR pszEnd = NULL;
BOOL lbForceGui = FALSE;
PROCESS_INFORMATION pi = {NULL};
pi.hProcess = (HANDLE)wcstoul(pszNext, &pszEnd, 16);
if (pi.hProcess && pszEnd && *pszEnd)
{
pszNext = pszEnd+1;
pi.dwProcessId = wcstoul(pszNext, &pszEnd, 10);
}
if (pi.dwProcessId && pszEnd && *pszEnd)
{
pszNext = pszEnd+1;
pi.hThread = (HANDLE)wcstoul(pszNext, &pszEnd, 16);
}
if (pi.hThread && pszEnd && *pszEnd)
{
pszNext = pszEnd+1;
pi.dwThreadId = wcstoul(pszNext, &pszEnd, 10);
}
if (pi.dwThreadId && pszEnd && *pszEnd)
{
pszNext = pszEnd+1;
lbForceGui = wcstoul(pszNext, &pszEnd, 10);
}
#ifdef SHOW_INJECT_MSGBOX
wchar_t szDbgMsg[512], szTitle[128];
PROCESSENTRY32 pinf;
GetProcessInfo(pi.dwProcessId, &pinf);
_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuCD PID=%u", GetCurrentProcessId());
_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"InjectsTo PID=%s {%s}\nConEmuCD PID=%u", asCmdArg ? asCmdArg : L"", pinf.szExeFile, GetCurrentProcessId());
MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
#endif
if (pi.hProcess && pi.hThread && pi.dwProcessId && pi.dwThreadId)
{
// Аргумент abForceGui не использовался
CINJECTHK_EXIT_CODES iHookRc = InjectHooks(pi, /*lbForceGui,*/ gbLogProcess);
if (iHookRc == CIH_OK/*0*/)
{
return CERR_HOOKS_WAS_SET;
}
// Ошибку (пока во всяком случае) лучше показать, для отлова возможных проблем
DWORD nErrCode = GetLastError();
//_ASSERTE(iHookRc == 0); -- ассерт не нужен, есть MsgBox
wchar_t szDbgMsg[255], szTitle[128];
_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuC[%u], PID=%u", WIN3264TEST(32,64), GetCurrentProcessId());
_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"ConEmuC.X, PID=%u\nInjecting hooks into PID=%u\nFAILED, code=%i:0x%08X", GetCurrentProcessId(), pi.dwProcessId, iHookRc, nErrCode);
MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
}
else
{
//_ASSERTE(pi.hProcess && pi.hThread && pi.dwProcessId && pi.dwThreadId);
wchar_t szDbgMsg[512], szTitle[128];
_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuC, PID=%u", GetCurrentProcessId());
_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"ConEmuC.X, PID=%u\nCmdLine parsing FAILED (%u,%u,%u,%u,%u)!\n%s",
GetCurrentProcessId(), LODWORD(pi.hProcess), LODWORD(pi.hThread), pi.dwProcessId, pi.dwThreadId, lbForceGui, //-V205
asCmdArg);
MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
}
return CERR_HOOKS_FAILED;
}
开发者ID:ForNeVeR,项目名称:ConEmu,代码行数:78,代码来源:Actions.cpp
示例6:
#include "mui.h"
#include "printer.h"
#include "uiprinter.h"
#include "intl.h"
#include "translate.h"
static video_canvas_t *printer_canvas;
static int ui_printer_enable_translate[] = {
IDMS_DISABLED,
IDS_ENABLED,
0
};
static char *ui_printer_enable[countof(ui_printer_enable_translate)];
static const int ui_printer_enable_values[] = {
0,
1,
-1
};
static int ui_printer_emulation_translate[] = {
IDS_NONE,
IDS_FILESYSTEM,
0
};
static char *ui_printer_emulation[countof(ui_printer_emulation_translate)];
开发者ID:c64scene-ar,项目名称:c64f3,代码行数:30,代码来源:uiprinter.c
示例7: if
bool GSDevice11::Create(GSWnd* wnd)
{
if(!__super::Create(wnd))
{
return false;
}
HRESULT hr = E_FAIL;
DXGI_SWAP_CHAIN_DESC scd;
D3D11_BUFFER_DESC bd;
D3D11_SAMPLER_DESC sd;
D3D11_DEPTH_STENCIL_DESC dsd;
D3D11_RASTERIZER_DESC rd;
D3D11_BLEND_DESC bsd;
CComPtr<IDXGIAdapter1> adapter;
D3D_DRIVER_TYPE driver_type = D3D_DRIVER_TYPE_HARDWARE;
std::string adapter_id = theApp.GetConfig("Adapter", "default");
if (adapter_id == "default")
;
else if (adapter_id == "ref")
{
driver_type = D3D_DRIVER_TYPE_REFERENCE;
}
else
{
CComPtr<IDXGIFactory1> dxgi_factory;
CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&dxgi_factory);
if (dxgi_factory)
for (int i = 0;; i++)
{
CComPtr<IDXGIAdapter1> enum_adapter;
if (S_OK != dxgi_factory->EnumAdapters1(i, &enum_adapter))
break;
DXGI_ADAPTER_DESC1 desc;
hr = enum_adapter->GetDesc1(&desc);
if (S_OK == hr && GSAdapter(desc) == adapter_id)
{
adapter = enum_adapter;
driver_type = D3D_DRIVER_TYPE_UNKNOWN;
break;
}
}
}
memset(&scd, 0, sizeof(scd));
scd.BufferCount = 2;
scd.BufferDesc.Width = 1;
scd.BufferDesc.Height = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
//scd.BufferDesc.RefreshRate.Numerator = 60;
//scd.BufferDesc.RefreshRate.Denominator = 1;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.OutputWindow = (HWND)m_wnd->GetHandle();
scd.SampleDesc.Count = 1;
scd.SampleDesc.Quality = 0;
// Always start in Windowed mode. According to MS, DXGI just "prefers" this, and it's more or less
// required if we want to add support for dual displays later on. The fullscreen/exclusive flip
// will be issued after all other initializations are complete.
scd.Windowed = TRUE;
spritehack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_SpriteHack", 0) : 0;
// NOTE : D3D11_CREATE_DEVICE_SINGLETHREADED
// This flag is safe as long as the DXGI's internal message pump is disabled or is on the
// same thread as the GS window (which the emulator makes sure of, if it utilizes a
// multithreaded GS). Setting the flag is a nice and easy 5% speedup on GS-intensive scenes.
uint32 flags = D3D11_CREATE_DEVICE_SINGLETHREADED;
#ifdef DEBUG
flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL level;
const D3D_FEATURE_LEVEL levels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
hr = D3D11CreateDeviceAndSwapChain(adapter, driver_type, NULL, flags, levels, countof(levels), D3D11_SDK_VERSION, &scd, &m_swapchain, &m_dev, &level, &m_ctx);
if(FAILED(hr)) return false;
if(!SetFeatureLevel(level, true))
{
return false;
}
D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options;
hr = m_dev->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &options, sizeof(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS));
//.........这里部分代码省略.........
开发者ID:Asmodean-,项目名称:pcsx2,代码行数:101,代码来源:GSDevice11.cpp
示例8: _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
DEBUGSTRCMD(L"GUI recieved CECMD_NEWCMD\n");
if (pIn->NewCmd.isAdvLogging && !gpSetCls->isAdvLogging)
{
gpSetCls->isAdvLogging = pIn->NewCmd.isAdvLogging;
gpConEmu->CreateLog();
}
if (gpSetCls->isAdvLogging && (pIn->NewCmd.isAdvLogging > gpSetCls->isAdvLogging))
{
wchar_t szLogLevel[80];
_wsprintf(szLogLevel, SKIPLEN(countof(szLogLevel)) L"Changing log level! Old=%u, New=%u", (UINT)gpSetCls->isAdvLogging, (UINT)pIn->NewCmd.isAdvLogging);
gpConEmu->LogString(szLogLevel);
gpSetCls->isAdvLogging = pIn->NewCmd.isAdvLogging;
}
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)
// Issue 1275: When minimized into TSA (on all VCon are closed) we need to restore and run new tab
|| (pIn->NewCmd.szCommand[0] && !CVConGroup::isVConExists(0));
gpConEmu->DoMinimizeRestore(bCreateTab ? sih_SetForeground : pIn->NewCmd.ShowHide);
// Может быть пусто
if (bCreateTab && pIn->NewCmd.szCommand[0])
{
RConStartArgs *pArgs = new RConStartArgs;
pArgs->Detached = (pIn->NewCmd.ShowHide == sih_StartDetached) ? crb_On : crb_Off;
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);
}
//.........这里部分代码省略.........
开发者ID:G-VAR,项目名称:ConEmu,代码行数:101,代码来源:GuiServer.cpp
示例9: MyAssertDumpToFile
void MyAssertDumpToFile(const wchar_t* pszFile, int nLine, const wchar_t* pszTest)
{
wchar_t dmpfile[MAX_PATH+64] = L"", szVer4[8] = L"", szLine[64];
typedef HRESULT (WINAPI* SHGetFolderPath_t)(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
HMODULE hShell = LoadLibrary(L"shell32.dll");
SHGetFolderPath_t shGetFolderPath = hShell ? (SHGetFolderPath_t)GetProcAddress(hShell, "SHGetFolderPathW") : NULL;
HRESULT hrc = shGetFolderPath ? shGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0/*SHGFP_TYPE_CURRENT*/, dmpfile) : E_FAIL;
if (hShell) FreeLibrary(hShell);
if (FAILED(hrc))
{
memset(dmpfile, 0, sizeof(dmpfile));
if (!GetTempPath(MAX_PATH, dmpfile) || !*dmpfile)
{
//pszError = L"CreateDumpForReport called, get desktop or temp folder failed";
return;
}
}
wcscat_c(dmpfile, (*dmpfile && dmpfile[lstrlen(dmpfile)-1] != L'\\') ? L"\\ConEmuTrap" : L"ConEmuTrap");
CreateDirectory(dmpfile, NULL);
int nLen = lstrlen(dmpfile);
lstrcpyn(szVer4, _T(MVV_4a), countof(szVer4));
static LONG snAutoIndex = 0;
LONG nAutoIndex = InterlockedIncrement(&snAutoIndex);
msprintf(dmpfile+nLen, countof(dmpfile)-nLen, L"\\Assert-%02u%02u%02u%s-%u-%u.txt", MVV_1, MVV_2, MVV_3, szVer4, GetCurrentProcessId(), nAutoIndex);
HANDLE hFile = CreateFile(dmpfile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
//pszError = L"Failed to create dump file";
return;
}
DWORD nWrite;
msprintf(szLine, countof(szLine), L"CEAssert PID=%u TID=%u\r\nAssertion in ", GetCurrentProcessId(), GetCurrentThreadId());
WriteFile(hFile, szLine, (nWrite = lstrlen(szLine)*2), &nWrite, NULL);
if (!GetModuleFileNameW(NULL, dmpfile, countof(dmpfile)-2))
lstrcpyn(dmpfile, L"<unknown>\r\n", countof(dmpfile));
else
wcscat_c(dmpfile, L"\r\n");
WriteFile(hFile, dmpfile, (nWrite = lstrlen(dmpfile)*2), &nWrite, NULL);
// File.cpp: 123\r\n
if (pszFile)
{
WriteFile(hFile, pszFile, (nWrite = lstrlen(pszFile)*2), &nWrite, NULL);
msprintf(szLine, countof(szLine), L": %i\r\n\r\n", nLine);
WriteFile(hFile, szLine, (nWrite = lstrlen(szLine)*2), &nWrite, NULL);
}
if (pszTest)
{
WriteFile(hFile, pszTest, (nWrite = lstrlen(pszTest)*2), &nWrite, NULL);
WriteFile(hFile, L"\r\n", 4, &nWrite, NULL);
}
CloseHandle(hFile);
}
开发者ID:EmuxEvans,项目名称:ConEmu,代码行数:61,代码来源:MAssert.cpp
示例10: NextPbo
void NextPbo() {
m_current_pbo = (m_current_pbo + 1) & (countof(m_pool)-1);
// Mark new PBO as free
m_offset[m_current_pbo] = 0;
}
开发者ID:adamantike,项目名称:pcsx2,代码行数:5,代码来源:GSTextureOGL.cpp
示例11:
#include "mui.h"
#include "drive.h"
#include "uidrivepetcbm2.h"
#include "intl.h"
#include "translate.h"
static int drive_number_strings_translate[] = {
IDMS_DRIVE_8,
IDMS_DRIVE_9,
IDMS_DRIVE_10,
IDMS_DRIVE_11,
0
};
static char *drive_number_strings[countof(drive_number_strings_translate)];
static int drive_type_strings_translate[] = {
IDS_NONE,
-1
};
static char *drive_type_strings_8[] = {
NULL, /* "None" placeholder */
"2031",
"2040",
"3040",
"4040",
"1001",
"8050",
"8250",
开发者ID:AreaScout,项目名称:vice,代码行数:31,代码来源:uidrivepetcbm2.c
示例12: Filenames_Init
//-----------------------------------------------------------------------------
// Initialize filenames of various path/files (configuration files, etc).
// FIXME-BUFFER: Potential buffer overflows here.
//-----------------------------------------------------------------------------
void Filenames_Init()
{
// Get and save current directory
getcwd(g_env.Paths.StartingDirectory, countof(g_env.Paths.StartingDirectory));
// Find emulator directory --------------------------------------------------
#if defined(ARCH_MACOSX)
GetResourcePath( g_env.Paths.EmulatorDirectory, sizeof(g_env.Paths.EmulatorDirectory) );
ConsolePrintf ("Resource path = %s\n", g_env.Paths.EmulatorDirectory);
#else
strcpy(g_env.Paths.EmulatorDirectory, g_env.argv[0]);
#ifdef ARCH_WIN32
StrReplace(g_env.Paths.EmulatorDirectory, '\\', '/');
#endif
char* p = strrchr(g_env.Paths.EmulatorDirectory, '/');
if (p)
*p = EOSTR;
else
strcpy(g_env.Paths.EmulatorDirectory, g_env.Paths.StartingDirectory);
#endif
#if defined(ARCH_UNIX) || defined(ARCH_MACOSX)
char* rp = realpath(g_env.Paths.EmulatorDirectory, NULL);
if (rp != NULL)
{
strcpy(g_env.Paths.EmulatorDirectory, rp);
//strcat(g_env.Paths.EmulatorDirectory, "/");
free(rp);
}
#endif
char data_dir[FILENAME_LEN];
char internal_resources_dir[FILENAME_LEN];
char external_resources_dir[FILENAME_LEN];
strcpy(data_dir, g_env.Paths.EmulatorDirectory);
#ifdef ARCH_MACOSX
GetWritableInternalResourcePath( internal_resources_dir, sizeof(internal_resources_dir) );
GetWritableExternalResourcePath( external_resources_dir, sizeof(external_resources_dir) );
const char* files_to_copy_internal_resources[2] =
{
"meka.inp",
NULL
};
PopulateWritableInternalResourcesPath(internal_resources_dir, files_to_copy_internal_resources);
#else
strcpy(internal_resources_dir, g_env.Paths.EmulatorDirectory);
strcpy(external_resources_dir, g_env.Paths.EmulatorDirectory);
#endif
//ConsolePrintf("Data Directory = %s\n", data_dir);
//ConsolePrintf("Internal Writable Resources Directory = %s\n", internal_resources_dir);
//ConsolePrintf("External Writable Resources Directory = %s\n", external_resources_dir);
// Datafiles
sprintf(g_env.Paths.DataFile, "%s/meka.dat", data_dir);
sprintf(g_env.Paths.DataBaseFile, "%s/meka.nam", data_dir);
sprintf(g_env.Paths.SkinFile, "%s/meka.thm", data_dir);
sprintf(Patches.filename, "%s/meka.pat", data_dir);
sprintf(Blitters.filename, "%s/meka.blt", data_dir);
sprintf(Messages.FileName, "%s/meka.msg", data_dir);
// files that are written to
sprintf(Desktop.filename, "%s/meka.dsk", internal_resources_dir);
sprintf(VLFN_DataBase.filename, "%s/meka.fdb", internal_resources_dir);
sprintf(Inputs.FileName, "%s/meka.inp", internal_resources_dir);
// Documentations
sprintf(g_env.Paths.DocumentationMain, "%s/meka.txt", data_dir);
sprintf(g_env.Paths.DocumentationCompat, "%s/compat.txt", data_dir);
sprintf(g_env.Paths.DocumentationMulti, "%s/multi.txt", data_dir);
sprintf(g_env.Paths.DocumentationChanges, "%s/changes.txt", data_dir);
sprintf(g_env.Paths.DocumentationDebugger, "%s/debugger.txt", data_dir);
// Configuration file
#ifdef ARCH_WIN32
sprintf(g_env.Paths.ConfigurationFile, "%s/mekaw.cfg", g_env.Paths.EmulatorDirectory);
#else /* unix */
sprintf(g_env.Paths.ConfigurationFile, "%s/meka.cfg", internal_resources_dir);
#endif
// Directories
sprintf(g_env.Paths.ScreenshotDirectory, "%s/Screenshots", external_resources_dir);
sprintf(g_env.Paths.SavegameDirectory, "%s/Saves", external_resources_dir);
sprintf(g_env.Paths.MusicDirectory, "%s/Music", external_resources_dir);
sprintf(g_env.Paths.DebugDirectory, "%s/Debug", external_resources_dir);
// ROM
strcpy(g_env.Paths.MediaImageFile, "");
strcpy(g_env.Paths.BatteryBackedMemoryFile, "");
}
开发者ID:maxim-zhao,项目名称:meka,代码行数:96,代码来源:file.cpp
示例13: CabExtractCallback
static __callback INT_PTR DIAMONDAPI CabExtractCallback(__in FDINOTIFICATIONTYPE iNotification, __inout FDINOTIFICATION *pFDINotify)
{
Assert(pFDINotify->pv);
HRESULT hr = S_OK;
INT_PTR ipResult = 0; // result to return on success
CAB_CALLBACK_STRUCT* pccs = static_cast<CAB_CALLBACK_STRUCT*>(pFDINotify->pv);
LPCSTR sz;
WCHAR wz[MAX_PATH];
FILETIME ft;
switch (iNotification)
{
case fdintCOPY_FILE: // begin extracting a resource from cabinet
ExitOnNull(pFDINotify->psz1, hr, E_INVALIDARG, "No cabinet file ID given to convert");
ExitOnNull(pccs, hr, E_INVALIDARG, "Failed to call cabextract callback, because no callback struct was provided");
if (pccs->fStopExtracting)
{
ExitFunction1(hr = S_FALSE); // no more extracting
}
// convert params to useful variables
sz = static_cast<LPCSTR>(pFDINotify->psz1);
if (!::MultiByteToWideChar(CP_ACP, 0, sz, -1, wz, countof(wz)))
{
ExitWithLastError1(hr, "failed to convert cabinet file id to unicode: %s", sz);
}
if (pccs->pfnProgress)
{
hr = pccs->pfnProgress(TRUE, wz, pccs->pvContext);
if (S_OK != hr)
{
ExitFunction();
}
}
if (L'*' == *pccs->pwzExtract || 0 == lstrcmpW(pccs->pwzExtract, wz))
{
// get the created date for the resource in the cabinet
FILETIME ftLocal;
if (!::DosDateTimeToFileTime(pFDINotify->date, pFDINotify->time, &ftLocal))
{
ExitWithLastError1(hr, "failed to get time for resource: %ls", wz);
}
::LocalFileTimeToFileTime(&ftLocal, &ft);
WCHAR wzPath[MAX_PATH];
hr = ::StringCchCopyW(wzPath, countof(wzPath), pccs->pwzExtractDir);
ExitOnFailure2(hr, "failed to copy in extract directory: %ls for file: %ls", pccs->pwzExtractDir, wz);
hr = ::StringCchCatW(wzPath, countof(wzPath), wz);
ExitOnFailure2(hr, "failed to concat onto path: %ls file: %ls", wzPath, wz);
ipResult = reinterpret_cast<INT_PTR>(::CreateFileW(wzPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
if (INVALID_HANDLE_VALUE == reinterpret_cast<HANDLE>(ipResult))
{
ExitWithLastError1(hr, "failed to create file: %s", wzPath);
}
::SetFileTime(reinterpret_cast<HANDLE>(ipResult), &ft, &ft, &ft); // try to set the file time (who cares if it fails)
if (::SetFilePointer(reinterpret_cast<HANDLE>(ipResult), pFDINotify->cb, NULL, FILE_BEGIN)) // try to set the end of the file (don't worry if this fails)
{
if (::SetEndOfFile(reinterpret_cast<HANDLE>(ipResult)))
{
::SetFilePointer(reinterpret_cast<HANDLE>(ipResult), 0, NULL, FILE_BEGIN); // reset the file pointer
}
}
}
else // resource wasn't requested, skip it
{
hr = S_OK;
ipResult = 0;
}
break;
case fdintCLOSE_FILE_INFO: // resource extraction complete
Assert(pFDINotify->hf && pFDINotify->psz1);
ExitOnNull(pccs, hr, E_INVALIDARG, "Failed to call cabextract callback, because no callback struct was provided");
// convert params to useful variables
sz = static_cast<LPCSTR>(pFDINotify->psz1);
ExitOnNull(sz, hr, E_INVALIDARG, "Failed to convert cabinet file id, because no cabinet file id was provided");
if (!::MultiByteToWideChar(CP_ACP, 0, sz, -1, wz, countof(wz)))
{
ExitWithLastError1(hr, "failed to convert cabinet file id to unicode: %s", sz);
}
if (NULL != pFDINotify->hf) // just close the file
{
::CloseHandle(reinterpret_cast<HANDLE>(pFDINotify->hf));
}
if (pccs->pfnProgress)
{
hr = pccs->pfnProgress(FALSE, wz, pccs->pvContext);
//.........这里部分代码省略.........
开发者ID:BMurri,项目名称:wix3,代码行数:101,代码来源:cabutil.cpp
示例14: normalized
/********************************************************************
CabOperation - helper function that enumerates or extracts files
from cabinet
NOTE: wzCabinet must be full path to cabinet file
wzExtractFile can be a single file id or "*" to extract all files
wzExttractDir must be normalized (end in a "\")
if pfnBeginFile is NULL pfnEndFile must be NULL and vice versa
pfnNotify is callback function to get notified for each file
in the cabinet. If it's NULL, files will be extracted.
********************************************************************/
static HRESULT DAPI CabOperation(
__in LPCWSTR wzCabinet,
__in LPCWSTR wzExtractFile,
__in_opt LPCWSTR wzExtractDir,
__in_opt CAB_CALLBACK_PROGRESS pfnProgress,
__in_opt LPVOID pvContext,
__in_opt STDCALL_PFNFDINOTIFY pfnNotify,
__in DWORD64 dw64EmbeddedOffset
)
{
HRESULT hr = S_OK;
BOOL fResult;
LPWSTR sczCabinet = NULL;
LPWSTR pwz = NULL;
CHAR szCabDirectory[MAX_PATH * 4]; // Make sure these are big enough for UTF-8 strings
CHAR szCabFile[MAX_PATH * 4];
CAB_CALLBACK_STRUCT ccs;
PFNFDINOTIFY pfnFdiNotify;
//
// ensure the cabinet.dll is loaded
//
if (!vhfdi)
{
hr = LoadCabinetDll();
ExitOnFailure(hr, "failed to load CABINET.DLL");
}
hr = StrAllocString(&sczCabinet, wzCabinet, 0);
ExitOnFailure1(hr, "Failed to make copy of cabinet name:%ls", wzCabinet);
//
// split the cabinet full path into directory and filename and convert to multi-byte (ick!)
//
pwz = FileFromPath(sczCabinet);
ExitOnNull1(pwz, hr, E_INVALIDARG, "failed to process cabinet path: %ls", wzCabinet);
if (!::WideCharToMultiByte(CP_UTF8, 0, pwz, -1, szCabFile, countof(szCabFile), NULL, NULL))
{
ExitWithLastError1(hr, "failed to convert cabinet filename to ASCII: %ls", pwz);
}
*pwz = '\0';
// If a full path was not provided, use the relative current directory.
if (wzCabinet == pwz)
{
hr = ::StringCchCopyA(szCabDirectory, countof(szCabDirectory), ".\\");
ExitOnFailure(hr, "Failed to copy relative current directory as cabinet directory.");
}
else
{
if (!::WideCharToMultiByte(CP_UTF8, 0, sczCabinet, -1, szCabDirectory, countof(szCabDirectory), NULL, NULL))
{
ExitWithLastError1(hr, "failed to convert cabinet directory to ASCII: %ls", sczCabinet);
}
}
//
// iterate through files in cabinet extracting them to the callback function
//
ccs.fStopExtracting = FALSE;
ccs.pwzExtract = wzExtractFile;
ccs.pwzExtractDir = wzExtractDir;
ccs.pfnProgress = pfnProgress;
ccs.pvContext = pvContext;
vdw64EmbeddedOffset = dw64EmbeddedOffset;
// if pfnNotify is given, use it, otherwise use default callback
if (NULL == pfnNotify)
{
pfnFdiNotify = CabExtractCallback;
}
else
{
v_pfnNetFx11Notify = pfnNotify;
pfnFdiNotify = FDINotify;
}
fResult = vpfnFDICopy(vhfdi, szCabFile, szCabDirectory, 0, pfnFdiNotify, NULL, static_cast<void*>(&ccs));
if (!fResult && !ccs.fStopExtracting) // if something went wrong and it wasn't us just stopping the extraction, then return a failure
{
ExitWithLastError1(hr, "failed to extract cabinet file: %ls", sczCabinet);
}
LExit:
ReleaseStr(sczCabinet);
//.........这里部分代码省略.........
开发者ID:BMurri,项目名称:wix3,代码行数:101,代码来源:cabutil.cpp
示例15: _ASSERTE
bool CPluginW1900::InputBox(LPCWSTR Title, LPCWSTR SubTitle, LPCWSTR HistoryName, LPCWSTR SrcText, wchar_t*& DestText)
{
_ASSERTE(DestText==NULL);
if (!InfoW1900)
return false;
wchar_t strTemp[MAX_PATH+1];
if (!InfoW1900->InputBox(&guid_ConEmu, &guid_ConEmuInput, Title, SubTitle, HistoryName, SrcText, strTemp, countof(strTemp), NULL, FIB_BUTTONS))
return false;
DestText = lstrdup(strTemp);
return true;
}
开发者ID:Heather,项目名称:ConEmu,代码行数:12,代码来源:ConEmuPlugin1900.cpp
示例16: MyAssertProc
int MyAssertProc(const wchar_t* pszFile, int nLine, const wchar_t* pszTest, bool abNoPipe)
{
HooksUnlocker;
#ifdef _DEBUG
if (MyAssertSkip(pszFile, nLine, pszTest, abNoPipe))
return 1;
#endif
MyAssertDumpToFile(pszFile, nLine, pszTest);
HANDLE hHeap = GetProcessHeap();
MyAssertInfo* pa = (MyAssertInfo*)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(MyAssertInfo));
if (!pa)
return -1;
wchar_t *szExeName = (wchar_t*)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, (MAX_PATH+1)*sizeof(wchar_t));
if (szExeName && !GetModuleFileNameW(NULL, szExeName, MAX_PATH+1)) szExeName[0] = 0;
pa->bNoPipe = abNoPipe;
msprintf(pa->szTitle, countof(pa->szTitle), L"CEAssert PID=%u TID=%u", GetCurrentProcessId(), GetCurrentThreadId());
wchar_t szVer4[2] = WSTRING(MVV_4a);
msprintf(pa->szDebugInfo, countof(pa->szDebugInfo), L"Assertion in %s [%02u%02u%02u%s]\n%s\n\n%s: %i\n\nPress 'Retry' to trap.",
szExeName ? szExeName : L"<HeapAllocFailed>",
MVV_1, MVV_2, MVV_3, szVer4,
pszTest ? pszTest : L"", pszFile, nLine);
DWORD dwCode = 0;
if (gAllowAssertThread == am_Thread)
{
DWORD dwTID;
HANDLE hThread = apiCreateThread(MyAssertThread, pa, &dwTID, "MyAssertThread");
if (hThread == NULL)
{
dwCode = IDRETRY;
goto wrap;
}
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwCode);
CloseHandle(hThread);
goto wrap;
}
#ifdef ASSERT_PIPE_ALLOWED
#ifdef _DEBUG
if (!abNoPipe && (gAllowAssertThread == am_Pipe))
{
HWND hConWnd = GetConEmuHWND(2);
HWND hGuiWnd = ghConEmuWnd;
// -- искать - нельзя. Если мы НЕ в ConEmu - нельзя стучаться в другие копии!!!
//#ifndef CONEMU_MINIMAL
//if (hGuiWnd == NULL)
//{
// hGuiWnd = FindWindowEx(NULL, NULL, VirtualConsoleClassMain, NULL);
//}
//#endif
if (hGuiWnd && gnInMyAssertTrap <= 0)
{
InterlockedIncrement(&gnInMyAssertTrap);
InterlockedIncrement(&gnInMyAssertPipe);
gnInMyAssertThread = GetCurrentThreadId();
ResetEvent(ghInMyAssertTrap);
dwCode = GuiMessageBox(abNoPipe ? NULL : hGuiWnd, pa->szDebugInfo, pa->szTitle, MB_SETFOREGROUND|MB_SYSTEMMODAL|MB_RETRYCANCEL);
InterlockedDecrement(&gnInMyAssertTrap);
InterlockedDecrement(&gnInMyAssertPipe);
SetEvent(ghInMyAssertTrap);
gnInMyAssertThread = 0;
goto wrap;
}
}
while (gnInMyAssertPipe>0 && (gnInMyAssertThread != GetCurrentThreadId()))
{
Sleep(250);
}
#endif
#endif
// В консольных приложениях попытка запустить CreateThread(MyAssertThread) может зависать
dwCode = MyAssertThread(pa);
wrap:
if (pa)
HeapFree(hHeap, 0, pa);
if (szExeName)
HeapFree(hHeap, 0, szExeName);
return (dwCode == IDRETRY) ? -1 : 1;
}
开发者ID:EmuxEvans,项目名称:ConEmu,代码行数:91,代码来源:MAssert.cpp
示例17: countof
{"+rotate", ".screenflip.rotate", XrmoptionNoArg, "false" },
{"-rotate", ".screenflip.rotate", XrmoptionNoArg, "true" },
};
char *imageDirectory = "";
Bool chooseRandomImages = False;
Bool grabDesktopImages = True;
static argtype vars[] = {
{&rotate, "rotate", "Rotate", DEF_ROTATE, t_Bool},
{&imageDirectory, "imageDirectory", NULL, "", t_String},
{&chooseRandomImages, "chooseRandomImages", NULL, "False", t_Bool},
{&grabDesktopImages, "grabDesktopImages", NULL, "True", t_Bool},
};
ENTRYPOINT ModeSpecOpt screenflip_opts = {countof(opts), opts, countof(vars), vars, NULL};
#ifdef USE_MODULES
ModStruct screenflip_description =
{"screenflip", "init_screenflip", "draw_screenflip", "release_screenflip",
"draw_screenflip", "init_screenflip", NULL, &screenflip_opts,
1000, 1, 2, 1, 4, 1.0, "",
"Screenflips", 0, NULL};
#endif
typedef struct {
GLXContext *glx_context;
Window window;
int winw, winh;
int tw, th; /* texture width, height */
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:31,代码来源:flipscreen3d.c
|
请发表评论