当前位置: 首页>>代码示例>>C++>>正文


C++ GetWindowsDirectoryW函数代码示例

本文整理汇总了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;
}
开发者ID:GYGit,项目名称:reactos,代码行数:29,代码来源:query.c

示例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);
}
开发者ID:AmesianX,项目名称:wine,代码行数:33,代码来源:directory.c

示例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;
}
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:25,代码来源:dirs_win32.c

示例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);
}
开发者ID:Gaikokujin,项目名称:WinNT4,代码行数:33,代码来源:fntsweep.c

示例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;
}
开发者ID:CSRedRat,项目名称:RosWine,代码行数:28,代码来源:misc.c

示例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;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:64,代码来源:install.c

示例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;
}
开发者ID:wine-mirror,项目名称:wine,代码行数:25,代码来源:task_scheduler.c

示例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'_';
}
开发者ID:Strongc,项目名称:reactos,代码行数:30,代码来源:settings.c

示例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;
}
开发者ID:r6144,项目名称:wine,代码行数:28,代码来源:asmcache.c

示例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();
}
开发者ID:Lichtavat,项目名称:TCAX,代码行数:31,代码来源:fontColor.cpp

示例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;
}
开发者ID:angelstudio,项目名称:sview,代码行数:8,代码来源:StProcess.cpp

示例12: InitializeSystemDialog

static BOOL
InitializeSystemDialog(HWND hDlg)
{
    WCHAR winDir[PATH_MAX];

    GetWindowsDirectoryW(winDir, PATH_MAX);
    return LoadSystemIni(winDir, hDlg);
}
开发者ID:rmallof,项目名称:reactos,代码行数:8,代码来源:systempage.c

示例13: GetSystemWindowsDirectoryW

/*
 * @implemented
 */
UINT
WINAPI
GetSystemWindowsDirectoryW(
	LPWSTR	lpBuffer,
	UINT	uSize
	)
{
    return GetWindowsDirectoryW( lpBuffer, uSize );
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:12,代码来源:curdir.c

示例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;

}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:62,代码来源:curdir.c

示例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 );
}
开发者ID:nunoneto,项目名称:vlc,代码行数:10,代码来源:platform_fonts.c


注:本文中的GetWindowsDirectoryW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。