本文整理匯總了C++中GetWindowsDirectoryW函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetWindowsDirectoryW函數的具體用法?C++ GetWindowsDirectoryW怎麽用?C++ GetWindowsDirectoryW使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetWindowsDirectoryW函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: search_for_inf
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;
}
示例2: test_GetWindowsDirectoryW
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);
}
示例3: GetWindowsDirectoryW
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;
}
示例4: bCheckIfDualBootingWithWin31
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);
}
示例5: SetupUninstallOEMInfW
/***********************************************************************
* SetupUninstallOEMInfW ([email protected])
*/
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;
}
示例6: InstallInfSection
/* 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;
}
示例7: MSTASK_ITaskScheduler_AddWorkItem
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;
}
示例8: TranslateConsoleName
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'_';
}
示例9: get_assembly_directory
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;
}
示例10: sizeof
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();
}
示例11: GetWindowsDirectoryW
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;
}
示例12: InitializeSystemDialog
static BOOL
InitializeSystemDialog(HWND hDlg)
{
WCHAR winDir[PATH_MAX];
GetWindowsDirectoryW(winDir, PATH_MAX);
return LoadSystemIni(winDir, hDlg);
}
示例13: GetSystemWindowsDirectoryW
/*
* @implemented
*/
UINT
WINAPI
GetSystemWindowsDirectoryW(
LPWSTR lpBuffer,
UINT uSize
)
{
return GetWindowsDirectoryW( lpBuffer, uSize );
}
示例14: GetTempPathW
/*
* @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;
}
示例15: GetWindowsFontPath
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 );
}