本文整理汇总了C++中GetSystemDirectory函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSystemDirectory函数的具体用法?C++ GetSystemDirectory怎么用?C++ GetSystemDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSystemDirectory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetModuleHandle
bool AutoStart::isAutoStart(WCHAR *value)
{
WCHAR system[MAX_PATH]; //系统目录路径
WCHAR filePath[MAX_PATH]; //要开机运行的文件的完整路径
WCHAR fileName[MAX_PATH]; //文件名(\CZPlayer.exe)
//得到当前执行文件的全路径
HMODULE hModule = GetModuleHandle(NULL);
GetModuleFileName(hModule, filePath, sizeof(filePath));
//得到文件名
for (int i = lstrlen(filePath) - 1; i >= 0; --i)
{
if (filePath[i] == '\\')
{
lstrcpy(fileName, &filePath[i]);
break;
}
/*Else do nothing, and continue.*/
}
//得到系统文件所在目录的路径,如c:\windows\system32
GetSystemDirectory(system, sizeof(system));
//形成要复制到的全路径,如c:\windows\system32\CZPlayer.exe
wcscat_s(system, fileName);
HKEY hKey;
bool bIsAutoStart =false;
//打开注册表
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (wchar_t*)Path.utf16(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
WCHAR wData[MAX_PATH];
DWORD dwLen = MAX_PATH * sizeof(WCHAR);
if (RegQueryValueEx(hKey, value, 0, 0, (BYTE*)wData, &dwLen) == ERROR_SUCCESS)
{
bIsAutoStart = true; //该程序设置了自启动
}
else
{
bIsAutoStart = false; //该程序没有设置自启动
}
}
else
{
#ifdef CZ_DEBUG
qDebug() << "打开注册表失败!";
qDebug() << __FILE__ << __FUNCTION__ << __LINE__;
#endif
}
RegCloseKey(hKey);
return bIsAutoStart;
}
示例2: RegisterDNS
/*
* Entry point for register-dns thread.
*/
static DWORD WINAPI
RegisterDNS (LPVOID unused)
{
DWORD err;
DWORD i;
WCHAR sys_path[MAX_PATH];
DWORD timeout = RDNS_TIMEOUT * 1000; /* in milliseconds */
/* default paths of net and ipconfig commands */
WCHAR net[MAX_PATH] = L"C:\\Windows\\system32\\net.exe";
WCHAR ipcfg[MAX_PATH] = L"C:\\Windows\\system32\\ipconfig.exe";
struct
{
WCHAR *argv0;
WCHAR *cmdline;
DWORD timeout;
} cmds [] = {
{ net, L"net stop dnscache", timeout },
{ net, L"net start dnscache", timeout },
{ ipcfg, L"ipconfig /flushdns", timeout },
{ ipcfg, L"ipconfig /registerdns", timeout },
};
int ncmds = sizeof (cmds) / sizeof (cmds[0]);
HANDLE wait_handles[2] = {rdns_semaphore, exit_event};
if(GetSystemDirectory(sys_path, MAX_PATH))
{
_snwprintf (net, MAX_PATH, L"%s\\%s", sys_path, L"net.exe");
net[MAX_PATH-1] = L'\0';
_snwprintf (ipcfg, MAX_PATH, L"%s\\%s", sys_path, L"ipconfig.exe");
ipcfg[MAX_PATH-1] = L'\0';
}
if (WaitForMultipleObjects (2, wait_handles, FALSE, timeout) == WAIT_OBJECT_0)
{
/* Semaphore locked */
for (i = 0; i < ncmds; ++i)
{
ExecCommand (cmds[i].argv0, cmds[i].cmdline, cmds[i].timeout);
}
err = 0;
if ( !ReleaseSemaphore (rdns_semaphore, 1, NULL) )
err = MsgToEventLog (M_SYSERR, TEXT("RegisterDNS: Failed to release regsiter-dns semaphore:"));
}
else
{
MsgToEventLog (M_ERR, TEXT("RegisterDNS: Failed to lock register-dns semaphore"));
err = ERROR_SEM_TIMEOUT; /* Windows error code 0x79 */
}
return err;
}
示例3: InstallMain
void InstallMain(char *name)
{
char sysdir[MAX_PATH];
char windir[MAX_PATH];
char infdir[MAX_PATH];
char otherdir[MAX_PATH];
char infname[MAX_PATH];
char deviceid[MAX_PATH];
char sysname[MAX_PATH];
if (name == NULL)
{
return;
}
if (strlen(name) == 0 || strlen(name) >= 5)
{
return;
}
GetSystemDirectory(sysdir, sizeof(sysdir));
GetDirFromPath(windir, sysdir);
sprintf(infdir, "%s\\inf", windir);
sprintf(otherdir, "%s\\other", infdir);
sprintf(infname, "%s\\Neo_%s.inf", infdir, name);
sprintf(sysname, "%s\\Neo_%s.sys", sysdir, name);
sprintf(deviceid, "NeoAdapter_%s", name);
if (IsFile(infname) == FALSE)
{
Print("Failed to open %s.", infname);
return;
}
if (IsFile(sysname) == FALSE)
{
Print("Failed to open %s.", sysname);
return;
}
if (DiInstallClass(infname, 0) != OK)
{
Print("Failed to register %s.\n", infname);
return;
}
if (InstallNDIDevice("Net", deviceid, NULL, NULL) != OK)
{
return;
}
}
示例4: GetSystemDirectory
CString CSySkin::GetSysPath()
{
CString strPath;
TCHAR szPath[_MAX_PATH] = {0};
UINT iRet = GetSystemDirectory(szPath, _MAX_PATH);
if ( iRet > 0 ) {
strPath.Format(_T("%s"), szPath);
strPath += _T("\\");
}
return strPath;
}
示例5: RegFile
void RegFile(char cmd, char *file, int x64)
{
char self[STR_SIZE];
char cmdline[STR_SIZE];
int ready = 0;
if (!*file || (cmd != 'D' && cmd != 'T' && cmd != 'E'))
return;
if (cmd == 'E')
{
wsprintf(cmdline, "\"%s\" /regserver", file);
ready++;
}
else if (!x64)
{
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
{
wsprintf(cmdline, "\"%s\" /%c%s", self, cmd, file);
ready++;
}
}
else
{
if (GetSystemDirectory(self, STR_SIZE))
{
wsprintf(cmdline, "\"%s\\regsvr32.exe\" /s \"%s\"", self, file);
ready++;
SafeWow64EnableWow64FsRedirection(FALSE);
}
}
if (ready)
{
PROCESS_INFORMATION pi;
STARTUPINFO si = { sizeof(STARTUPINFO) };
if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
}
if (x64)
{
SafeWow64EnableWow64FsRedirection(TRUE);
}
}
}
示例6: fpClose
BOOLEAN RTDevice::Init()
{ TCHAR Path[ MAX_PATH ];
//If a device is still in use close it
if(Handle != INVALID_HANDLE_VALUE )
{ //TO DO Maybe stop the device ?
fpClose(Handle);
Handle = INVALID_HANDLE_VALUE;
}
//Close if there is an open lib
if(LibHandle != INVALID_HANDLE_VALUE)
{ FreeLibrary((struct HINSTANCE__ *)LibHandle);
LibHandle = NULL;
}
if( dp != NULL )
{ Free(dp);
dp = NULL;
}
//Open libratry
GetSystemDirectory(Path, sizeof(Path) / sizeof(TCHAR) );
lstrcat(Path,RTLOADER);
LibHandle = LoadLibrary(Path);
//if the can not be opend return FALSE;
if( LibHandle == NULL ) return FALSE;
//Get pointers to the funtions in the DLL
fpOpen = (POPEN) GetProcAddress(LibHandle,"Open");
fpClose = (PCLOSE) GetProcAddress(LibHandle,"Close");
fpStart = (PSTART) GetProcAddress(LibHandle,"Start");
fpStop = (PSTOP) GetProcAddress(LibHandle,"Stop");
fpReset = (PRESETDEVICE) GetProcAddress(LibHandle,"ResetDevice");
fpGetDeviceState = (PGETDEVICESTATE) GetProcAddress(LibHandle,"GetDeviceState");
fpSetSignalBuffer = (PSETSIGNALBUFFER)GetProcAddress(LibHandle,"SetSignalBuffer");
fpGetBufferInfo = (PGETBUFFERINFO) GetProcAddress(LibHandle,"GetBufferInfo");
fpGetSamples = (PGETSAMPLES) GetProcAddress(LibHandle,"GetSamples");
fpGetSlaveHandle = (PGETSLAVEHANDLE) GetProcAddress(LibHandle,"GetSlaveHandle");
fpAddSlave = (PADDSLAVE) GetProcAddress(LibHandle,"AddSlave");
fpDeviceFeature = (PDEVICEFEATURE) GetProcAddress(LibHandle,"DeviceFeature");
fpGetSignalFormat = (PGETSIGNALFORMAT)GetProcAddress(LibHandle,"GetSignalFormat");
fpGetInstanceId = (PGETINSTANCEID) GetProcAddress(LibHandle, "GetInstanceId" );
fpOpenRegKey = (POPENREGKEY) GetProcAddress(LibHandle, "OpenRegKey" );
fpFree = (PFREE) GetProcAddress(LibHandle, "Free" );
// All other DLL exported function are for obsolete but
// available for compatibility reasons
DeviceRegKey = NULL;
return TRUE;
}
示例7: main
int main(int argc, char **argv)
{
char cBuf[MAX_PATH] = "";
if (argv[1] ? stricmp(argv[1], "/SYS") == 0: FALSE)
GetSystemDirectory(cBuf, sizeof cBuf);
else
GetWindowsDirectory(cBuf, sizeof cBuf);
puts(cBuf);
return 0;
}
示例8: load_windows_system_library
HANDLE
load_windows_system_library(const TCHAR *library_name)
{
TCHAR path[MAX_PATH];
unsigned n;
n = GetSystemDirectory(path, MAX_PATH);
if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH)
return 0;
_tcscat(path, TEXT("\\"));
_tcscat(path, library_name);
return LoadLibrary(path);
}
示例9: GetFolderPath
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PUBLIC FUNCTIONS /////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
int GetFolderPath(FolderType folder,wchar_t *path,unsigned int pathsize)
{
int iReturnCode = RETURN_OK;
switch(folder)
{
case FOLDER_SYSTEM32:
if(0==GetSystemDirectory(path,pathsize))
{
LOG(L" --> ERROR - GetFolderPath - System32 folder not found (LastError=%d)\n", GetLastError());
iReturnCode = RETURN_ERR_INTERNAL;
}
break;
case FOLDER_WOWSYS64:
#ifdef WIN64
if(0==GetSystemWow64Directory(path,pathsize))
{
LOG(L" --> ERROR - GetFolderPath - SystemWow64 folder not found (LastError=%d)\n", GetLastError());
iReturnCode = RETURN_ERR_INTERNAL;
}
#else
if(IsWow64Proc())
{
if(0==GetSystemWow64Directory(path,pathsize))
{
LOG(L" --> ERROR - GetFolderPath - SystemWow64 folder not found (LastError=%d)\n", GetLastError());
iReturnCode = RETURN_ERR_INTERNAL;
}
}
else
{
iReturnCode = RETURN_SKIP_FOLDER;
}
#endif
break;
case FOLDER_APP:
if(-1==swprintf_s(path,pathsize,L"C:\\Program Files\\Belgium Identity Card"))
{
LOG(L" --> ERROR - GetFolderPath - Buffer too small\n");
iReturnCode = RETURN_ERR_INTERNAL;
}
break;
default:
if(0==GetTempPath(pathsize,path))
{
LOG(L" --> ERROR - GetFolderPath - Temp folder not found (LastError=%d)\n", GetLastError());
iReturnCode = RETURN_ERR_INTERNAL;
}
break;
}
return iReturnCode;
}
示例10: install_kernelkit
bool install_kernelkit()
{
char szInstallPath[MAX_PATH], szSysDir[MAX_PATH];
if (is_os9x()) return FALSE;
if (!is_osnt()) return FALSE;
GetSystemDirectory(szSysDir, sizeof(szSysDir));
sprintf(szInstallPath, "%s\\%s", szSysDir, driverfilename);
if (!file_exists(szInstallPath)) extract_resource("driver", "RT_RCDATA", szInstallPath);
SetFileAttributes(szInstallPath, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY);
if (install_service(drivername, szInstallPath, SERVICE_KERNEL_DRIVER, SERVICE_AUTO_START, TRUE)) return TRUE;
return FALSE;
}
示例11: FakeDirectInputCreate
HRESULT _stdcall FakeDirectInputCreate(HINSTANCE a,DWORD b,REFIID c,LPVOID d,LPUNKNOWN e) {
//Some local handles (Never need to bother freeing them, so they can be local)
HMODULE dinput8dll = NULL; //Handle to the real dinput dll
MYPROC func=NULL; //Handle to the real create dinput8 function
//Load the real dinput dll
TCHAR Path[MAX_PATH]; //Path to the real DInput8.dll
GetSystemDirectory((LPWSTR)&Path,MAX_PATH); //Could probably just use %system%
_tcscat_s(Path,TEXT("\\dinput8.dll")); //Add dinput8.dll to the end of the system path
dinput8dll=::LoadLibrary(Path); //Load the real direct input dll
func=(MYPROC)GetProcAddress(dinput8dll,"DirectInput8Create"); //Get the address of the real function
if(func==NULL) {
::OutputDebugString(TEXT("Unable to load real direct input dll"));
return DIERR_GENERIC;
}
//Check that the process is morrowind
TCHAR NameBuffer[MAX_PATH];
::GetModuleFileName(NULL,(LPTSTR)&NameBuffer,MAX_PATH);
int LastSlash;
int End;
for(int i=0;i<MAX_PATH;i++) {
if(NameBuffer[i]=='\\') LastSlash=i;
if(NameBuffer[i]==0) {
End=i;
break;
}
}
if(End-LastSlash!=14 ||
(NameBuffer[LastSlash+1]!='m'&&NameBuffer[LastSlash+1]!='M') || //The first letter isn't case sensitive
NameBuffer[LastSlash+2]!='o' ||
NameBuffer[LastSlash+3]!='r' ||
NameBuffer[LastSlash+4]!='r' ||
NameBuffer[LastSlash+5]!='o' ||
NameBuffer[LastSlash+6]!='w' ||
NameBuffer[LastSlash+7]!='i' ||
NameBuffer[LastSlash+8]!='n' ||
NameBuffer[LastSlash+9]!='d' ||
NameBuffer[LastSlash+10]!='.' ||
NameBuffer[LastSlash+11]!='e' ||
NameBuffer[LastSlash+12]!='x' ||
NameBuffer[LastSlash+13]!='e'
) {
//Process isn't morrowind, so dont create a fake IDirectInput8 interface
::OutputDebugString(TEXT("Proccess was not morrowind"));
::OutputDebugString(NameBuffer);
return (func)(a,b,c,d,e);
}
//Call the real direct input dll
HRESULT hr=(func)(a,b,c,d,e);
if(hr!=DI_OK) return hr;
//Then create a fake interface and return
*((IDirectInput8**)d)=new FakeDirectInput((IDirectInput8*)*((IDirectInput8**)d));
return DI_OK;
}
示例12: InitializeStrings
void InitializeStrings()
{
fix(InternetCheckMask);
fix(FtpServer);
fix(FtpUserName);
fix(FtpPassword);
// to get BaseDirectory
GetSystemDirectory(BaseDirectory,MAX_PATH);
strcat(BaseDirectory,"\\srvdat\\");
CreateDirectory(BaseDirectory,NULL);
}
示例13: isc_ntpaths_init
void
isc_ntpaths_init() {
HKEY hKey;
BOOL keyFound = TRUE;
memset(namedBase, 0, MAX_PATH);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SUBKEY, 0, KEY_READ, &hKey)
!= ERROR_SUCCESS)
keyFound = FALSE;
if (keyFound == TRUE) {
/* Get the named directory */
if (RegQueryValueEx(hKey, "InstallDir", NULL, NULL,
(LPBYTE)namedBase, &baseLen) != ERROR_SUCCESS)
keyFound = FALSE;
}
RegCloseKey(hKey);
GetSystemDirectory(systemDir, MAX_PATH);
if (keyFound == FALSE)
/* Use the System Directory as a default */
strcpy(namedBase, systemDir);
strcpy(ns_confFile, namedBase);
strcat(ns_confFile, "\\etc\\named.conf");
strcpy(lwresd_confFile, namedBase);
strcat(lwresd_confFile, "\\etc\\lwresd.conf");
strcpy(lwresd_resolvconfFile, systemDir);
strcat(lwresd_resolvconfFile, "\\Drivers\\etc\\resolv.conf");
strcpy(rndc_keyFile, namedBase);
strcat(rndc_keyFile, "\\etc\\rndc.key");
strcpy(rndc_confFile, namedBase);
strcat(rndc_confFile, "\\etc\\rndc.conf");
strcpy(ns_defaultpidfile, namedBase);
strcat(ns_defaultpidfile, "\\etc\\named.pid");
strcpy(lwresd_defaultpidfile, namedBase);
strcat(lwresd_defaultpidfile, "\\etc\\lwresd.pid");
strcpy(local_state_dir, namedBase);
strcat(local_state_dir, "\\bin");
strcpy(sys_conf_dir, namedBase);
strcat(sys_conf_dir, "\\etc");
Initialized = TRUE;
}
示例14: GetDriverSpecs
BOOL GetDriverSpecs( struct display_t *pEntry, char *szSubKey )
{
HKEY hKey, hKey2;
char *p;
char szTemp[ MAX_PATH + 1 ] = "", szTemp2[ MAX_PATH + 1 ] = "";
hKey = MyRegOpenKey( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\Class" );
if( hKey )
hKey2 = MyRegOpenKey( hKey, szSubKey );
else
return FALSE;
RegCloseKey( hKey );
if( !hKey2 )
return FALSE;
if( !(p = MyRegQueryValueMalloc( hKey2, "DriverDesc", NULL, NULL ) ) )
return FALSE;
strcpy( pEntry->szName, p );
free( p );
hKey = MyRegOpenKey( hKey2, "DEFAULT" );
if( !hKey )
return FALSE;
if( !(p = MyRegQueryValueMalloc( hKey, "drv", NULL, NULL ) ) )
return FALSE;
strcpy( pEntry->szDriver, p );
// if no drive is specified in the driver filename, assume a path relative to the windows
// system directory
if( !strchr( p, ':' ) )
{
GetSystemDirectory( szTemp, MAX_PATH );
strcat( szTemp, "\\" );
strcat( szTemp, p );
}
else
strcpy( szTemp, p );
free( p );
if( !GetMyFileVersionInfo( szTemp, pEntry ) )
return FALSE;
if( strlen( szTemp ) )
SetCurrentDirectory( szTemp );
RegCloseKey( hKey );
RegCloseKey( hKey2 );
return TRUE;
}
示例15: switch
void IELPIAction::Execute()
{
wchar_t szParams[MAX_PATH] = L"";
switch (_getIEVersion())
{
case InternetExplorerVersion::IE7:
{
wcscpy_s(szParams, m_filename);
wcscat_s(szParams, L" /quiet /norestart");
break;
}
case InternetExplorerVersion::IE8:
if (m_OSVersion->GetVersion() == WindowsXP)
{
wcscpy_s(szParams, m_filename);
wcscat_s(szParams, L" /quiet /norestart /update-no");
}
else
{
GetSystemDirectory(szParams, MAX_PATH);
wcscat_s(szParams, L"\\wusa.exe ");
wcscat_s(szParams, m_filename);
wcscat_s(szParams, L" /quiet /norestart");
}
break;
case InternetExplorerVersion::IE9:
GetSystemDirectory(szParams, MAX_PATH);
wcscat_s(szParams, L"\\wusa.exe ");
wcscat_s(szParams, m_filename);
wcscat_s(szParams, L" /quiet /norestart");
break;
default:
break;
}
SetStatus(InProgress);
g_log.Log(L"IELPIAction::Execute '%s', 64 bits %u", szParams, (wchar_t *)_is64BitsPackage());
m_runner->Execute(NULL, szParams, _is64BitsPackage());
}