您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetWindowsDirectory函数代码示例

51自学网 2021-06-01 21:18:11
  C++
这篇教程C++ GetWindowsDirectory函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetWindowsDirectory函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowsDirectory函数的具体用法?C++ GetWindowsDirectory怎么用?C++ GetWindowsDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetWindowsDirectory函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: noise_get_heavy

void noise_get_heavy(void (*func) (void *, int)){    HANDLE srch;    WIN32_FIND_DATA finddata;    DWORD pid;    char winpath[MAX_PATH + 3];    GetWindowsDirectory(winpath, sizeof(winpath));    strcat(winpath, "//*");    srch = FindFirstFile(winpath, &finddata);    if (srch != INVALID_HANDLE_VALUE) {	do {	    func(&finddata, sizeof(finddata));	} while (FindNextFile(srch, &finddata));	FindClose(srch);    }    pid = GetCurrentProcessId();    func(&pid, sizeof(pid));    read_random_seed(func);    /* Update the seed immediately, in case another instance uses it. */    random_save_seed();}
开发者ID:AlexKir,项目名称:Far-NetBox,代码行数:24,


示例2: GetWindowsDirectory

//////////////////// Set "hand" cursor to cue user that this is a link. If app has not set// g_hCursorLink, then try to get the cursor from winhlp32.exe,// resource 106, which is a pointing finger. This is a bit of a kludge,// but it works.//BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message){	if (g_hCursorLink == NULL) {		static BOOL bTriedOnce = FALSE;		if (!bTriedOnce) {         CString windir;         GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);         windir.ReleaseBuffer();         windir += _T("//winhlp32.exe");         HMODULE hModule = LoadLibrary(windir);			if (hModule) {				g_hCursorLink =					CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));			}			FreeLibrary(hModule);			bTriedOnce = TRUE;		}	}	if (g_hCursorLink) {		::SetCursor(g_hCursorLink);		return TRUE;	}	return FALSE;}
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:30,


示例3: noise_get_heavy

void noise_get_heavy(void (*func) (void *, int)) {    HANDLE srch;    HANDLE seedf;    WIN32_FIND_DATA finddata;    char winpath[MAX_PATH+3];    GetWindowsDirectory(winpath, sizeof(winpath));    strcat(winpath, "//*");    srch = FindFirstFile(winpath, &finddata);    if (srch != INVALID_HANDLE_VALUE) {	do {	    func(&finddata, sizeof(finddata));	} while (FindNextFile(srch, &finddata));	FindClose(srch);    }    if (!seedpath[0])	get_seedpath();    seedf = CreateFile(seedpath, GENERIC_READ,		       FILE_SHARE_READ | FILE_SHARE_WRITE,		       NULL, OPEN_EXISTING, 0, NULL);    if (seedf != INVALID_HANDLE_VALUE) {	while (1) {	    char buf[1024];	    DWORD len;	    if (ReadFile(seedf, buf, sizeof(buf), &len, NULL) && len)		func(buf, len);	    else		break;	}	CloseHandle(seedf);    }}
开发者ID:rdebath,项目名称:sgt,代码行数:36,


示例4: location

/***************************************************************************   Function:   FixFilePath   Purpose:    Adds the correct path string to a file name according                to given file location    Input:      Original file name               File location (Windows dir, System dir, Current dir or none)   Output:     TRUE only if successful   Remarks:    Trashes original file name****************************************************************************/BOOL CDLLVersion::FixFilePath (char * szFileName, int FileLoc){    char    szPathStr [_MAX_PATH];      // Holds path prefix       switch (FileLoc)     {        case WIN_DIR:            // Get the name of the windows directory            if (GetWindowsDirectory (szPathStr, _MAX_PATH) ==  0)                  return FALSE;   // Cannot get windows directory            break;        case SYS_DIR:            // Get the name of the windows SYSTEM directory            if (GetSystemDirectory (szPathStr, _MAX_PATH) ==  0)                  return FALSE;   // Cannot get system directory            break;        case CUR_DIR:            // Get the name of the current directory            if (GetCurrentDirectory (_MAX_PATH, szPathStr) ==  0)                  return FALSE;   // Cannot get current directory            break;        case NO_DIR:            lstrcpy (szPathStr,"");            break;        default:            return FALSE;    }    lstrcat (szPathStr, _T("//"));    lstrcat (szPathStr, szFileName);    lstrcpy (szFileName, szPathStr);    return TRUE;}            
开发者ID:AnthonyNystrom,项目名称:GenXSource,代码行数:51,


示例5: dha_uninstall

int dha_uninstall(void){	SC_HANDLE hSCManager = NULL;	SC_HANDLE hService = NULL;	char szPath[MAX_PATH];	int result = 0;	hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);	hService = OpenService(hSCManager, DRV_NAME, SERVICE_ALL_ACCESS);	dha_stop();	result = DeleteService(hService);	if(!result) print_last_error("Error while deleting service");	CloseServiceHandle(hService);	CloseServiceHandle(hSCManager);	GetWindowsDirectory(szPath, MAX_PATH);	strcpy(szPath + strlen(szPath), "//system32//drivers//" DRV_FILENAME);	DeleteFile(szPath);	return 0;}
开发者ID:TI8XEmulator,项目名称:graph89,代码行数:24,


