本文整理汇总了C++中MAKELANGID函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKELANGID函数的具体用法?C++ MAKELANGID怎么用?C++ MAKELANGID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAKELANGID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PetscDLOpen
/*@C
PetscDLOpen - opens dynamic library
Not Collective
Input Parameters:
+ name - name of library
- flags - options on how to open library
Output Parameter:
. handle
Level: developer
@*/
PetscErrorCode PetscDLOpen(const char name[],int flags,PetscDLHandle *handle)
{
PETSC_UNUSED int dlflags1,dlflags2; /* There are some preprocessor paths where these variables are set, but not used */
dlhandle_t dlhandle;
PetscFunctionBegin;
PetscValidCharPointer(name,1);
PetscValidPointer(handle,3);
dlflags1 = 0;
dlflags2 = 0;
dlhandle = (dlhandle_t) 0;
*handle = (PetscDLHandle) 0;
/*
--- LoadLibrary ---
*/
#if defined(PETSC_HAVE_WINDOWS_H) && defined(PETSC_HAVE_LOADLIBRARY)
dlhandle = LoadLibrary(name);
if (!dlhandle) {
#if defined(PETSC_HAVE_GETLASTERROR)
PetscErrorCode ierr;
DWORD erc;
char *buff = NULL;
erc = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,erc,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPSTR)&buff,0,NULL);
ierr = PetscError(PETSC_COMM_SELF,__LINE__,__FUNCT__,__FILE__,__SDIR__,PETSC_ERR_FILE_OPEN,PETSC_ERROR_REPEAT,
"Unable to open dynamic library:\n %s\n Error message from LoadLibrary() %s\n",name,buff);
LocalFree(buff);
PetscFunctionReturn(ierr);
#else
SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to open dynamic library:\n %s\n Error message from LoadLibrary() %s\n",name,"unavailable");
#endif
}
/*
--- dlopen ---
*/
#elif defined(PETSC_HAVE_DLFCN_H) && defined(PETSC_HAVE_DLOPEN)
/*
Mode indicates symbols required by symbol loaded with dlsym()
are only loaded when required (not all together) also indicates
symbols required can be contained in other libraries also opened
with dlopen()
*/
#if defined(PETSC_HAVE_RTLD_LAZY)
dlflags1 = RTLD_LAZY;
#endif
#if defined(PETSC_HAVE_RTLD_NOW)
if (flags & PETSC_DL_NOW)
dlflags1 = RTLD_NOW;
#endif
#if defined(PETSC_HAVE_RTLD_GLOBAL)
dlflags2 = RTLD_GLOBAL;
#endif
#if defined(PETSC_HAVE_RTLD_LOCAL)
if (flags & PETSC_DL_LOCAL)
dlflags2 = RTLD_LOCAL;
#endif
#if defined(PETSC_HAVE_DLERROR)
dlerror(); /* clear any previous error */
#endif
dlhandle = dlopen(name,dlflags1|dlflags2);
if (!dlhandle) {
#if defined(PETSC_HAVE_DLERROR)
const char *errmsg = dlerror();
#else
const char *errmsg = "unavailable";
#endif
SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to open dynamic library:\n %s\n Error message from dlopen() %s\n",name,errmsg);
}
/*
--- unimplemented ---
*/
#else
SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP_SYS, "Cannot use dynamic libraries on this platform");
#endif
*handle = (PetscDLHandle) dlhandle;
PetscFunctionReturn(0);
}
示例2: get_meter
bool CDropTargetController::PutValue(TCHAR *szFileName)
{
IMeter *iMeter = 0;
get_meter(&iMeter);
if (iMeter)
{
DISPID id;
HRESULT hr;
LPOLESTR name;
#ifdef notdef
name = L"PutValue";
hr = iMeter->GetIDsOfNames(IID_NULL,
&name,
1,
LOCALE_USER_DEFAULT,
&id);
if (SUCCEEDED(hr))
{
AtlTrace("DropTargetController: Found PutValue method\n");
CComVariant varResult;
CComVariant* pvars = new CComVariant[2];
VariantClear(&varResult);
pvars[0] = (BSTR)value;
pvars[1] = (BSTR)selector;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
hr = iMeter->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
delete[] pvars;
if (SUCCEEDED(hr))
{
AtlTrace("DropTargetController: Set Value via PutValue\n");
return true;
}
}
#endif
name = L"Value";
hr = iMeter->GetIDsOfNames(IID_NULL,
&name,
1,
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
&id);
if (SUCCEEDED(hr))
{
AtlTrace("ValueSetter: Found Value Property\n");
CComVariant varResult;
CComVariant* pvars = new CComVariant[1];
VariantClear(&varResult);
DISPID dispidNamed = DISPID_PROPERTYPUT;
DISPPARAMS disp = { pvars, &dispidNamed, 1, 1 };
_bstr_t value(szFileName);
pvars[0] = (BSTR)value;
hr = iMeter->Invoke(id,
IID_NULL,
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
DISPATCH_PROPERTYPUT,
&disp,
&varResult,
NULL,
NULL);
delete[] pvars;
if (SUCCEEDED(hr))
{
AtlTrace("CDropTargetController: Set Value Property\n");
return true;
}
}
}
return false;
}
示例3: RenderCandidateReadingWindow
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
void CDXUTIMEEditBox::RenderCandidateReadingWindow( bool bReading )
{
RECT rc;
UINT nNumEntries = bReading ? 4 : MAX_CANDLIST;
int nX, nXFirst, nXComp;
m_Buffer.CPtoX( m_nCaret, FALSE, &nX );
m_Buffer.CPtoX( m_nFirstVisible, FALSE, &nXFirst );
DWORD TextColor, TextBkColor, SelTextColor, SelBkColor;
if( bReading )
{
TextColor = m_ReadingColor;
TextBkColor = m_ReadingWinColor;
SelTextColor = m_ReadingSelColor;
SelBkColor = m_ReadingSelBkColor;
}
else
{
TextColor = m_CandidateColor;
TextBkColor = m_CandidateWinColor;
SelTextColor = m_CandidateSelColor;
SelBkColor = m_CandidateSelBkColor;
}
// For Japanese IME, align the window with the first target converted character.
// For all other IMEs, align with the caret. This is because the caret
// does not move for Japanese IME.
if( GetLanguage() == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL ) && !GetImeId() )
nXComp = 0;
else if( GetPrimaryLanguage() == LANG_JAPANESE )
s_CompString.CPtoX( s_nFirstTargetConv, FALSE, &nXComp );
else
s_CompString.CPtoX( ImeUi_GetImeCursorChars(), FALSE, &nXComp );
// Compute the size of the candidate window
int nWidthRequired = 0;
int nHeightRequired = 0;
int nSingleLineHeight = 0;
if( ( ImeUi_IsVerticalCand() && !bReading ) ||
( !ImeUi_IsHorizontalReading() && bReading ) )
{
// Vertical window
for( UINT i = 0; i < nNumEntries; ++i )
{
if( *( ImeUi_GetCandidate( i ) ) == L'\0' )
break;
SetRect( &rc, 0, 0, 0, 0 );
m_pDialog->CalcTextRect( ImeUi_GetCandidate( i ), m_Elements[ 1 ], &rc );
nWidthRequired = std::max<int>( nWidthRequired, rc.right - rc.left );
nSingleLineHeight = std::max<int>( nSingleLineHeight, rc.bottom - rc.top );
}
nHeightRequired = nSingleLineHeight * nNumEntries;
}
else
{
// Horizontal window
SetRect( &rc, 0, 0, 0, 0 );
if( bReading )
m_pDialog->CalcTextRect( s_wszReadingString, m_Elements[ 1 ], &rc );
else
{
WCHAR wszCand[256] = L"";
s_CandList.nFirstSelected = 0;
s_CandList.nHoriSelectedLen = 0;
for( UINT i = 0; i < MAX_CANDLIST; ++i )
{
if( *ImeUi_GetCandidate( i ) == L'\0' )
break;
WCHAR wszEntry[32];
swprintf_s( wszEntry, 32, L"%s ", ImeUi_GetCandidate( i ) );
// If this is the selected entry, mark its char position.
if( ImeUi_GetCandidateSelection() == i )
{
s_CandList.nFirstSelected = (int)wcslen( wszCand );
s_CandList.nHoriSelectedLen = (int)wcslen( wszEntry ) - 1; // Minus space
}
wcscat_s( wszCand, 256, wszEntry );
}
wszCand[wcslen( wszCand ) - 1] = L'\0'; // Remove the last space
s_CandList.HoriCand.SetText( wszCand );
m_pDialog->CalcTextRect( s_CandList.HoriCand.GetBuffer(), m_Elements[ 1 ], &rc );
}
nWidthRequired = rc.right - rc.left;
nSingleLineHeight = nHeightRequired = rc.bottom - rc.top;
}
// Now that we have the dimension, calculate the location for the candidate window.
// We attempt to fit the window in this order:
// bottom, top, right, left.
bool bHasPosition = false;
// Bottom
//.........这里部分代码省略.........
示例4: EnumResNameProc
BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
{
CRuntime* pRuntime = (CRuntime*)lParam;
pRuntime->ExtractDependency(lpszType, lpszName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
return TRUE;
}
示例5: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT lpPaint;
switch(iMessage)
{
case WM_CLOSE:
case WM_DESTROY:
exit(0);
if(MessageBox(hWnd, "Do you really want to quit?", "Message", MB_YESNO) == IDYES)
PostQuitMessage(0);
break;
case WM_ERASEBKGND:
return 1; // Done
case WM_PAINT:
GdiFlush();
hDC = BeginPaint( hWnd, &lpPaint);
// Assume hPaintDC is a variable of type HDC, and the dc we're rendering to
HDC hBitmapDC = CreateCompatibleDC(hDC);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, screenBitmap);
//HPALETTE hOldPalette = SelectPalette(hPaintDC, hPalette, FALSE);
GdiFlush();
if( !BitBlt(hDC, 0, 0, VSCREEN_WIDTH, VSCREEN_HEIGHT, hBitmapDC, 0, 0, SRCCOPY) )
{
DWORD err = GetLastError();
//FormatMessage();
printf("Win error %d", (int)err);
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0, NULL );
printf("WinErr: %s\n", (const char *)lpMsgBuf );
}
GdiFlush();
//SelectPalette(hPaintDC, hOldPalette, TRUE);
SelectObject(hBitmapDC, hOldBitmap);
DeleteDC(hBitmapDC);
/*if(eline)
{
MoveToEx(hDC, 60, 20, NULL);
LineTo(hDC, 264, 122);
}*/
// TODO: paint OS mouse cursor
EndPaint( hWnd, &lpPaint);
break;
#if HOVER
case WM_MOUSEHOVER:
{
int xPos = (short)(0x0FFFF & lParam);//GET_X_LPARAM(lParam);
int yPos = VSCREEN_HEIGHT - (short)(0x0FFFF & (lParam>>16));//GET_Y_LPARAM(lParam);
printf("%d,%d\n", xPos, yPos );
TrackMouseEvent(&eventTrack);
}
break;
#endif
//case WM_KEYDOWN:
//case WM_KEYUP: TranslateMessage( __in const MSG *lpMsg );
case WM_CHAR:
{
printf("-%x-", (int)lParam );
}
break;
case WM_MOUSEMOVE:
{
int xPos = (short)(0x0FFFF & lParam);//GET_X_LPARAM(lParam);
int yPos = VSCREEN_HEIGHT - (short)(0x0FFFF & (lParam>>16));//GET_Y_LPARAM(lParam);
// printf("%d,%d\n", xPos, yPos );
drv_video_win32.mouse_x = xPos;
drv_video_win32.mouse_y = yPos;
drv_video_win32.mouse_flags = wParam;
drv_video_win32.mouse();
#if 1
//.........这里部分代码省略.........
示例6: args_tchar
void ProgramRunner::launchProcess(int child_stdout) {
#ifdef _WIN32
stringstream ss;
for (unsigned i = 0; i < _argv.size(); i++) {
if (i)
ss << ' ';
if (_argv[i].find(' ') == string::npos)
ss << _argv[i];
else {
ss << '"';
// escape all embedded quotes
for (size_t j = 0; j < _argv[i].size(); ++j) {
if (_argv[i][j] == '"')
ss << '\\';
ss << _argv[i][j];
}
ss << '"';
}
}
string args = ss.str();
std::unique_ptr<TCHAR[]> args_tchar(new TCHAR[args.size() + 1]);
size_t i;
for (i = 0; i < args.size(); i++)
args_tchar[i] = args[i];
args_tchar[i] = 0;
HANDLE h = (HANDLE)_get_osfhandle(child_stdout);
verify(h != INVALID_HANDLE_VALUE);
verify(SetHandleInformation(h, HANDLE_FLAG_INHERIT, 1));
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.hStdError = h;
si.hStdOutput = h;
si.dwFlags |= STARTF_USESTDHANDLES;
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
bool success =
CreateProcess(NULL, args_tchar.get(), NULL, NULL, true, 0, NULL, NULL, &si, &pi) != 0;
if (!success) {
LPSTR lpMsgBuf = 0;
DWORD dw = GetLastError();
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&lpMsgBuf,
0,
NULL);
stringstream ss;
ss << "couldn't start process " << _argv[0] << "; " << lpMsgBuf;
uassert(14042, ss.str(), success);
LocalFree(lpMsgBuf);
}
CloseHandle(pi.hThread);
_pid = ProcessId::fromNative(pi.dwProcessId);
registry._handles.insert(make_pair(_pid, pi.hProcess));
#else
unique_ptr<const char* []> argvStorage(new const char* [_argv.size() + 1]);
const char** argv = argvStorage.get();
for (unsigned i = 0; i < _argv.size(); i++) {
argv[i] = _argv[i].c_str();
}
argv[_argv.size()] = 0;
unique_ptr<const char* []> envStorage(new const char* [2]);
const char** env = envStorage.get();
env[0] = NULL;
env[1] = NULL;
pid_t nativePid = fork();
_pid = ProcessId::fromNative(nativePid);
// Async signal unsafe functions should not be called in the child process.
verify(nativePid != -1);
if (nativePid == 0) {
// DON'T ASSERT IN THIS BLOCK - very bad things will happen
if (dup2(child_stdout, STDOUT_FILENO) == -1 || dup2(child_stdout, STDERR_FILENO) == -1) {
// Async signal unsafe code reporting a terminal error condition.
cout << "Unable to dup2 child output: " << errnoWithDescription() << endl;
quickExit(-1); // do not pass go, do not call atexit handlers
}
// NOTE execve is async signal safe, but it is not clear that execvp is async
// signal safe.
execvp(argv[0], const_cast<char**>(argv));
// Async signal unsafe code reporting a terminal error condition.
cout << "Unable to start program " << argv[0] << ' ' << errnoWithDescription() << endl;
//.........这里部分代码省略.........
示例7: MessageBox
void FileEncrypter::ErrorMsgBox(DWORD dwErrorCode,TCHAR* szTemplet){
BOOL hasTemplet=TRUE;
if (!szTemplet || _tcslen(szTemplet)==0) hasTemplet=FALSE;
if(dwErrorCode==0 && hasTemplet){
MessageBox(GetForegroundWindow(),szTemplet,_T("亿榕公文交换平台错误"),MB_OK|MB_ICONERROR);
return ;
}
TCHAR* szPos=NULL;
if (hasTemplet) szPos=_tcsstr(szTemplet,_T("%s"));
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM,NULL,dwErrorCode,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0, NULL );
TCHAR szTip[STRLEN_DEFAULT]={0};
_stprintf_s(szTip,(szPos?szTemplet:_T("%s")),(lpMsgBuf==NULL?_T("未知错误"):lpMsgBuf));
LocalFree(lpMsgBuf);
MessageBox(GetForegroundWindow(),szTip,_T("亿榕公文交换平台错误"),MB_OK|MB_ICONERROR);
}
示例8: AttachRootProcessHandle
// Используется и в обычном, и в "отладочном" режиме
int AttachRootProcessHandle()
{
if (gpSrv->DbgInfo.pszDebuggingCmdLine != NULL)
{
_ASSERTE(gpSrv->DbgInfo.bDebuggerActive);
return 0; // Started from DebuggingThread
}
DWORD dwErr = 0;
// Нужно открыть HANDLE корневого процесса
_ASSERTE(gpSrv->hRootProcess==NULL || gpSrv->hRootProcess==GetCurrentProcess());
if (gpSrv->dwRootProcess == GetCurrentProcessId())
{
if (gpSrv->hRootProcess == NULL)
{
gpSrv->hRootProcess = GetCurrentProcess();
}
}
else if (gpSrv->DbgInfo.bDebuggerActive)
{
if (gpSrv->hRootProcess == NULL)
{
gpSrv->hRootProcess = GetProcessHandleForDebug(gpSrv->dwRootProcess);
}
}
else if (gpSrv->hRootProcess == NULL)
{
gpSrv->hRootProcess = OpenProcess(MY_PROCESS_ALL_ACCESS, FALSE, gpSrv->dwRootProcess);
if (gpSrv->hRootProcess == NULL)
{
gpSrv->hRootProcess = OpenProcess(SYNCHRONIZE|PROCESS_QUERY_INFORMATION, FALSE, gpSrv->dwRootProcess);
}
}
if (!gpSrv->hRootProcess)
{
dwErr = GetLastError();
wchar_t* lpMsgBuf = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&lpMsgBuf, 0, NULL);
_printf("\nCan't open process (%i) handle, ErrCode=0x%08X, Description:\n", //-V576
gpSrv->dwRootProcess, dwErr, (lpMsgBuf == NULL) ? L"<Unknown error>" : lpMsgBuf);
if (lpMsgBuf) LocalFree(lpMsgBuf);
SetLastError(dwErr);
return CERR_CREATEPROCESS;
}
if (gpSrv->DbgInfo.bDebuggerActive)
{
wchar_t szTitle[64];
_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"Debugging PID=%u, Debugger PID=%u", gpSrv->dwRootProcess, GetCurrentProcessId());
SetTitle(szTitle);
UpdateDebuggerTitle();
}
return 0;
}
示例9: ShowError
/*
Writes the last error to log.
*/
void ShowError(int lineNumber, WCHAR* errorMsg)
{
DWORD dwErr = GetLastError();
WCHAR buffer[16];
wsprintf(buffer, L"%i", lineNumber);
std::wstring err = L"WebParser.dll: (";
err += buffer;
err += L") ";
if (errorMsg == nullptr)
{
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
{
WCHAR szBuffer[1024];
DWORD dwError, dwLen = 1024;
if (InternetGetLastResponseInfo(&dwError, szBuffer, &dwLen))
{
err += szBuffer;
wsprintf(buffer, L"%i", dwError);
}
else
{
err += L"Unknown error";
wsprintf(buffer, L"%i", dwErr);
}
err += L" (ErrorCode=";
err += buffer;
err += L')';
}
else
{
LPVOID lpMsgBuf = nullptr;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK,
GetModuleHandle(L"wininet"),
dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
nullptr
);
if (lpMsgBuf == nullptr)
{
err += L"Unknown error";
}
else
{
err += (LPTSTR)lpMsgBuf;
LocalFree(lpMsgBuf);
}
wsprintf(buffer, L"%i", dwErr);
err += L" (ErrorCode=";
err += buffer;
err += L')';
}
}
else
{
err += errorMsg;
}
RmLog(LOG_ERROR, err.c_str());
}
示例10: get_meter
/*
* This method is called when a windows message of the correct type has been posted.
*/
STDMETHODIMP CValueSetter::HandleMessage(/*[in]*/ UINT wParam, /*[in]*/ UINT lParam, /*[in]*/ short x, /*[in]*/ short y, /*[out, retval]*/ VARIANT_BOOL *handled)
{
*handled = !passThrough;
IMeter *iMeter = 0;
get_meter(&iMeter);
if (iMeter)
{
LPOLESTR name = L"PutValue";
DISPID id;
HRESULT hr = iMeter->GetIDsOfNames(IID_NULL,
&name,
1,
LOCALE_USER_DEFAULT,
&id);
if (SUCCEEDED(hr))
{
AtlTrace("MappedController: Found PutValue method\n");
CComVariant varResult;
CComVariant* pvars = new CComVariant[2];
VariantClear(&varResult);
pvars[0] = (BSTR)value;
pvars[1] = (BSTR)selector;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
hr = iMeter->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
delete[] pvars;
if (SUCCEEDED(hr))
{
AtlTrace("ValueSetter: Set Value via PutValue\n");
return S_OK;
}
}
name = L"Value";
hr = iMeter->GetIDsOfNames(IID_NULL,
&name,
1,
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
&id);
if (SUCCEEDED(hr))
{
AtlTrace("ValueSetter: Found Value Property\n");
CComVariant varResult;
CComVariant* pvars = new CComVariant[1];
VariantClear(&varResult);
DISPID dispidNamed = DISPID_PROPERTYPUT;
DISPPARAMS disp = { pvars, &dispidNamed, 1, 1 };
pvars[0] = (BSTR)value;
hr = iMeter->Invoke(id,
IID_NULL,
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT),
DISPATCH_PROPERTYPUT,
&disp,
&varResult,
NULL,
NULL);
delete[] pvars;
if (SUCCEEDED(hr))
{
AtlTrace("ValueSetter: Set Value Property\n");
return S_OK;
}
}
}
return S_OK;
}
示例11: winMessageDlgPopup
static int winMessageDlgPopup(Ihandle* ih, int x, int y)
{
InativeHandle* parent = iupDialogGetNativeParent(ih);
MSGBOXPARAMS MsgBoxParams;
int result, num_but = 2;
DWORD dwStyle = MB_TASKMODAL;
char *icon, *buttons;
(void)x;
(void)y;
if (!parent)
parent = GetActiveWindow();
icon = iupAttribGetStr(ih, "DIALOGTYPE");
if (iupStrEqualNoCase(icon, "ERROR"))
dwStyle |= MB_ICONERROR;
else if (iupStrEqualNoCase(icon, "WARNING"))
dwStyle |= MB_ICONWARNING;
else if (iupStrEqualNoCase(icon, "INFORMATION"))
dwStyle |= MB_ICONINFORMATION;
else if (iupStrEqualNoCase(icon, "QUESTION"))
dwStyle |= MB_ICONQUESTION;
buttons = iupAttribGetStr(ih, "BUTTONS");
if (iupStrEqualNoCase(buttons, "OKCANCEL"))
dwStyle |= MB_OKCANCEL;
else if (iupStrEqualNoCase(buttons, "YESNO"))
dwStyle |= MB_YESNO;
else
{
dwStyle |= MB_OK;
num_but = 1;
}
if (IupGetCallback(ih, "HELP_CB"))
dwStyle |= MB_HELP;
if (num_but == 2 && iupAttribGetInt(ih, "BUTTONDEFAULT") == 2)
dwStyle |= MB_DEFBUTTON2;
else
dwStyle |= MB_DEFBUTTON1;
MsgBoxParams.cbSize = sizeof(MSGBOXPARAMS);
MsgBoxParams.hwndOwner = parent;
MsgBoxParams.hInstance = NULL;
MsgBoxParams.lpszText = iupAttribGet(ih, "VALUE");
MsgBoxParams.lpszCaption = iupAttribGet(ih, "TITLE");
MsgBoxParams.dwStyle = dwStyle;
MsgBoxParams.lpszIcon = NULL;
MsgBoxParams.dwContextHelpId = (DWORD_PTR)ih;
MsgBoxParams.lpfnMsgBoxCallback = (MSGBOXCALLBACK)winMessageDlgHelpCallback;
MsgBoxParams.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
result = MessageBoxIndirect(&MsgBoxParams);
if (result == 0)
{
iupAttribSetStr(ih, "BUTTONRESPONSE", NULL);
return IUP_ERROR;
}
if (result == IDNO || result == IDCANCEL)
iupAttribSetStr(ih, "BUTTONRESPONSE", "2");
else
iupAttribSetStr(ih, "BUTTONRESPONSE", "1");
return IUP_NOERROR;
}
示例12: LoadLangDll
//.........这里部分代码省略.........
do
{
if (bIsWow)
_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc32%d.dll"), langdir, langId);
else
_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc%d.dll"), langdir, langId);
BOOL versionmatch = TRUE;
struct TRANSARRAY
{
WORD wLanguageID;
WORD wCharacterSet;
};
DWORD dwReserved,dwBufferSize;
dwBufferSize = GetFileVersionInfoSize((LPTSTR)langDll,&dwReserved);
if (dwBufferSize > 0)
{
LPVOID pBuffer = (void*) malloc(dwBufferSize);
if (pBuffer != (void*) NULL)
{
UINT nInfoSize = 0;
UINT nFixedLength = 0;
LPSTR lpVersion = NULL;
VOID* lpFixedPointer;
TRANSARRAY* lpTransArray;
TCHAR strLangProduktVersion[MAX_PATH];
if (GetFileVersionInfo((LPTSTR)langDll,
dwReserved,
dwBufferSize,
pBuffer))
{
// Query the current language
if (VerQueryValue( pBuffer,
_T("\\VarFileInfo\\Translation"),
&lpFixedPointer,
&nFixedLength))
{
lpTransArray = (TRANSARRAY*) lpFixedPointer;
_stprintf_s(strLangProduktVersion, _T("\\StringFileInfo\\%04x%04x\\ProductVersion"),
lpTransArray[0].wLanguageID, lpTransArray[0].wCharacterSet);
if (VerQueryValue(pBuffer,
(LPTSTR)strLangProduktVersion,
(LPVOID *)&lpVersion,
&nInfoSize))
{
versionmatch = (_tcscmp((LPCTSTR)lpVersion, _T(STRPRODUCTVER)) == 0);
}
}
}
free(pBuffer);
} // if (pBuffer != (void*) NULL)
} // if (dwBufferSize > 0)
else
versionmatch = FALSE;
if (versionmatch)
hInst = LoadLibrary(langDll);
if (hInst != NULL)
{
if (g_hResInst != g_hmodThisDll)
FreeLibrary(g_hResInst);
g_hResInst = hInst;
}
else
{
DWORD lid = SUBLANGID(langId);
lid--;
if (lid > 0)
{
langId = MAKELANGID(PRIMARYLANGID(langId), lid);
}
else
langId = 0;
}
} while ((hInst == NULL) && (langId != 0));
if (hInst == NULL)
{
// either the dll for the selected language is not present, or
// it is the wrong version.
// fall back to English and set a timeout so we don't retry
// to load the language dll too often
if (g_hResInst != g_hmodThisDll)
FreeLibrary(g_hResInst);
g_hResInst = g_hmodThisDll;
g_langid = 1033;
// set a timeout of 10 seconds
if (g_ShellCache.GetLangID() != 1033)
g_langTimeout = GetTickCount() + 10000;
}
else
g_langTimeout = 0;
} // if (g_langid != g_ShellCache.GetLangID())
}
示例13: zbx_get_eventlog_message
/* get Nth error from event log. 1 is the first. */
static int zbx_get_eventlog_message(LPCTSTR wsource, HANDLE eventlog_handle, long which, char **out_source, char **out_message,
unsigned short *out_severity, unsigned long *out_timestamp, unsigned long *out_eventid)
{
const char *__function_name = "zbx_get_eventlog_message";
int buffer_size = 512;
EVENTLOGRECORD *pELR = NULL;
DWORD dwRead, dwNeeded, dwErr;
TCHAR stat_buf[MAX_PATH], MsgDll[MAX_PATH];
HKEY hk = NULL;
LPTSTR pFile = NULL, pNextFile = NULL;
DWORD szData, Type;
HINSTANCE hLib = NULL; /* handle to the messagetable DLL */
LPTSTR pCh, aInsertStrs[MAX_INSERT_STRS]; /* array of pointers to insert */
LPTSTR msgBuf = NULL; /* hold text of the error message */
char *buf = NULL;
long i, err = 0;
int ret = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() which:%ld", __function_name, which);
*out_source = NULL;
*out_message = NULL;
*out_severity = 0;
*out_timestamp = 0;
*out_eventid = 0;
memset(aInsertStrs, 0, sizeof(aInsertStrs));
pELR = (EVENTLOGRECORD *)zbx_malloc((void *)pELR, buffer_size);
retry:
if (0 == ReadEventLog(eventlog_handle, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, which,
pELR, buffer_size, &dwRead, &dwNeeded))
{
dwErr = GetLastError();
if (dwErr == ERROR_INSUFFICIENT_BUFFER)
{
buffer_size = dwNeeded;
pELR = (EVENTLOGRECORD *)zbx_realloc((void *)pELR, buffer_size);
goto retry;
}
else
{
zabbix_log(LOG_LEVEL_DEBUG, "%s(): %s", __function_name, strerror_from_system(dwErr));
goto out;
}
}
*out_severity = pELR->EventType; /* return event type */
*out_timestamp = pELR->TimeGenerated; /* return timestamp */
*out_eventid = pELR->EventID & 0xffff;
*out_source = zbx_unicode_to_utf8((LPTSTR)(pELR + 1)); /* copy source name */
err = FAIL;
/* prepare the array of insert strings for FormatMessage - the
insert strings are in the log entry. */
for (i = 0, pCh = (LPTSTR)((LPBYTE)pELR + pELR->StringOffset);
i < pELR->NumStrings && i < MAX_INSERT_STRS;
i++, pCh += zbx_strlen(pCh) + 1) /* point to next string */
{
aInsertStrs[i] = pCh;
}
/* Get path to message dll */
zbx_wsnprintf(stat_buf, MAX_PATH, EVENTLOG_REG_PATH TEXT("%s\\%s"), wsource, (LPTSTR)(pELR + 1));
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, stat_buf, 0, KEY_READ, &hk))
{
if (ERROR_SUCCESS == RegQueryValueEx(hk, TEXT("EventMessageFile"), NULL, &Type, NULL, &szData))
{
buf = zbx_malloc(buf, szData);
if (ERROR_SUCCESS == RegQueryValueEx(hk, TEXT("EventMessageFile"), NULL, &Type, (LPBYTE)buf, &szData))
pFile = (LPTSTR)buf;
}
RegCloseKey(hk);
}
err = FAIL;
while (NULL != pFile && FAIL == err)
{
if (NULL != (pNextFile = zbx_strchr(pFile, ';')))
{
*pNextFile = '\0';
pNextFile++;
}
if (ExpandEnvironmentStrings(pFile, MsgDll, MAX_PATH))
{
if (NULL != (hLib = LoadLibraryEx(MsgDll, NULL, LOAD_LIBRARY_AS_DATAFILE)))
{
/* Format the message from the message DLL with the insert strings */
if (0 != FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_MAX_WIDTH_MASK, /* do not generate new line breaks */
hLib, /* the messagetable DLL handle */
pELR->EventID, /* message ID */
MAKELANGID(LANG_NEUTRAL, SUBLANG_ENGLISH_US), /* language ID */
(LPTSTR)&msgBuf, /* address of pointer to buffer for message */
//.........这里部分代码省略.........
示例14: getResultMessage
std::string getResultMessage(result_t hr)
{
static const char *s_errors[] =
{
"",
// CALL_E_BADPARAMCOUNT
"Invalid number of parameters.",
// CALL_E_PARAMNOTOPTIONAL
"Parameter not optional.",
// CALL_E_BADVARTYPE
"The input parameter is not a valid type.",
// CALL_E_INVALIDARG
"Invalid argument.",
// CALL_E_TYPEMISMATCH
"The argument could not be coerced to the specified type.",
// CALL_E_OUTRANGE
"Value is out of range.",
// CALL_E_CONSTRUCTOR
"Constructor cannot be called as a function.",
// CALL_E_NOTINSTANCE
"Object is not an instance of declaring class.",
// CALL_E_INVALID_CALL
"Invalid procedure call.",
// CALL_E_REENTRANT_CALL
"Re-entrant calls are not allowed.",
// CALL_E_INVALID_DATA
"Invalid input data.",
// CALL_E_BADINDEX
"Index was out of range.",
// CALL_E_OVERFLOW
"Memory overflow error.",
// CALL_E_EMPTY
"Collection is empty.",
// CALL_E_PENDDING
"Operation now in progress.",
// CALL_E_NOSYNC
"Operation not support synchronous call.",
// CALL_E_NOASYNC
"Operation not support asynchronous call.",
// CALL_E_INTERNAL
"Internal error.",
// CALL_E_RETURN_TYPE
"Invalid return type.",
// CALL_E_EXCEPTION
"Exception occurred.",
// CALL_E_JAVASCRIPT
"Javascript error."
};
if (hr == CALL_E_EXCEPTION)
{
std::string s = Runtime::errMessage();
if (s.length() > 0)
return s;
}
if (hr > CALL_E_MIN && hr < CALL_E_MAX)
return fmtString(hr, s_errors[CALL_E_MAX - hr]);
hr = -hr;
#ifdef _WIN32
WCHAR MsgBuf[1024];
if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MsgBuf, 1024, NULL ))
{
std::string s = fmtString(hr, UTF8_A(MsgBuf));
size_t sz = s.length();
if (sz > 0 && s[sz - 1] == '\n')
s.resize(sz - 1);
return s;
}
return fmtString(hr, "Unknown error.");
#else
return fmtString(hr, strerror(hr));
#endif
}
示例15: API_EXPORT
API_EXPORT(void) ap_log_error (const char *file, int line, int level,
const server_rec *s, const char *fmt, ...)
{
va_list args;
char errstr[MAX_STRING_LEN];
size_t len;
int save_errno = errno;
FILE *logf;
if (s == NULL) {
/*
* If we are doing stderr logging (startup), don't log messages that are
* above the default server log level unless it is a startup/shutdown
* notice
*/
if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL))
return;
logf = stderr;
}
else if (s->error_log) {
/*
* If we are doing normal logging, don't log messages that are
* above the server log level unless it is a startup/shutdown notice
*/
if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
((level & APLOG_LEVELMASK) > s->loglevel))
return;
logf = s->error_log;
}
else {
/*
* If we are doing syslog logging, don't log messages that are
* above the server log level (including a startup/shutdown notice)
*/
if ((level & APLOG_LEVELMASK) > s->loglevel)
return;
logf = NULL;
}
if (logf) {
len = ap_snprintf(errstr, sizeof(errstr), "[%s] ", ap_get_time());
} else {
len = 0;
}
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
"[%s] ", priorities[level & APLOG_LEVELMASK].t_name);
if (file && (level & APLOG_LEVELMASK) == APLOG_DEBUG) {
#ifdef _OSD_POSIX
char tmp[256];
char *e = strrchr(file, '/');
/* In OSD/POSIX, the compiler returns for __FILE__
* a string like: __FILE__="*POSIX(/usr/include/stdio.h)"
* (it even returns an absolute path for sources in
* the current directory). Here we try to strip this
* down to the basename.
*/
if (e != NULL && e[1] != '\0') {
ap_snprintf(tmp, sizeof(tmp), "%s", &e[1]);
e = &tmp[strlen(tmp)-1];
if (*e == ')')
*e = '\0';
file = tmp;
}
#endif /*_OSD_POSIX*/
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
"%s(%d): ", file, line);
}
if (!(level & APLOG_NOERRNO)
&& (save_errno != 0)
#ifdef WIN32
&& !(level & APLOG_WIN32ERROR)
#endif
) {
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
"(%d)%s: ", save_errno, strerror(save_errno));
}
#ifdef WIN32
if (level & APLOG_WIN32ERROR) {
int nChars;
int nErrorCode;
nErrorCode = GetLastError();
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
"(%d)", nErrorCode);
nChars = FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
nErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) errstr + len,
sizeof(errstr) - len,
NULL
);
len += nChars;
if (nChars == 0) {
//.........这里部分代码省略.........