BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len) { HKEY hkey; BOOL ret = FALSE; DWORD buflen = len; szDest[0] = 0; if (HCR_RegOpenClassIDKey(riid, &hkey)) { if (!RegLoadMUIStringA(hkey,"LocalizedString",szDest,len,NULL,0,NULL) || !RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len)) { ret = TRUE; } RegCloseKey(hkey); } if (!ret || !szDest[0]) { if(IsEqualIID(riid, &CLSID_ShellDesktop)) { if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen)) ret = TRUE; } else if (IsEqualIID(riid, &CLSID_MyComputer)) { if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen)) ret = TRUE; } } TRACE("-- (%s)\n", szDest); return ret; }
UINT WINAPI GetStateTextA(DWORD state_bit, CHAR *state_str, UINT state_str_len) { DWORD state_id; TRACE("%x %p %u\n", state_bit, state_str, state_str_len); if(state_str && !state_str_len) return 0; if(state_bit & ~(STATE_SYSTEM_VALID | STATE_SYSTEM_HASPOPUP)) { if(state_str && state_str_len) state_str[0] = 0; return 0; } state_id = IDS_STATE_NORMAL; while(state_bit) { state_id++; state_bit /= 2; } if(state_str) { UINT ret = LoadStringA(oleacc_handle, state_id, state_str, state_str_len); if(!ret && state_str_len) state_str[0] = 0; return ret; }else { CHAR tmp[256]; return LoadStringA(oleacc_handle, state_id, tmp, sizeof(tmp)); } }
static void test_LoadStringA (void) { HINSTANCE hInst = GetModuleHandleA(NULL); static const char str[] = "String resource"; /* same in resource.rc */ char buf[128]; struct string_test { unsigned int bufsiz; unsigned int expected; }; struct string_test tests[] = {{sizeof buf, sizeof str - 1}, {sizeof str, sizeof str - 1}, {sizeof str - 1, sizeof str - 2} }; unsigned int i; int ret, ret2; assert (sizeof str < sizeof buf); for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { const unsigned int bufsiz = tests[i].bufsiz; const unsigned int expected = tests[i].expected; const int len = LoadStringA (hInst, 0, buf, bufsiz); ok (len == expected, "bufsiz=%d: got %d, expected %d\n", bufsiz, len, expected); if (len != expected) continue; ok (!memcmp (buf, str, len), "bufsiz=%d: got '%s', expected '%.*s'\n", bufsiz, buf, len, str); ok (buf[len] == 0, "bufsiz=%d: NUL termination missing\n", bufsiz); } ret = LoadStringA(hInst, 1, buf, sizeof(buf) ); ok( ret > 0, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret2 = LoadStringA( hInst, MAKELONG( 1, 0x8000 ), buf, sizeof(buf)); ok( ret2 == ret, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret2 = LoadStringA( hInst, MAKELONG( 1, 0xffff ), buf, sizeof(buf)); ok( ret2 == ret, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret = LoadStringA(hInst, 65534, buf, sizeof(buf) ); ok( ret > 0, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret2 = LoadStringA( hInst, MAKELONG( 65534, 0x8000 ), buf, sizeof(buf)); ok( ret2 == ret, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret2 = LoadStringA( hInst, MAKELONG( 65534, 0xffff ), buf, sizeof(buf)); ok( ret2 == ret, "LoadString failed: ret %d err %d\n", ret, GetLastError()); ret = LoadStringA(hInst, 0, buf, 0); ok( ret == -1 || broken(ret == 0), "LoadStringA did not return -1 when called with buflen = 0, got %d, err %d\n", ret, GetLastError()); SetLastError(0xdeadbeef); buf[0] = 'a'; ret = LoadStringA(hInst, 1, buf, 1); ok( !ret, "LoadString returned %d\n", ret); ok( buf[0] == 0, "buf[0] = %c (%x)\n", buf[0], buf[0]); ok( GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError()); }
/*********************************************************************** * ldap_err2stringA (WLDAP32.@) * * See ldap_err2stringW. */ PCHAR CDECL ldap_err2stringA( ULONG err ) { static char buf[256] = ""; TRACE( "(0x%08lx)\n", err ); if (err <= WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED) LoadStringA( hwldap32, err, buf, 256 ); else LoadStringA( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 ); return buf; }
static void test_LoadStringA (void) { HINSTANCE hInst = GetModuleHandle (NULL); static const char str[] = "String resource"; /* same in resource.rc */ char buf[128]; struct string_test { int bufsiz; int expected; }; struct string_test tests[] = {{sizeof buf, sizeof str - 1}, {sizeof str, sizeof str - 1}, {sizeof str - 1, sizeof str - 2}}; unsigned int i; assert (sizeof str < sizeof buf); for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { const int bufsiz = tests[i].bufsiz; const int expected = tests[i].expected; const int len = LoadStringA (hInst, 0, buf, bufsiz); ok (len == expected, "bufsiz=%d: got %d, expected %d\n", bufsiz, len, expected); ok (!memcmp (buf, str, len), "bufsiz=%d: got '%s', expected '%.*s'\n", bufsiz, buf, len, str); ok (buf[len] == 0, "bufsiz=%d: NUL termination missing\n", bufsiz); } }
HRESULT __stdcall BtrfsContextMenu::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax) { if (ignore) return E_INVALIDARG; if (idCmd != 0) return E_INVALIDARG; switch (uFlags) { case GCS_HELPTEXTA: if (LoadStringA(module, bg ? IDS_NEW_SUBVOL_HELP_TEXT : IDS_CREATE_SNAPSHOT_HELP_TEXT, pszName, cchMax)) return S_OK; else return E_FAIL; case GCS_HELPTEXTW: if (LoadStringW(module, bg ? IDS_NEW_SUBVOL_HELP_TEXT : IDS_CREATE_SNAPSHOT_HELP_TEXT, (LPWSTR)pszName, cchMax)) return S_OK; else return E_FAIL; case GCS_VALIDATEA: case GCS_VALIDATEW: return S_OK; case GCS_VERBA: return StringCchCopyA(pszName, cchMax, bg ? NEW_SUBVOL_VERBA : SNAPSHOT_VERBA); case GCS_VERBW: return StringCchCopyW((STRSAFE_LPWSTR)pszName, cchMax, bg ? NEW_SUBVOL_VERBW : SNAPSHOT_VERBW); default: return E_INVALIDARG; } }
/* Fills in the name and exename fields */ static void extract_test (struct wine_test *test, const char *dir, int id) { BYTE* code; DWORD size; FILE* fout; int strlen, bufflen = 128; char *exepos; code = extract_rcdata (id, TESTRES, &size); if (!code) report (R_FATAL, "Can't find test resource %d: %d", id, GetLastError ()); test->name = xmalloc (bufflen); while ((strlen = LoadStringA (NULL, id, test->name, bufflen)) == bufflen - 1) { bufflen *= 2; test->name = xrealloc (test->name, bufflen); } if (!strlen) report (R_FATAL, "Can't read name of test %d.", id); test->exename = strmake (NULL, "%s/%s", dir, test->name); exepos = strstr (test->name, "_test.exe"); if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name); *exepos = 0; test->name = xrealloc (test->name, exepos - test->name + 1); report (R_STEP, "Extracting: %s", test->name); if (!(fout = fopen (test->exename, "wb")) || (fwrite (code, size, 1, fout) != 1) || fclose (fout)) report (R_FATAL, "Failed to write file %s.", test->exename); }
char* WINAPI StringFromResource(char* pBuffer, int iResourceID) { if (LoadStringA(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH) == 0) { return ""; } return pBuffer; }
static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) { ICPanelImpl *This = (ICPanelImpl *)iface; HRESULT hr; TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG; if (!pidl) { psd->fmt = ControlPanelSFHeader[iColumn].fmt; psd->cxChar = ControlPanelSFHeader[iColumn].cxChar; psd->str.uType = STRRET_CSTR; LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); return S_OK; } else { psd->str.u.cStr[0] = 0x00; psd->str.uType = STRRET_CSTR; switch(iColumn) { case 0: /* name */ hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); break; case 1: /* comment */ _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH); break; } hr = S_OK; } return hr; }
void Welcome() { system("cls"); char s[1500]; LoadStringA(NULL, (int)MAKEINTRESOURCE(IDS_STRING1), s, sizeof(s)); printf("%s\n",s); }
BOOL SetEenvironment() { LoadString(hInst, IDS_CMDLINE, szCommandLine, sizeof(szCommandLine)/sizeof(szCommandLine[0])-1); LoadString(hInst, IDS_ENVIRONMENT, szEnvironment, sizeof(szEnvironment)/sizeof(szEnvironment[0])-1); LoadString(hInst, IDS_PROXYLIST, szProxyString, sizeof(szProxyString)/sizeof(szEnvironment[0])-1); LoadStringA(hInst, IDS_RASPBK, szRasPbk, sizeof(szRasPbk)/sizeof(szRasPbk[0])-1); WCHAR *sep = L"\n"; WCHAR *pos = NULL; WCHAR *token = wcstok(szEnvironment, sep); while(token != NULL) { if (pos = wcschr(token, L'=')) { *pos = 0; SetEnvironmentVariableW(token, pos+1); //wprintf(L"[%s] = [%s]\n", token, pos+1); } token = wcstok(NULL, sep); } GetEnvironmentVariableW(L"TASKBAR_TITLE", szTitle, sizeof(szTitle)/sizeof(szTitle[0])-1); GetEnvironmentVariableW(L"TASKBAR_TOOLTIP", szTooltip, sizeof(szTooltip)/sizeof(szTooltip[0])-1); GetEnvironmentVariableW(L"TASKBAR_BALLOON", szBalloon, sizeof(szBalloon)/sizeof(szBalloon[0])-1); return TRUE; }
void ShowErrorMessage(HRESULT hr) { DWORD dwSize; CHAR szErrorMessagePrefix[64]; int nChars = LoadStringA(NULL, IDS_ERRORMESSAGE, szErrorMessagePrefix, sizeof(szErrorMessagePrefix)/sizeof(CHAR)); HANDLE hStdErr = GetStdHandle(STD_OUTPUT_HANDLE); dwSize = nChars; ::WriteFile(hStdErr, szErrorMessagePrefix, nChars, &dwSize, NULL); //Write the dll name DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; LPSTR szMessage = NULL; dwSize = ::FormatMessageA(dwFlags, NULL, hr, 0, reinterpret_cast<LPSTR>(&szMessage), 0, NULL); if ((szMessage == NULL) || (dwSize == 0)) { wsprintfA(szErrorMessagePrefix, "%hu ", hr); szMessage = szErrorMessagePrefix; ::WriteFile(hStdErr, szMessage, dwSize, &dwSize, NULL); } else { ::WriteFile(hStdErr, szMessage, dwSize, &dwSize, NULL); LocalFree(reinterpret_cast<HLOCAL>(szMessage)); } }
VOID LoadResourceString( UINT ResourceId, LPVOID Buffer, UINT ccount, LPVOID DefaultString, BOOL bUnicode) { if (bUnicode) { /* load localized string */ if (!LoadStringW(dsound_hInstance, ResourceId, (LPWSTR)Buffer, ccount)) { /* default device name */ wcscpy((LPWSTR)Buffer, (LPWSTR)DefaultString); } } else { /* load localized string */ if (!LoadStringA(dsound_hInstance, ResourceId, (LPSTR)Buffer, ccount)) { /* default device name */ strcpy((LPSTR)Buffer, (LPSTR)DefaultString); } } }
static void extract_rev_infos (void) { char revinfo[256], *p; int size = 0, i; unsigned int len; HMODULE module = GetModuleHandle (NULL); for (i = 0; TRUE; i++) { if (i >= size) { size += 100; rev_infos = xrealloc (rev_infos, size * sizeof (*rev_infos)); } memset(rev_infos + i, 0, sizeof(rev_infos[i])); len = LoadStringA (module, REV_INFO+i, revinfo, sizeof(revinfo)); if (len == 0) break; /* end of revision info */ if (len >= sizeof(revinfo) - 1) report (R_FATAL, "Revision info too long."); if(!(p = strrchr(revinfo, ':'))) report (R_FATAL, "Revision info malformed (i=%d)", i); *p = 0; rev_infos[i].file = strdup(revinfo); rev_infos[i].rev = strdup(p + 1); } }
int StringBase::loadString( void * pInstance, dword nID, char * pBuffer, int nBufferMax ) { #if defined(_WIN32) || defined(_XBOX) return LoadStringA( (HINSTANCE)pInstance,nID, pBuffer, nBufferMax ); #else return 0; #endif }
static void errmsg(UINT id, DWORD code) { char buffer [512]; char format [128]; LoadStringA(GetModuleHandleA(NULL), id, format, 128); wnsprintfA(buffer, 512, format, code); MessageBoxA(NULL, buffer, "gdi++ ERROR", MB_OK|MB_ICONSTOP); }
HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags) { HKEY hKey; DWORD cbData = 0; DWORD Value = 0; LONG rc; BOOL EnumerateAttachedSecondaries = FALSE; DWORD privateDWFlags = 0; CHAR strMsg[RC_STRING_MAX_SIZE]; HRESULT retVal = DDERR_INVALIDPARAMS; DX_WINDBG_trace(); if ((IsBadCodePtr((LPVOID)lpCallback) == 0) && ((dwFlags & ~(DDENUM_NONDISPLAYDEVICES | DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_ATTACHEDSECONDARYDEVICES)) == 0)) { LoadStringA(hDllModule, STR_PRIMARY_DISPLAY, (LPSTR)&strMsg, RC_STRING_MAX_SIZE); rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, REGSTR_PATH_DDHW, &hKey); if (rc == ERROR_SUCCESS) { /* Enumerate Attached Secondaries */ cbData = sizeof(DWORD); rc = RegQueryValueExA(hKey, "EnumerateAttachedSecondaries", NULL, NULL, (LPBYTE)&Value, &cbData); if (rc == ERROR_SUCCESS) { if (Value != 0) { EnumerateAttachedSecondaries = TRUE; privateDWFlags = DDENUM_ATTACHEDSECONDARYDEVICES; } } RegCloseKey(hKey); } /* Call the user supplied callback function */ rc = lpCallback(NULL, strMsg, "display", lpContext, NULL); /* If the callback function returns DDENUMRET_CANCEL, we will stop enumerating devices */ if(rc == DDENUMRET_CANCEL) { retVal = DD_OK; } else { // not finished retVal = DDERR_UNSUPPORTED; } } return retVal; }
inline void CServiceModule::Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, UINT nServiceNameID, UINT nServiceDescID, const GUID* plibid) { CComModule::Init(p, h, plibid); m_bService = TRUE; LoadStringA(h, nServiceNameID, m_szServiceName, sizeof(m_szServiceName) / sizeof(TCHAR)); LoadStringA(h, nServiceDescID, m_szServiceDesc, sizeof(m_szServiceDesc) / sizeof(TCHAR)); // set up the initial service status m_hServiceStatus = NULL; m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; m_status.dwCurrentState = SERVICE_STOPPED; m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; m_status.dwWin32ExitCode = 0; m_status.dwServiceSpecificExitCode = 0; m_status.dwCheckPoint = 0; m_status.dwWaitHint = 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static char s1[100], s2[100], s3[100]; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); LoadStringA(hInst, 129, s1, 100); LoadStringA(hInst, 130, s2, 100); LoadStringA(hInst, 132, s3, 100); TextOutA(hdc, 10, 10, s1, 10); TextOutA(hdc, 10, 30, s2, 10); TextOutA(hdc, 10, 50, s3, 10); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
char *ViLoadStringA(HINSTANCE hInst, UINT id) { UINT tmp_size = 60000; char *tmp = Malloc(tmp_size); char *ret = NULL; if (LoadStringA(hInst, id, tmp, tmp_size) != 0) { ret = CopyStr(tmp); } Free(tmp); return ret; }
/* Convert a dllmode to a pretty string for display. TODO: use translations. */ static const char* mode_to_label(enum dllmode mode) { static char buffer[256]; UINT id = 0; switch( mode ) { case NATIVE: id = IDS_DLL_NATIVE; break; case BUILTIN: id = IDS_DLL_BUILTIN; break; case NATIVE_BUILTIN: id = IDS_DLL_NATIVE_BUILTIN; break; case BUILTIN_NATIVE: id = IDS_DLL_BUILTIN_NATIVE; break; case DISABLE: id = IDS_DLL_DISABLED; break; default: return "??"; } if (!LoadStringA( GetModuleHandleA(NULL), id, buffer, sizeof(buffer) )) buffer[0] = 0; return buffer; }
static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd) { IGenericSFImpl *This = (IGenericSFImpl *)iface; HRESULT hr = S_OK; TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd); if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS) return E_INVALIDARG; if (!pidl) { psd->fmt = DesktopSFHeader[iColumn].fmt; psd->cxChar = DesktopSFHeader[iColumn].cxChar; psd->str.uType = STRRET_CSTR; LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH); return S_OK; } /* the data from the pidl */ psd->str.uType = STRRET_CSTR; switch (iColumn) { case 0: /* name */ hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); break; case 1: /* size */ _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH); break; case 2: /* type */ _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH); break; case 3: /* date */ _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH); break; case 4: /* attributes */ _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH); break; } return hr; }
SeismicVideo::SeismicVideo( Universe &u, int number_of_frames, int threads_high, bool init_is_parallel) :numberOfFrames_(number_of_frames),initIsParallel(init_is_parallel),u_(u),threadsHigh(threads_high) { title = initIsParallel?titles[1]:titles[0]; #ifdef _WINDOWS gVideo = this; LoadStringA(video::win_hInstance, IDC_SEISMICSIMULATION, szWindowClass, MAX_LOADSTRING); memset(&wcex, 0, sizeof(wcex)); wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.hIcon = LoadIcon(video::win_hInstance, MAKEINTRESOURCE(IDI_SEISMICSIMULATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = LPCTSTR(IDC_SEISMICSIMULATION); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(video::win_hInstance, MAKEINTRESOURCE(IDI_SMALL)); win_set_class(wcex); // ascii convention here win_load_accelerators(IDC_SEISMICSIMULATION); #endif }
/** * This function checks the version of an iconpack. * If the icon pack's version differs from the desired one, * dialog with a warning is displayed. * * @param szIconPack - This is the path to the icon pack. * It can be absolute or relative. * * @return nothing **/ static void IcoLib_CheckIconPackVersion(LPTSTR szIconPack) { if (db_get_b(NULL, MODNAME, SET_ICONS_CHECKFILEVERSION, TRUE)) { if (szIconPack) { TCHAR szAbsolutePath[MAX_PATH]; PathToAbsoluteT(szIconPack, szAbsolutePath); HMODULE hIconDll = LoadLibrary(szAbsolutePath); if (hIconDll) { CHAR szFileVersion[64]; if (!LoadStringA(hIconDll, IDS_ICOPACKVERSION, szFileVersion, sizeof(szFileVersion)) || mir_strcmp(szFileVersion, "__UserInfoEx_IconPack_1.2__")) MsgErr(NULL, LPGENT("Warning: Your current IconPack's version differs from the one UserInfoEx is designed for.\nSome icons may not be displayed correctly")); FreeLibrary(hIconDll); } } else MsgErr(NULL, LPGENT("Warning: No IconPack found in one of the following directories: 'customize\\icons', 'icons' or 'plugins'!")); } }
HRESULT SHELL32_GetColumnDetails(const shvheader *data, int column, SHELLDETAILS *details) { details->fmt = data[column].fmt; details->cxChar = data[column].cxChar; if (SHELL_OsIsUnicode()) { details->str.u.pOleStr = CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR)); if (!details->str.u.pOleStr) return E_OUTOFMEMORY; details->str.uType = STRRET_WSTR; LoadStringW(shell32_hInstance, data[column].colnameid, details->str.u.pOleStr, MAX_PATH); } else { details->str.uType = STRRET_CSTR; LoadStringA(shell32_hInstance, data[column].colnameid, details->str.u.cStr, MAX_PATH); } return S_OK; }
int LoadStringW_AnyBuild( HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int nBufferCount //!< バッファのサイズ。文字単位。 ) { //まずはACHARでロード int nTmpCnt = nBufferCount*2+2; ACHAR* pTmp = new ACHAR[nTmpCnt]; int ret=LoadStringA(hInstance, uID, pTmp, nTmpCnt); //WCHARに変換 mbstowcs2(lpBuffer, pTmp, nBufferCount); int ret2=wcslen(lpBuffer); //後始末 delete[] pTmp; //結果 return ret2; }
static int GetIconPackVersion(HMODULE hDLL) { char szIDString[256]; int version = 0; if (LoadStringA(hDLL, IDS_IDENTIFY, szIDString, sizeof(szIDString)) == 0) version = 0; else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 1.0__")) version = 1; else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 2.0__")) version = 2; else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 3.0__")) version = 3; else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 3.5__")) version = 4; else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 5.0__")) version = 5; if (version < 5) CWarning::show(CWarning::WARN_ICONPACK_VERSION, MB_OK | MB_ICONERROR); return version; }
////////// // // Loads the indicated resource string from the localization file // ////// s8* CALLTYPE mc_loadResourceAsciiText(u32 tnResourceNumber) { u32 lnLength; SVvmmcResourceText* lr; s8 buffer[1024]; SStartEndCallback cb; // Try to find the resource we've already loaded cb._func = (u64)&iimc_loadResourceAsciiTextCallback; cb.extra = tnResourceNumber; lr = (SVvmmcResourceText*)vvm_SEChain_searchByCallback(&gseRootResourceTexts, &cb); if (lr) return(lr->text); // It's already been loaded // Try to locate it if (!LoadStringA(ghResourceDll, tnResourceNumber, buffer, sizeof(buffer))) return((s8*)cgcUnableToLocateResource); // Use the default failure string // Allocate the new item lr = (SVvmmcResourceText*)vvm_SEChain_append(&gseRootResourceTexts, vvm_getNextUniqueId(), vvm_getNextUniqueId(), sizeof(SVvmmcResourceText), _COMMON_START_END_BLOCK_SIZE, NULL); if (lr) { // Store the resource information lr->resourceNumber = tnResourceNumber; // Duplicate the loaded string lnLength = strlen(buffer) + 1; lr->text = (s8*)oss_alloc(lnLength, true); if (lr->text) memcpy(lr->text, buffer, lnLength - 1); // All done return(lr->text); } // If we get here, failure return(NULL); }
void controlyPlugin::getApps(QList<CatItem>* items) { int a = 0; // Get the control panel applications TCHAR infoBuf[32767]; if (!GetSystemDirectory(infoBuf, 32767)) { return; } QString buff = QString::fromUtf16((const ushort*) infoBuf); QDir qd(buff); QStringList files = qd.entryList(QStringList("*.cpl"), QDir::Files, QDir::Unsorted); foreach(QString file, files) { QString path = QDir::toNativeSeparators(qd.absoluteFilePath(file)); if (cache.count(file) > 0) { if (cache[file] != "") items->push_back(CatItem(path, cache[file], 0, getIcon())); continue; } union { NEWCPLINFOA NewCplInfoA; NEWCPLINFOW NewCplInfoW; } Newcpl; HINSTANCE hLib; // Library Handle to *.cpl file APPLET_PROC CplCall; // Pointer to CPlApplet() function LONG i; hLib = LoadLibrary((LPCTSTR) path.utf16()); if (hLib) { CplCall=(APPLET_PROC)GetProcAddress(hLib,"CPlApplet"); if (CplCall) { if (CplCall(NULL, CPL_INIT,0,0)) { for (i=0;i<CplCall(NULL,CPL_GETCOUNT,0,0);i++) { Newcpl.NewCplInfoA.dwSize = 0; Newcpl.NewCplInfoA.dwFlags = 0; a = CplCall(NULL,CPL_INQUIRE,i,(long)&Newcpl); if (Newcpl.NewCplInfoA.dwSize == sizeof(NEWCPLINFOW)) { // Case #1, CPL_INQUIRE has returned an Unicode String items->push_back(CatItem(path, QString::fromUtf16((const ushort*)Newcpl.NewCplInfoW.szName), 0, getIcon())); cache[file] = QString::fromUtf16((const ushort*)Newcpl.NewCplInfoW.szName); } else { // Case #2, CPL_NEWINQUIRE has returned an ANSI String if (Newcpl.NewCplInfoA.dwSize != sizeof(NEWCPLINFOA)) { // Case #3, CPL_NEWINQUIRE failed to return a string // Get the string from the *.cpl Resource instead CPLINFO CInfo; a = CplCall(NULL,CPL_INQUIRE,i,(long)&CInfo); LoadStringA(hLib,CInfo.idName, Newcpl.NewCplInfoA.szName,32); } // wchar_t tmpString[32]; // MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Newcpl.NewCplInfoA.szName, 32, tmpString, 32); items->push_back(CatItem(path, QString(Newcpl.NewCplInfoA.szName), 0, getIcon())); cache[file] = QString(Newcpl.NewCplInfoA.szName); } } // for CplCall(NULL,CPL_EXIT,0,0); } } FreeLibrary(hLib); } }
/** * Processes a software update command * * @param argc The number of arguments in argv * @param argv The arguments normally passed to updater.exe * argv[0] must be the path to updater.exe * @return TRUE if the update was successful. */ BOOL ProcessSoftwareUpdateCommand(DWORD argc, LPWSTR *argv) { BOOL result = TRUE; if (argc < 3) { LOG(("Not enough command line parameters specified. " "Updating update.status.\n")); // We can only update update.status if argv[1] exists. argv[1] is // the directory where the update.status file exists. if (argc > 1 || !WriteStatusFailure(argv[1], SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS)) { LOG(("Could not write update.status service update failure." "Last error: %d\n", GetLastError())); } return FALSE; } // Verify that the updater.exe that we are executing is the same // as the one in the installation directory which we are updating. // The installation dir that we are installing to is argv[2]. WCHAR installDirUpdater[MAX_PATH + 1]; wcsncpy(installDirUpdater, argv[2], MAX_PATH); if (!PathAppendSafe(installDirUpdater, L"updater.exe")) { LOG(("Install directory updater could not be determined.\n")); result = FALSE; } BOOL updaterIsCorrect; if (result && !VerifySameFiles(argv[0], installDirUpdater, updaterIsCorrect)) { LOG(("Error checking if the updaters are the same.\n" "Path 1: %ls\nPath 2: %ls\n", argv[0], installDirUpdater)); result = FALSE; } if (result && !updaterIsCorrect) { LOG(("The updaters do not match, udpater will not run.\n")); result = FALSE; } if (result) { LOG(("updater.exe was compared successfully to the installation directory" " updater.exe.\n")); } else { if (!WriteStatusFailure(argv[1], SERVICE_UPDATER_COMPARE_ERROR)) { LOG(("Could not write update.status updater compare failure.\n")); } return FALSE; } // Check to make sure the udpater.exe module has the unique updater identity. // This is a security measure to make sure that the signed executable that // we will run is actually an updater. HMODULE updaterModule = LoadLibrary(argv[0]); if (!updaterModule) { LOG(("updater.exe module could not be loaded. (%d)\n", GetLastError())); result = FALSE; } else { char updaterIdentity[64]; if (!LoadStringA(updaterModule, IDS_UPDATER_IDENTITY, updaterIdentity, sizeof(updaterIdentity))) { LOG(("The updater.exe application does not contain the Mozilla" " updater identity.\n")); result = FALSE; } if (strcmp(updaterIdentity, UPDATER_IDENTITY_STRING)) { LOG(("The updater.exe identity string is not valid.\n")); result = FALSE; } FreeLibrary(updaterModule); } if (result) { LOG(("The updater.exe application contains the Mozilla" " updater identity.\n")); } else { if (!WriteStatusFailure(argv[1], SERVICE_UPDATER_IDENTITY_ERROR)) { LOG(("Could not write update.status no updater identity.\n")); } return TRUE; } // Check for updater.exe sign problems BOOL updaterSignProblem = FALSE; #ifndef DISABLE_UPDATER_AUTHENTICODE_CHECK updaterSignProblem = !DoesBinaryMatchAllowedCertificates(argv[2], argv[0]); #endif // Only proceed with the update if we have no signing problems if (!updaterSignProblem) { BOOL updateProcessWasStarted = FALSE; if (StartUpdateProcess(argc, argv, updateProcessWasStarted)) { LOG(("updater.exe was launched and run successfully!\n")); LogFlush(); // We might not execute code after StartServiceUpdate because // the service installer will stop the service if it is running. StartServiceUpdate(argc, argv); } else { result = FALSE; LOG(("Error running update process. Updating update.status" " Last error: %d\n", GetLastError())); LogFlush(); // If the update process was started, then updater.exe is responsible for // setting the failure code. If it could not be started then we do the // work. We set an error instead of directly setting status pending // so that the app.update.service.errors pref can be updated when // the callback app restarts. if (!updateProcessWasStarted) { if (!WriteStatusFailure(argv[1], SERVICE_UPDATER_COULD_NOT_BE_STARTED)) { LOG(("Could not write update.status service update failure." "Last error: %d\n", GetLastError())); } } } } else { result = FALSE; LOG(("Could not start process due to certificate check error on " "updater.exe. Updating update.status. Last error: %d\n", GetLastError())); // When there is a certificate check error on the updater.exe application, // we want to write out the error. if (!WriteStatusFailure(argv[1], SERVICE_UPDATER_SIGN_ERROR)) { LOG(("Could not write pending state to update.status. (%d)\n", GetLastError())); } } LocalFree(argv); return result; }