示例6: TRACE

///////////////////////////////////////////////////////////////////////////////// SetDefaultCursorvoid CXHyperLink::SetDefaultCursor(){	if (m_hLinkCursor == NULL)				// No cursor handle - try to load one	{		// First try to load the Win98 / Windows 2000 hand cursor		TRACE(_T("loading from IDC_HAND/n"));		m_hLinkCursor = AfxGetApp()->LoadStandardCursor(IDC_HAND);		if (m_hLinkCursor == NULL)			// Still no cursor handle - 											// load the WinHelp hand cursor		{			// The following appeared in Paul DiLascia's Jan 1998 MSJ articles.			// It loads a "hand" cursor from the winhlp32.exe module.			TRACE(_T("loading from winhlp32/n"));			// Get the windows directory			CString strWndDir;			GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);			strWndDir.ReleaseBuffer();			strWndDir += _T("//winhlp32.exe");			// This retrieves cursor #106 from winhlp32.exe, which is a hand pointer			HMODULE hModule = LoadLibrary(strWndDir);			if (hModule) 			{				HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));				if (hHandCursor)					m_hLinkCursor = CopyCursor(hHandCursor);				FreeLibrary(hModule);			}		}	}}
开发者ID:Bitfall,项目名称:AppWhirr-client,代码行数:38,


示例7: get_home

static voidget_home(void){    int len;    char tmpstr[MAX_PATH+1];    char* homedrive;    char* homepath;    homedrive = get_env("HOMEDRIVE");    homepath = get_env("HOMEPATH");    if (!homedrive || !homepath) {	if (len = GetWindowsDirectory(tmpstr,MAX_PATH)) {	    home = emalloc(len+1);	    strcpy(home,tmpstr);	} else	    error("HOMEDRIVE or HOMEPATH is not set and GetWindowsDir failed");    } else {	home = emalloc(strlen(homedrive)+strlen(homepath)+1);	strcpy(home, homedrive);	strcat(home, homepath);    }    free_env_val(homedrive);    free_env_val(homepath);}
开发者ID:AugustoFernandes,项目名称:otp,代码行数:24,


示例8: php_init_config

