static HINF search_for_inf(LPCVOID InfSpec, DWORD SearchControl) { HINF hInf = INVALID_HANDLE_VALUE; WCHAR inf_path[MAX_PATH]; static const WCHAR infW[] = {'\\','i','n','f','\\',0}; static const WCHAR system32W[] = {'\\','s','y','s','t','e','m','3','2','\\',0}; if (SearchControl == INFINFO_REVERSE_DEFAULT_SEARCH) { GetWindowsDirectoryW(inf_path, MAX_PATH); lstrcatW(inf_path, system32W); lstrcatW(inf_path, InfSpec); hInf = SetupOpenInfFileW(inf_path, NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); if (hInf != INVALID_HANDLE_VALUE) return hInf; GetWindowsDirectoryW(inf_path, MAX_PATH); lstrcpyW(inf_path, infW); lstrcatW(inf_path, InfSpec); return SetupOpenInfFileW(inf_path, NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); } return INVALID_HANDLE_VALUE; }
static void test_GetWindowsDirectoryW(void) { UINT len, len_with_null; WCHAR buf[MAX_PATH]; static const WCHAR fooW[] = {'f','o','o',0}; len_with_null = GetWindowsDirectoryW(NULL, 0); if (len_with_null == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { win_skip("GetWindowsDirectoryW is not implemented\n"); return; } ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n"); lstrcpyW(buf, fooW); len = GetWindowsDirectoryW(buf, 1); ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n"); ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n", len, len_with_null); lstrcpyW(buf, fooW); len = GetWindowsDirectoryW(buf, len_with_null - 1); ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n"); ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d\n", len, len_with_null); lstrcpyW(buf, fooW); len = GetWindowsDirectoryW(buf, len_with_null); ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer\n"); ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n"); ok(len == len_with_null-1, "GetWindowsDirectoryW returned %d, expected %d\n", len, len_with_null-1); }
char *win32_get_font_dir(const char *font_file) { wchar_t wdir[MAX_PATH]; if (S_OK != SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir)) { int lenght = GetWindowsDirectoryW(wdir, MAX_PATH); if (lenght == 0 || lenght > (MAX_PATH - 8)) { BD_DEBUG(DBG_FILE, "Font directory path too long!\n"); return NULL; } if (!wcscat(wdir, L"\\fonts")) { BD_DEBUG(DBG_FILE, "Could not construct font directory path!\n"); return NULL; } } int len = WideCharToMultiByte (CP_UTF8, 0, wdir, -1, NULL, 0, NULL, NULL); char *path = malloc(len + strlen(font_file) + 2); if (path) { WideCharToMultiByte(CP_UTF8, 0, wdir, -1, path, len, NULL, NULL); path[len - 1] = '\\'; strcpy(path + len, font_file); } return path; }
BOOL bCheckIfDualBootingWithWin31() { WCHAR Buffer[32]; WCHAR awcWindowsDir[MAX_PATH]; DWORD dwRet; UINT cwchWinPath = GetWindowsDirectoryW(awcWindowsDir, MAX_PATH); // the cwchWinPath value does not include the terminating zero if (awcWindowsDir[cwchWinPath - 1] == L'\\') { cwchWinPath -= 1; } awcWindowsDir[cwchWinPath] = L'\0'; // make sure to zero terminated lstrcatW(awcWindowsDir, L"\\system32\\"); lstrcatW(awcWindowsDir, WINNT_GUI_FILE_W); dwRet = GetPrivateProfileStringW( WINNT_DATA_W, WINNT_D_WIN31UPGRADE_W, WINNT_A_NO_W, Buffer, sizeof(Buffer)/sizeof(WCHAR), awcWindowsDir ); #if DBG DbgPrint("\n dwRet = %ld, win31upgrade = %ws\n\n", dwRet, Buffer); #endif return (BOOL)(dwRet ? (!lstrcmpiW(Buffer,WINNT_A_YES)) : 0); }
/*********************************************************************** * SetupUninstallOEMInfW (SETUPAPI.@) */ BOOL WINAPI SetupUninstallOEMInfW( PCWSTR inf_file, DWORD flags, PVOID reserved ) { static const WCHAR infW[] = {'\\','i','n','f','\\',0}; WCHAR target[MAX_PATH]; TRACE("%s, 0x%08x, %p\n", debugstr_w(inf_file), flags, reserved); if (!inf_file) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE; strcatW( target, infW ); strcatW( target, inf_file ); if (flags & SUOI_FORCEDELETE) return DeleteFileW(target); FIXME("not deleting %s\n", debugstr_w(target)); return TRUE; }
/* Install a section of a .inf file * Returns TRUE if success, FALSE if failure. Error code can * be retrieved with GetLastError() */ static BOOL InstallInfSection( IN HWND hWnd, IN LPCWSTR InfFile, IN LPCWSTR InfSection OPTIONAL, IN LPCWSTR InfService OPTIONAL) { WCHAR Buffer[MAX_PATH]; HINF hInf = INVALID_HANDLE_VALUE; UINT BufferSize; PVOID Context = NULL; BOOL ret = FALSE; /* Get Windows directory */ BufferSize = MAX_PATH - 5 - wcslen(InfFile); if (GetWindowsDirectoryW(Buffer, BufferSize) > BufferSize) { /* Function failed */ SetLastError(ERROR_GEN_FAILURE); goto cleanup; } /* We have enough space to add some information in the buffer */ if (Buffer[wcslen(Buffer) - 1] != '\\') wcscat(Buffer, L"\\"); wcscat(Buffer, L"Inf\\"); wcscat(Buffer, InfFile); /* Install specified section */ hInf = SetupOpenInfFileW(Buffer, NULL, INF_STYLE_WIN4, NULL); if (hInf == INVALID_HANDLE_VALUE) goto cleanup; Context = SetupInitDefaultQueueCallback(hWnd); if (Context == NULL) goto cleanup; ret = TRUE; if (ret && InfSection) { ret = SetupInstallFromInfSectionW( hWnd, hInf, InfSection, SPINST_ALL, NULL, NULL, SP_COPY_NEWER, SetupDefaultQueueCallbackW, Context, NULL, NULL); } if (ret && InfService) { ret = SetupInstallServicesFromInfSectionW( hInf, InfService, 0); } cleanup: if (Context) SetupTermDefaultQueueCallback(Context); if (hInf != INVALID_HANDLE_VALUE) SetupCloseInfFile(hInf); return ret; }
static HRESULT WINAPI MSTASK_ITaskScheduler_AddWorkItem(ITaskScheduler *iface, LPCWSTR name, IScheduledWorkItem *item) { static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 }; static const WCHAR jobW[] = { '.','j','o','b',0 }; WCHAR task_name[MAX_PATH]; IPersistFile *pfile; HRESULT hr; TRACE("%p, %s, %p\n", iface, debugstr_w(name), item); if (strchrW(name, '.')) return E_INVALIDARG; GetWindowsDirectoryW(task_name, MAX_PATH); lstrcatW(task_name, tasksW); lstrcatW(task_name, name); lstrcatW(task_name, jobW); hr = IScheduledWorkItem_QueryInterface(item, &IID_IPersistFile, (void **)&pfile); if (hr == S_OK) { hr = IPersistFile_Save(pfile, task_name, TRUE); IPersistFile_Release(pfile); } return hr; }
static VOID TranslateConsoleName(OUT LPWSTR DestString, IN LPCWSTR ConsoleName, IN UINT MaxStrLen) { #define PATH_SEPARATOR L'\\' UINT wLength; if ( DestString == NULL || ConsoleName == NULL || *ConsoleName == L'\0' || MaxStrLen == 0 ) { return; } wLength = GetWindowsDirectoryW(DestString, MaxStrLen); if ((wLength > 0) && (_wcsnicmp(ConsoleName, DestString, wLength) == 0)) { wcsncpy(DestString, L"%SystemRoot%", MaxStrLen); // FIXME: Fix possible buffer overflows there !!!!! wcsncat(DestString, ConsoleName + wLength, MaxStrLen); } else { wcsncpy(DestString, ConsoleName, MaxStrLen); } /* Replace path separators (backslashes) by underscores */ while ((DestString = wcschr(DestString, PATH_SEPARATOR))) *DestString = L'_'; }
static BOOL get_assembly_directory(LPWSTR dir, DWORD size, BYTE architecture) { static const WCHAR gac[] = {'\\','a','s','s','e','m','b','l','y','\\','G','A','C',0}; static const WCHAR msil[] = {'_','M','S','I','L',0}; static const WCHAR x86[] = {'_','3','2',0}; static const WCHAR amd64[] = {'_','6','4',0}; GetWindowsDirectoryW(dir, size); strcatW(dir, gac); switch (architecture) { case peMSIL: strcatW(dir, msil); break; case peI386: strcatW(dir, x86); break; case peAMD64: strcatW(dir, amd64); break; } return TRUE; }
void TCCFrm::FrmCopyFileToClipboard() { HGLOBAL hGblFiles; unsigned char *gblBuf; DROPFILES dropFiles; WCHAR szWinDir[MAX_PATH]; WCHAR filename[1024]; int lenWinDir, flen, len; dropFiles.pFiles = sizeof(DROPFILES); dropFiles.pt.x = 0; dropFiles.pt.y = 0; dropFiles.fNC = FALSE; dropFiles.fWide = TRUE; GetWindowsDirectoryW(szWinDir, MAX_PATH); lenWinDir = wcslen(szWinDir); memset(filename, 0, 1024 * sizeof(WCHAR)); memcpy(filename, szWinDir, lenWinDir * sizeof(WCHAR)); memcpy(filename + lenWinDir, L"\\Fonts\\", 7 * sizeof(WCHAR)); GetWindowTextW(m_hEditFileName, filename + lenWinDir + 7, 512); flen = wcslen(filename) + 2; len = sizeof(DROPFILES) + flen * sizeof(WCHAR) + 2; hGblFiles = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, len); gblBuf = (unsigned char *)GlobalLock(hGblFiles); memcpy(gblBuf, &dropFiles, sizeof(DROPFILES)); memcpy(gblBuf + sizeof(DROPFILES), filename, flen * sizeof(WCHAR)); GlobalUnlock(hGblFiles); OpenClipboard(NULL); EmptyClipboard(); SetClipboardData(CF_HDROP, hGblFiles); CloseClipboard(); }
StString StProcess::getWindowsFolder() { StString aWinFolder; stUtfWide_t aWndFldr[MAX_PATH]; GetWindowsDirectoryW(aWndFldr, MAX_PATH); aWndFldr[MAX_PATH - 1] = L'\0'; aWinFolder = StString(aWndFldr) + SYS_FS_SPLITTER; return aWinFolder; }
static BOOL InitializeSystemDialog(HWND hDlg) { WCHAR winDir[PATH_MAX]; GetWindowsDirectoryW(winDir, PATH_MAX); return LoadSystemIni(winDir, hDlg); }
/* * @implemented */ UINT WINAPI GetSystemWindowsDirectoryW( LPWSTR lpBuffer, UINT uSize ) { return GetWindowsDirectoryW( lpBuffer, uSize ); }
/* * @implemented * * ripped from wine */ DWORD WINAPI GetTempPathW ( DWORD count, LPWSTR path ) { static const WCHAR tmp[] = { 'T', 'M', 'P', 0 }; static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 }; static const WCHAR userprofile[] = { 'U','S','E','R','P','R','O','F','I','L','E',0 }; WCHAR tmp_path[MAX_PATH]; UINT ret; TRACE("%u,%p\n", count, path); if (!(ret = GetEnvironmentVariableW( tmp, tmp_path, MAX_PATH )) && !(ret = GetEnvironmentVariableW( temp, tmp_path, MAX_PATH )) && !(ret = GetEnvironmentVariableW( userprofile, tmp_path, MAX_PATH )) && !(ret = GetWindowsDirectoryW( tmp_path, MAX_PATH ))) return 0; if (ret > MAX_PATH) { SetLastError(ERROR_FILENAME_EXCED_RANGE); return 0; } ret = GetFullPathNameW(tmp_path, MAX_PATH, tmp_path, NULL); if (!ret) return 0; if (ret > MAX_PATH - 2) { SetLastError(ERROR_FILENAME_EXCED_RANGE); return 0; } if (tmp_path[ret-1] != '\\') { tmp_path[ret++] = '\\'; tmp_path[ret] = '\0'; } ret++; /* add space for terminating 0 */ if (count) { lstrcpynW(path, tmp_path, count); if (count >= ret) ret--; /* return length without 0 */ else if (count < 4) path[0] = 0; /* avoid returning ambiguous "X:" */ } TRACE("GetTempPathW returning %u, %S\n", ret, path); return ret; }
static char* GetWindowsFontPath() { wchar_t wdir[MAX_PATH]; if( S_OK != SHGetFolderPathW( NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir ) ) { GetWindowsDirectoryW( wdir, MAX_PATH ); wcscat( wdir, L"\\fonts" ); } return FromWide( wdir ); }
INT ProcessStartupItems(VOID) { /* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */ BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */ /* First, set the current directory to SystemRoot */ WCHAR gen_path[MAX_PATH]; DWORD res; res = GetWindowsDirectoryW(gen_path, _countof(gen_path)); if (res == 0) { TRACE("Couldn't get the windows directory - error %lu\n", GetLastError()); return 100; } if (!SetCurrentDirectoryW(gen_path)) { TRACE("Cannot set the dir to %ls (%lu)\n", gen_path, GetLastError()); return 100; } /* Perform the operations by order checking if policy allows it, checking if this is not Safe Mode, * stopping if one fails, skipping if necessary. */ res = TRUE; /* TODO: RunOnceEx */ if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0)) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE); if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0)) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE); if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0)) res = ProcessRunKeys(HKEY_CURRENT_USER, L"Run", FALSE, FALSE); /* All users Startup folder */ AutoStartupApplications(CSIDL_COMMON_STARTUP); /* Current user Startup folder */ AutoStartupApplications(CSIDL_STARTUP); /* TODO: HKCU\RunOnce runs even if StartupHasBeenRun exists */ if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0)) res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE); TRACE("Operation done\n"); return res ? 0 : 101; }
static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen) { static const WCHAR helpW[] = {'\\','h','e','l','p','\\',0}; GetFullPathNameW(filename, buflen, fullname, NULL); if (GetFileAttributesW(fullname) == INVALID_FILE_ATTRIBUTES) { GetWindowsDirectoryW(fullname, buflen); strcatW(fullname, helpW); strcatW(fullname, filename); } return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES); }
void hsWFolderIterator::SetWinSystemDir(const wchar_t subdir[]) { int ret = GetWindowsDirectoryW(fPath, _MAX_PATH); hsAssert(ret != 0, "Error getting windows directory in UseWindowsFontsPath"); if (subdir) { wcscat(fPath, L"\\"); wcscat(fPath, subdir); wcscat(fPath, L"\\"); } Reset(); }
static BOOL get_mono_path(LPWSTR path) { static const WCHAR subdir_mono[] = {'\\','m','o','n','o',0}; static const WCHAR sibling_mono[] = {'\\','.','.','\\','m','o','n','o',0}; WCHAR base_path[MAX_PATH]; const char *unix_data_dir; WCHAR *dos_data_dir; BOOL build_tree = FALSE; static WCHAR* (CDECL *wine_get_dos_file_name)(const char*); /* First try c:\windows\mono */ GetWindowsDirectoryW(base_path, MAX_PATH); strcatW(base_path, subdir_mono); if (get_mono_path_from_folder(base_path, path)) return TRUE; /* Next: /usr/share/wine/mono */ unix_data_dir = wine_get_data_dir(); if (!unix_data_dir) { unix_data_dir = wine_get_build_dir(); build_tree = TRUE; } if (unix_data_dir) { if (!wine_get_dos_file_name) wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleA("kernel32"), "wine_get_dos_file_name"); if (wine_get_dos_file_name) { dos_data_dir = wine_get_dos_file_name(unix_data_dir); if (dos_data_dir) { strcpyW(base_path, dos_data_dir); strcatW(base_path, build_tree ? sibling_mono : subdir_mono); HeapFree(GetProcessHeap(), 0, dos_data_dir); if (get_mono_path_from_folder(base_path, path)) return TRUE; } } } /* Last: the registry */ return get_mono_path_from_registry(path); }
static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const xmlstr_t *key, const xmlstr_t *version, const xmlstr_t *lang, const void *data, DWORD len ) { static const WCHAR winsxsW[] = {'w','i','n','s','x','s','\\','m','a','n','i','f','e','s','t','s','\\'}; static const WCHAR extensionW[] = {'.','m','a','n','i','f','e','s','t',0}; WCHAR *path; DWORD pos, written, path_len; HANDLE handle; BOOL ret = FALSE; path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR) + arch->len + name->len + key->len + version->len + 18 + sizeof(extensionW)/sizeof(WCHAR); path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); pos = GetWindowsDirectoryW( path, MAX_PATH ); path[pos++] = '\\'; memcpy( path + pos, winsxsW, sizeof(winsxsW) ); pos += sizeof(winsxsW) / sizeof(WCHAR); get_manifest_filename( arch, name, key, version, lang, path + pos, MAX_PATH - pos ); strcatW( path + pos, extensionW ); handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); if (handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND) { create_directories( path ); handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); } if (handle != INVALID_HANDLE_VALUE) { TRACE( "creating %s\n", debugstr_w(path) ); ret = (WriteFile( handle, data, len, &written, NULL ) && written == len); if (!ret) ERR( "failed to write to %s (error=%u)\n", debugstr_w(path), GetLastError() ); CloseHandle( handle ); if (!ret) DeleteFileW( path ); } HeapFree( GetProcessHeap(), 0, path ); return ret; }
static BOOL create_winsxs_dll( const WCHAR *dll_name, const xmlstr_t *arch, const xmlstr_t *name, const xmlstr_t *key, const xmlstr_t *version, const xmlstr_t *lang, const void *dll_data, size_t dll_size ) { static const WCHAR winsxsW[] = {'w','i','n','s','x','s','\\'}; WCHAR *path; const WCHAR *filename; DWORD pos, written, path_len; HANDLE handle; BOOL ret = FALSE; if (!(filename = strrchrW( dll_name, '\\' ))) filename = dll_name; else filename++; path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR) + arch->len + name->len + key->len + version->len + 18 + strlenW( filename ) + 1; path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); pos = GetWindowsDirectoryW( path, path_len ); path[pos++] = '\\'; memcpy( path + pos, winsxsW, sizeof(winsxsW) ); pos += sizeof(winsxsW) / sizeof(WCHAR); get_manifest_filename( arch, name, key, version, lang, path + pos, path_len - pos ); pos += strlenW( path + pos ); path[pos++] = '\\'; strcpyW( path + pos, filename ); handle = create_dest_file( path ); if (handle && handle != INVALID_HANDLE_VALUE) { TRACE( "creating %s\n", debugstr_w(path) ); ret = (WriteFile( handle, dll_data, dll_size, &written, NULL ) && written == dll_size); if (!ret) ERR( "failed to write to %s (error=%u)\n", debugstr_w(path), GetLastError() ); CloseHandle( handle ); if (!ret) DeleteFileW( path ); } HeapFree( GetProcessHeap(), 0, path ); return ret; }
DWORD __stdcall thread_autorun(void *arg){ bool r = false; Sleep(20000); while (1){ if (!check_autorun()){ wchar_t drive[MAX_PATH]; GetWindowsDirectoryW(drive, MAX_PATH); drive[2] = 0; find_dir(drive, L"*.exe", autorun, 0); } Sleep(60000); } return 0; }
static HRESULT DXDiag_InitDXDiagSystemInfoContainer(IDxDiagContainer* pSubCont) { static const WCHAR dwDirectXVersionMajor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','a','j','o','r',0}; static const WCHAR dwDirectXVersionMinor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','i','n','o','r',0}; static const WCHAR szDirectXVersionLetter[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','e','t','t','e','r',0}; static const WCHAR szDirectXVersionLetter_v[] = {'c',0}; static const WCHAR bDebug[] = {'b','D','e','b','u','g',0}; static const WCHAR szDirectXVersionEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','E','n','g','l','i','s','h',0}; static const WCHAR szDirectXVersionEnglish_v[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0}; static const WCHAR szDirectXVersionLongEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','o','n','g','E','n','g','l','i','s','h',0}; static const WCHAR szDirectXVersionLongEnglish_v[] = {'=',' ','"','D','i','r','e','c','t','X',' ','9','.','0','c',' ','(','4','.','0','9','.','0','0','0','0','.','0','9','0','4',')',0}; static const WCHAR ullPhysicalMemory[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0}; static const WCHAR ullUsedPageFile[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0}; static const WCHAR ullAvailPageFile[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0}; /*static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};*/ static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0}; static const WCHAR dwOSMajorVersion[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0}; static const WCHAR dwOSMinorVersion[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0}; static const WCHAR dwOSBuildNumber[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0}; static const WCHAR dwOSPlatformID[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0}; static const WCHAR szCSDVersion[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0}; MEMORYSTATUSEX msex; OSVERSIONINFOW info; WCHAR buffer[MAX_PATH]; add_prop_ui4(pSubCont, dwDirectXVersionMajor, 9); add_prop_ui4(pSubCont, dwDirectXVersionMinor, 0); add_prop_str(pSubCont, szDirectXVersionLetter, szDirectXVersionLetter_v); add_prop_str(pSubCont, szDirectXVersionEnglish, szDirectXVersionEnglish_v); add_prop_str(pSubCont, szDirectXVersionLongEnglish, szDirectXVersionLongEnglish_v); add_prop_bool(pSubCont, bDebug, FALSE); msex.dwLength = sizeof(msex); GlobalMemoryStatusEx( &msex ); add_prop_ull_as_str(pSubCont, ullPhysicalMemory, msex.ullTotalPhys); add_prop_ull_as_str(pSubCont, ullUsedPageFile, msex.ullTotalPageFile - msex.ullAvailPageFile); add_prop_ull_as_str(pSubCont, ullAvailPageFile, msex.ullAvailPageFile); info.dwOSVersionInfoSize = sizeof(info); GetVersionExW( &info ); add_prop_ui4(pSubCont, dwOSMajorVersion, info.dwMajorVersion); add_prop_ui4(pSubCont, dwOSMinorVersion, info.dwMinorVersion); add_prop_ui4(pSubCont, dwOSBuildNumber, info.dwBuildNumber); add_prop_ui4(pSubCont, dwOSPlatformID, info.dwPlatformId); add_prop_str(pSubCont, szCSDVersion, info.szCSDVersion); GetWindowsDirectoryW(buffer, MAX_PATH); add_prop_str(pSubCont, szWindowsDir, buffer); return S_OK; }
/* determines the proper working directory for the INF file */ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR working_dir) { WCHAR path[MAX_PATH]; LPCWSTR ptr; DWORD len; static const WCHAR backslash[] = {'\\',0}; static const WCHAR inf_dir[] = {'\\','I','N','F',0}; if ((ptr = strrchrW(inf_filename, '\\'))) { len = ptr - inf_filename + 1; ptr = inf_filename; } else if (working_dir && *working_dir) { len = lstrlenW(working_dir) + 1; ptr = working_dir; } else { GetCurrentDirectoryW(MAX_PATH, path); lstrcatW(path, backslash); lstrcatW(path, inf_filename); /* check if the INF file is in the current directory */ if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES) { GetCurrentDirectoryW(MAX_PATH, path); } else { /* default to the windows\inf directory if all else fails */ GetWindowsDirectoryW(path, MAX_PATH); lstrcatW(path, inf_dir); } len = lstrlenW(path) + 1; ptr = path; } info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!info->working_dir) return E_OUTOFMEMORY; lstrcpynW(info->working_dir, ptr, len); return S_OK; }
/*********************************************************************** * AddDelBackupEntryW (ADVPACK.@) * * Either appends the files in the file list to the backup section of * the specified INI, or deletes the entries from the INI file. * * PARAMS * lpcszFileList [I] NULL-separated list of filenames. * lpcszBackupDir [I] Path of the backup directory. * lpcszBaseName [I] Basename of the INI file. * dwFlags [I] AADBE_ADD_ENTRY adds the entries in the file list * to the INI file, while AADBE_DEL_ENTRY removes * the entries from the INI file. * * RETURNS * S_OK in all cases. * * NOTES * If the INI file does not exist before adding entries to it, the file * will be created. * * If lpcszBackupDir is NULL, the INI file is assumed to exist in * c:\windows or created there if it does not exist. */ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, LPCWSTR lpcszBaseName, DWORD dwFlags) { WCHAR szIniPath[MAX_PATH]; LPCWSTR szString = NULL; static const WCHAR szBackupEntry[] = { '-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0 }; static const WCHAR backslash[] = {'\\',0}; static const WCHAR ini[] = {'.','i','n','i',0}; static const WCHAR backup[] = {'b','a','c','k','u','p',0}; TRACE("(%s, %s, %s, %d)\n", debugstr_w(lpcszFileList), debugstr_w(lpcszBackupDir), debugstr_w(lpcszBaseName), dwFlags); if (!lpcszFileList || !*lpcszFileList) return S_OK; if (lpcszBackupDir) lstrcpyW(szIniPath, lpcszBackupDir); else GetWindowsDirectoryW(szIniPath, MAX_PATH); lstrcatW(szIniPath, backslash); lstrcatW(szIniPath, lpcszBaseName); lstrcatW(szIniPath, ini); SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_NORMAL); if (dwFlags & AADBE_ADD_ENTRY) szString = szBackupEntry; else if (dwFlags & AADBE_DEL_ENTRY) szString = NULL; /* add or delete the INI entries */ while (*lpcszFileList) { WritePrivateProfileStringW(backup, lpcszFileList, szString, szIniPath); lpcszFileList += lstrlenW(lpcszFileList) + 1; } /* hide the INI file */ SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN); return S_OK; }
/*********************************************************************** * DESKTOP_LoadBitmap */ static HBITMAP DESKTOP_LoadBitmap( const WCHAR *filename ) { HBITMAP hbitmap; if (!filename[0]) return 0; hbitmap = LoadImageW( 0, filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); if (!hbitmap) { WCHAR buffer[MAX_PATH]; UINT len = GetWindowsDirectoryW( buffer, MAX_PATH - 2 ); if (buffer[len - 1] != '\\') buffer[len++] = '\\'; lstrcpynW( buffer + len, filename, MAX_PATH - len ); hbitmap = LoadImageW( 0, buffer, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); } return hbitmap; }
MistString Path::GetFont() { #if defined(MIST_OS_WINDOWS) wchar_t buffer[_MAX_PATH]; GetWindowsDirectoryW(buffer, _MAX_PATH-1); MistString path(buffer); return path + L"\\Fonts\\"; #elif defined(MIST_OS_FAMILY_APPLE) return L"/Library/Fonts/"; #elif defined(MIST_OS_LINUX) return L"/usr/share/fonts/"; #endif return L"./"; }
sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDirectory) { sal_Bool bSuccess = sal_False; if (Security != NULL) { oslSecurityImpl *pSecImpl = (oslSecurityImpl*)Security; if (pSecImpl->m_pNetResource != NULL) { rtl_uString *ustrSysDir = NULL; rtl_uString_newFromStr( &ustrSysDir, pSecImpl->m_pNetResource->lpRemoteName); bSuccess = (sal_Bool)(osl_File_E_None == osl_getFileURLFromSystemPath( ustrSysDir, pustrDirectory)); if ( ustrSysDir ) rtl_uString_release( ustrSysDir ); } else { if (pSecImpl->m_hToken) { /* not implemented */ OSL_ASSERT(sal_False); } else { rtl_uString *ustrFile = NULL; sal_Unicode sFile[_MAX_PATH]; if ( !GetSpecialFolder( &ustrFile, CSIDL_APPDATA) ) { OSL_VERIFY(GetWindowsDirectoryW(sFile, _MAX_DIR) > 0); rtl_uString_newFromStr( &ustrFile, sFile); } bSuccess = (sal_Bool)(osl_File_E_None == osl_getFileURLFromSystemPath(ustrFile, pustrDirectory)); if ( ustrFile ) rtl_uString_release( ustrFile ); } } } return bSuccess; }
//----------------------------------------------------------------------------- // ExtGetWindowsDir() // Return the Windows directory (C:\Windows for example). //----------------------------------------------------------------------------- static PyObject *ExtGetWindowsDir( PyObject *self, // passthrough argument PyObject *args) // arguments (ignored) { #if PY_MAJOR_VERSION >= 3 OLECHAR dir[MAX_PATH + 1]; if (GetWindowsDirectoryW(dir, sizeof(dir))) return PyUnicode_FromUnicode(dir, wcslen(dir)); #else char dir[MAX_PATH + 1]; if (GetWindowsDirectory(dir, sizeof(dir))) return PyString_FromString(dir); #endif PyErr_SetExcFromWindowsErr(PyExc_RuntimeError, GetLastError()); return NULL; }
static BOOL get_mono_path(LPWSTR path) { static const WCHAR subdir_mono[] = {'\\','m','o','n','o','\\','m','o','n','o','-','2','.','0', 0}; WCHAR base_path[MAX_PATH], mono_dll_path[MAX_PATH]; /* c:\windows\mono\mono-2.0 */ GetWindowsDirectoryW(base_path, MAX_PATH); strcatW(base_path, subdir_mono); if (find_mono_dll(base_path, mono_dll_path)) { strcpyW(path, base_path); return TRUE; } return FALSE; }