int php_init_config(char *php_ini_path_override){	char *env_location, *php_ini_search_path;	int safe_mode_state;	char *open_basedir;	int free_ini_search_path=0;	zend_file_handle fh;	PLS_FETCH();	if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {		return FAILURE;	}	zend_llist_init(&extension_lists.engine, sizeof(zval), (llist_dtor_func_t) free_estring, 1);	zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t)  ZVAL_DESTRUCTOR, 1);		safe_mode_state = PG(safe_mode);	open_basedir = PG(open_basedir);	env_location = getenv("PHPRC");	if (!env_location) {		env_location="";	}	if (php_ini_path_override) {		php_ini_search_path = php_ini_path_override;		free_ini_search_path = 0;	} else {		char *default_location;		int free_default_location;#ifdef PHP_WIN32		default_location = (char *) emalloc(512);			if (!GetWindowsDirectory(default_location,255)) {			default_location[0]=0;		}		free_default_location=1;#else		default_location = PHP_CONFIG_FILE_PATH;		free_default_location=0;#endif		php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);		free_ini_search_path = 1;		if(env_location && env_location[0]) {			sprintf(php_ini_search_path, ".%c%s%c%s", ZEND_PATHS_SEPARATOR, env_location, ZEND_PATHS_SEPARATOR, default_location);		} else {			sprintf(php_ini_search_path, ".%c%s", ZEND_PATHS_SEPARATOR, default_location);		}		if (free_default_location) {			efree(default_location);		}	}	PG(safe_mode) = 0;	PG(open_basedir) = NULL;		fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path);	if (free_ini_search_path) {		efree(php_ini_search_path);	}	PG(safe_mode) = safe_mode_state;	PG(open_basedir) = open_basedir;	if (!fh.handle.fp) {		return SUCCESS;  /* having no configuration file is ok */	}	fh.type = ZEND_HANDLE_FP;	fh.filename = php_ini_opened_path;	zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);		if (php_ini_opened_path) {		zval tmp;				tmp.value.str.len = strlen(php_ini_opened_path);		tmp.value.str.val = zend_strndup(php_ini_opened_path, tmp.value.str.len);		tmp.type = IS_STRING;		zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval), NULL);		persist_alloc(php_ini_opened_path);	}		return SUCCESS;}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:83,


示例9: GetComspecFromEnvVar

LPCWSTR GetComspecFromEnvVar(wchar_t* pszComspec, DWORD cchMax, ComSpecBits Bits/* = csb_SameOS*/){	if (!pszComspec || (cchMax < MAX_PATH))	{		_ASSERTE(pszComspec && (cchMax >= MAX_PATH));		return NULL;	}	*pszComspec = 0;	BOOL bWin64 = IsWindows64();	if (!((Bits == csb_x32) || (Bits == csb_x64)))	{		if (GetEnvironmentVariable(L"ComSpec", pszComspec, cchMax))		{			// Не должен быть (даже случайно) ConEmuC.exe			const wchar_t* pszName = PointToName(pszComspec);			if (!pszName || !lstrcmpi(pszName, L"ConEmuC.exe") || !lstrcmpi(pszName, L"ConEmuC64.exe")				|| !FileExists(pszComspec)) // ну и существовать должен			{				pszComspec[0] = 0;			}		}	}	// Если не удалось определить через переменную окружения - пробуем обычный "cmd.exe" из System32	if (pszComspec[0] == 0)	{		int n = GetWindowsDirectory(pszComspec, cchMax - 20);		if (n > 0 && (((DWORD)n) < (cchMax - 20)))		{			// Добавить /System32/cmd.exe			// Warning! 'c:/Windows/SysNative/cmd.exe' не прокатит, т.к. доступен			// только для 32битных приложений. А нам нужно в общем виде.			// Если из 32битного нужно запустить 64битный cmd.exe - нужно выключать редиректор.			if (!bWin64 || (Bits != csb_x32))			{				_wcscat_c(pszComspec, cchMax, (pszComspec[n-1] == L'//') ? L"System32//cmd.exe" : L"//System32//cmd.exe");			}			else			{				_wcscat_c(pszComspec, cchMax, (pszComspec[n-1] == L'//') ? L"SysWOW64//cmd.exe" : L"//SysWOW64//cmd.exe");			}		}	}	if (pszComspec[0] && !FileExists(pszComspec))	{		_ASSERTE("Comspec not found! File not exists!");		pszComspec[0] = 0;	}	// Last chance	if (pszComspec[0] == 0)	{		_ASSERTE(pszComspec[0] != 0); // Уже должен был быть определен		//lstrcpyn(pszComspec, L"cmd.exe", cchMax);		wchar_t *psFilePart;		DWORD n = SearchPathW(NULL, L"cmd.exe", NULL, cchMax, pszComspec, &psFilePart);		if (!n || (n >= cchMax))			_wcscpy_c(pszComspec, cchMax, L"cmd.exe");	}	return pszComspec;}
开发者ID:BigVal71,项目名称:ConEmu,代码行数:67,


示例10: CPropertyPage

CThirdPage::CThirdPage()    : CPropertyPage(CThirdPage::IDD),      m_manufacturerSelected( NULL ),      m_modelSelected( NULL ),      m_genericPostscript( NULL ),      m_genericPCL( NULL ),      m_initialized(false),      m_printerImage( NULL ){    static const int	bufferSize	= 32768;    TCHAR				windowsDirectory[bufferSize];    CString				header;    WIN32_FIND_DATA		findFileData;    HANDLE				findHandle;    CString				prnFiles;    CString				ntPrint;    OSStatus			err;    BOOL				ok;    m_psp.dwFlags &= ~(PSP_HASHELP);    m_psp.dwFlags |= PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;    m_psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_INSTALL_TITLE);    m_psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_INSTALL_SUBTITLE);    //    // load printers from ntprint.inf    //    ok = GetWindowsDirectory( windowsDirectory, bufferSize );    err = translate_errno( ok, errno_compat(), kUnknownErr );    require_noerr( err, exit );    //    // <rdar://problem/4826126>    //    // If there are no *prn.inf files, we'll assume that the information    // is in ntprint.inf    //    prnFiles.Format( L"%s//%s", windowsDirectory, kVistaPrintFiles );    findHandle = FindFirstFile( prnFiles, &findFileData );    if ( findHandle != INVALID_HANDLE_VALUE )    {        CString absolute;        absolute.Format( L"%s//inf//%s", windowsDirectory, findFileData.cFileName );        err = LoadPrintDriverDefsFromFile( m_manufacturers, absolute, false );        require_noerr( err, exit );        while ( FindNextFile( findHandle, &findFileData ) )        {            absolute.Format( L"%s//inf//%s", windowsDirectory, findFileData.cFileName );            err = LoadPrintDriverDefsFromFile( m_manufacturers, absolute, false );            require_noerr( err, exit );        }        FindClose( findHandle );    }    else    {        ntPrint.Format(L"%s//%s", windowsDirectory, kNTPrintFile);        err = LoadPrintDriverDefsFromFile( m_manufacturers, ntPrint, false );        require_noerr(err, exit);    }    //    // load printer drivers that have been installed on this machine    //    err = LoadPrintDriverDefs( m_manufacturers );    require_noerr(err, exit);    //    // load our own special generic printer defs    //    err = LoadGenericPrintDriverDefs( m_manufacturers );    require_noerr( err, exit );exit:    return;}
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:81,


万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。