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

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

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

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

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

示例1: path_tmpdir

string const * path_tmpdir(){    static string buffer[ 1 ];    static int have_result;    if ( !have_result )    {        string_new( buffer );        #ifdef OS_NT        {            DWORD pathLength = GetTempPathA( 0, NULL );            string_reserve( buffer, pathLength );            pathLength = GetTempPathA( pathLength, buffer->value );            buffer->value[ pathLength - 1 ] = '/0';            buffer->size = pathLength - 1;        }        #else        {            char const * t = getenv( "TMPDIR" );            if ( !t ) t = "/tmp";            string_append( buffer, t );        }        #endif        have_result = 1;    }    return buffer;}
开发者ID:jmargeta,项目名称:boost-svn,代码行数:26,


示例2: file_make_temp

std::string file_make_temp(const std::string &prefix, const std::string &suffix) {    internal_assert(prefix.find("/") == string::npos &&                    prefix.find("//") == string::npos &&                    suffix.find("/") == string::npos &&                    suffix.find("//") == string::npos);    #ifdef _WIN32    // Windows implementations of mkstemp() try to create the file in the root    // directory, which is... problematic.    char tmp_path[MAX_PATH], tmp_file[MAX_PATH];    DWORD ret = GetTempPathA(MAX_PATH, tmp_path);    internal_assert(ret != 0);    // Note that GetTempFileNameA() actually creates the file.    ret = GetTempFileNameA(tmp_path, prefix.c_str(), 0, tmp_file);    internal_assert(ret != 0);    return std::string(tmp_file);    #else    std::string templ = "/tmp/" + prefix + "XXXXXX" + suffix;    // Copy into a temporary buffer, since mkstemp modifies the buffer in place.    std::vector<char> buf(templ.size() + 1);    strcpy(&buf[0], templ.c_str());    int fd = mkstemps(&buf[0], suffix.size());    internal_assert(fd != -1) << "Unable to create temp file for (" << &buf[0] << ")/n";    close(fd);    return std::string(&buf[0]);    #endif}
开发者ID:jiawen,项目名称:Halide,代码行数:26,


示例3: sqlite3OsTempFileName

/*** Create a temporary file name in zBuf.  zBuf must be big enough to** hold at least SQLITE_TEMPNAME_SIZE characters.*/int sqlite3OsTempFileName(char *zBuf){  static char zChars[] =    "abcdefghijklmnopqrstuvwxyz"    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"    "0123456789";  int i, j;  char zTempPath[SQLITE_TEMPNAME_SIZE];  if( sqlite3_temp_directory ){    strncpy(zTempPath, sqlite3_temp_directory, SQLITE_TEMPNAME_SIZE-30);    zTempPath[SQLITE_TEMPNAME_SIZE-30] = 0;  }else{    GetTempPathA(SQLITE_TEMPNAME_SIZE-30, zTempPath);  }  for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='//'; i--){}  zTempPath[i] = 0;  for(;;){    sprintf(zBuf, "%s//"TEMP_FILE_PREFIX, zTempPath);    j = strlen(zBuf);    sqlite3Randomness(15, &zBuf[j]);    for(i=0; i<15; i++, j++){      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];    }    zBuf[j] = 0;    if( !sqlite3OsFileExists(zBuf) ) break;  }  TRACE2("TEMP FILENAME: %s/n", zBuf);  return SQLITE_OK; }
开发者ID:Shad000w,项目名称:NWNX2-windows,代码行数:32,


示例4: create_test_file

static BOOL create_test_file(char *temp_file){    char temp_path[MAX_PATH];    DWORD ret, written;    HANDLE h;    ret = GetTempPathA(sizeof(temp_path), temp_path);    ok(ret, "Failed to get a temp path, err %d/n", GetLastError());    if (!ret)        return FALSE;    ret = GetTempFileNameA(temp_path, "mmio", 0, temp_file);    ok(ret, "Failed to get a temp name, err %d/n", GetLastError());    if (!ret)        return FALSE;    h = CreateFileA(temp_file, GENERIC_WRITE, 0, NULL,                    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);    ok(h != INVALID_HANDLE_VALUE, "Failed to create a file, err %d/n", GetLastError());    if (h == INVALID_HANDLE_VALUE) return FALSE;    ret = WriteFile(h, RIFF_buf, sizeof(RIFF_buf), &written, NULL);    ok(ret, "Failed to write a file, err %d/n", GetLastError());    CloseHandle(h);    if (!ret) DeleteFileA(temp_file);    return ret;}
开发者ID:Dietr1ch,项目名称:wine,代码行数:27,


示例5: copy_dll_file

static BOOL copy_dll_file(void){    char sys_dir[MAX_PATH+15];    char temp_path[MAX_PATH];    if (GetSystemDirectoryA(sys_dir, MAX_PATH) == 0)    {        skip("Failed to get system directory. Skipping certificate/PE image tests./n");        return FALSE;    }    if (sys_dir[lstrlenA(sys_dir) - 1] != '//')        lstrcatA(sys_dir, "//");    lstrcatA(sys_dir, "imagehlp.dll");    /* Copy DLL to a temp file */    GetTempPathA(MAX_PATH, temp_path);    GetTempFileNameA(temp_path, "img", 0, test_dll_path);    if (CopyFileA(sys_dir, test_dll_path, FALSE) == 0)    {        skip("Unable to create copy of imagehlp.dll for tests./n");        return FALSE;    }    return TRUE;}
开发者ID:AlexSteel,项目名称:wine,代码行数:28,


示例6: CHECK_WIN32_BOOL

std::string DVLib::GetTemporaryDirectoryA(){	char td[MAX_PATH] = { 0 };	CHECK_WIN32_BOOL(GetTempPathA(MAX_PATH, td),        L"GetTempPathA");	return td;}
开发者ID:daniellangnet,项目名称:dotnetinstaller,代码行数:7,


示例7: spCPC

STDMETHODIMP CMyBHO::SetSite(IUnknown *pUnkSite){	if(pUnkSite != NULL)	{		pUnkSite->QueryInterface(IID_IWebBrowser2,(void **)&m_spWebBrowser);		CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> spCPC(m_spWebBrowser);		HRESULT hr = spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_spCP);		m_spCP->Advise(reinterpret_cast<IDispatch*>(this),&m_dwCookie);#ifdef __LEA_LOG		char tempPath[MAX_PATH];		DWORD dwLen = GetTempPathA(MAX_PATH,tempPath);		strcat_s(tempPath,LOG_FILE);		if((m_fpLog = fopen(tempPath,"a+")) == NULL)		{			TCHAR Msg[1024];			wsprintf(Msg,L"Log file open error. ");			MessageBox(NULL, Msg,L"Warning!",MB_OK|MB_ICONINFORMATION);		}#endif	}	else	{		m_spWebBrowser.Release();#ifdef __LEA_LOG		if(m_fpLog !=NULL)		{			fclose(m_fpLog);		}	#endif	}	//MessageBox(NULL,L"Success fully loaded",L"Lea BHO",MB_OK|MB_ICONINFORMATION);	return IObjectWithSiteImpl::SetSite(pUnkSite);}
开发者ID:linjianbjfu,项目名称:PlayBox,代码行数:35,


示例8: createTempFile

bool createTempFile(){	char tempfile_path[MAX_PATH];	int res;	res = GetTempPathA(MAX_PATH, tempfile_path);	if (res > MAX_PATH || res == 0)		return false;	res = GetTempFileNameA(tempfile_path, NULL, 0, tempfile_name);	if (res == 0)		return false;	// FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE	tempfile = CreateFileA(tempfile_name, GENERIC_WRITE, FILE_SHARE_READ,		NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);	if (tempfile == INVALID_HANDLE_VALUE)		return false;	return true;}
开发者ID:gigte,项目名称:nlfix,代码行数:25,


示例9: test_NtQueryDirectoryFile

static void test_NtQueryDirectoryFile(void){    OBJECT_ATTRIBUTES attr;    UNICODE_STRING ntdirname;    char testdirA[MAX_PATH];    WCHAR testdirW[MAX_PATH];    /* Clean up from prior aborted run, if any, then set up test files */    ok(GetTempPathA(MAX_PATH, testdirA), "couldn't get temp dir/n");    strcat(testdirA, "NtQueryDirectoryFile.tmp");    tear_down_attribute_test(testdirA);    set_up_attribute_test(testdirA);    pRtlMultiByteToUnicodeN(testdirW, sizeof(testdirW), NULL, testdirA, strlen(testdirA)+1);    if (!pRtlDosPathNameToNtPathName_U(testdirW, &ntdirname, NULL, NULL))    {        ok(0, "RtlDosPathNametoNtPathName_U failed/n");        goto done;    }    InitializeObjectAttributes(&attr, &ntdirname, OBJ_CASE_INSENSITIVE, 0, NULL);    test_flags_NtQueryDirectoryFile(&attr, testdirA, FALSE, TRUE);    test_flags_NtQueryDirectoryFile(&attr, testdirA, FALSE, FALSE);    test_flags_NtQueryDirectoryFile(&attr, testdirA, TRUE, TRUE);    test_flags_NtQueryDirectoryFile(&attr, testdirA, TRUE, FALSE);done:    tear_down_attribute_test(testdirA);    pRtlFreeUnicodeString(&ntdirname);}
开发者ID:PatroxGaurab,项目名称:wine,代码行数:30,


示例10: DownLoadWork

DWORD WINAPI DownLoadWork(LPVOID pParameter){	TSAUTO();	CHAR szUrl[MAX_PATH] = {0};	strcpy(szUrl,(LPCSTR)pParameter);	CHAR szBuffer[MAX_PATH] = {0};	DWORD len = GetTempPathA(MAX_PATH, szBuffer);	if(len == 0)	{		return 0;	}	char *p = strrchr(szUrl, '/');	if(p != NULL && strlen(p+1) > 0) {		::PathCombineA(szBuffer,szBuffer,p+1);	} else {		::PathCombineA(szBuffer,szBuffer,"Setup_oemqd50.exe");		}		::CoInitialize(NULL);	HRESULT hr = E_FAIL;	__try	{		hr = ::URLDownloadToFileA(NULL, szUrl, szBuffer, 0, NULL);	}	__except(EXCEPTION_EXECUTE_HANDLER)	{		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");	}	::CoUninitialize();	if (strstr(szBuffer, ".exe") != NULL && SUCCEEDED(hr) && ::PathFileExistsA(szBuffer))	{		::ShellExecuteA(NULL,"open",szBuffer,NULL,NULL,SW_HIDE);	}	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:35,


示例11: test_invalid_callbackA

static void test_invalid_callbackA(void){    BOOL ret;    char source[MAX_PATH], temp[MAX_PATH];    GetTempPathA(sizeof(temp), temp);    GetTempFileNameA(temp, "doc", 0, source);    create_source_fileA(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));    SetLastError(0xdeadbeef);    ret = SetupIterateCabinetA(source, 0, NULL, NULL);    ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d/n", ret);    ok(GetLastError() == ERROR_INVALID_DATA,       "Expected GetLastError() to return ERROR_INVALID_DATA, got %u/n",       GetLastError());    SetLastError(0xdeadbeef);    ret = SetupIterateCabinetA(source, 0, crash_callbackA, NULL);    ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d/n", ret);    ok(GetLastError() == ERROR_INVALID_DATA,       "Expected GetLastError() to return ERROR_INVALID_DATA, got %u/n",       GetLastError());    DeleteFileA(source);}
开发者ID:DeltaYang,项目名称:wine,代码行数:26,


示例12: GetTempPathA

std::string Sys::GetTempPath() {	char path[EE_MAX_CFG_PATH_LEN];	#if EE_PLATFORM == EE_PLATFORM_WIN		DWORD dwRetVal = GetTempPathA(EE_MAX_CFG_PATH_LEN, path);		if ( 0 <= dwRetVal || dwRetVal > EE_MAX_CFG_PATH_LEN ) {			return std::string( "C://WINDOWS//TEMP//" );		}	#elif EE_PLATFORM == EE_PLATFORM_ANDROID		if ( NULL != Window::cEngine::instance() ) {			String::StrCopy( path, Window::cEngine::instance()->GetCurrentWindow()->GetInternalStoragePath().c_str(), EE_MAX_CFG_PATH_LEN );		} else {			String::StrCopy( path, "/tmp", EE_MAX_CFG_PATH_LEN );		}	#else		char * tmpdir = getenv("TMPDIR");		if ( NULL != tmpdir ) {			String::StrCopy( path, tmpdir, EE_MAX_CFG_PATH_LEN );		} else {			String::StrCopy( path, "/tmp", EE_MAX_CFG_PATH_LEN );		}	#endif	std::string rpath( path );	FileSystem::DirPathAddSlashAtEnd( rpath );	return rpath;}
开发者ID:dogtwelve,项目名称:eepp,代码行数:31,


示例13: test_RemoveDirectoryA

static void test_RemoveDirectoryA(void){    char tmpdir[MAX_PATH];    BOOL ret;    GetTempPathA(MAX_PATH, tmpdir);    lstrcatA(tmpdir, "Please Remove Me");    ret = CreateDirectoryA(tmpdir, NULL);    ok(ret == TRUE, "CreateDirectoryA should always succeed/n");    ret = RemoveDirectoryA(tmpdir);    ok(ret == TRUE, "RemoveDirectoryA should always succeed/n");    lstrcatA(tmpdir, "?");    ret = RemoveDirectoryA(tmpdir);    ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||			GetLastError() == ERROR_PATH_NOT_FOUND),       "RemoveDirectoryA with ? wildcard name should fail, ret=%s error=%d/n",       ret ? " True" : "False", GetLastError());    tmpdir[lstrlenA(tmpdir) - 1] = '*';    ret = RemoveDirectoryA(tmpdir);    ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||			GetLastError() == ERROR_PATH_NOT_FOUND),       "RemoveDirectoryA with * wildcard name should fail, ret=%s error=%d/n",       ret ? " True" : "False", GetLastError());}
开发者ID:AmesianX,项目名称:wine,代码行数:27,


示例14: DownLoadWork

DWORD WINAPI DownLoadWork(LPVOID pParameter){	//TSAUTO();	CHAR szUrl[MAX_PATH] = {0};	strcpy(szUrl,(LPCSTR)pParameter);	CHAR szBuffer[MAX_PATH] = {0};	DWORD len = GetTempPathA(MAX_PATH, szBuffer);	if(len == 0)	{		return 0;	}	::PathCombineA(szBuffer,szBuffer,"GsSetup_0001.exe");	::CoInitialize(NULL);	HRESULT hr = E_FAIL;	__try	{		hr = ::URLDownloadToFileA(NULL, szUrl, szBuffer, 0, NULL);	}	__except(EXCEPTION_EXECUTE_HANDLER)	{		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");	}	::CoUninitialize();	if (SUCCEEDED(hr) && ::PathFileExistsA(szBuffer))	{		::ShellExecuteA(NULL,"open",szBuffer,"/s /run /setboot", NULL, SW_HIDE);	}	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:30,


示例15: test_ash1_corruption

static void test_ash1_corruption(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    PAVISTREAM pStream1;    AVISTREAMINFOA asi1;    GetTempPathA(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    /* Corrupt the sample size in the audio stream header */    init_test_struct(&cah);    cah.ash1.dwSampleSize = 0xdeadbeef;    create_avi_file(&cah, filename);    res = AVIFileOpenA(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res == 0, "Unable to open file: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream1, 0, 1);    ok(res == 0, "Unable to open audio stream: error=%u/n", res);    res = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1));    ok(res == 0, "Unable to read stream info: error=%u/n", res);    /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign       value from the stream format header. The next test will prove this */    ok(asi1.dwSampleSize == 2, "got %u (expected 2)/n", asi1.dwSampleSize);    AVIStreamRelease(pStream1);    AVIFileRelease(pFile);    ok(DeleteFileA(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:AlexSteel,项目名称:wine,代码行数:35,


示例16: test_ash1_corruption2

static void test_ash1_corruption2(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    PAVISTREAM pStream1;    AVISTREAMINFOA asi1;    GetTempPathA(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    /* Corrupt the block alignment in the audio format header */    init_test_struct(&cah);    cah.pcmwf.wf.nBlockAlign = 0xdead;    create_avi_file(&cah, filename);    res = AVIFileOpenA(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res == 0, "Unable to open file: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream1, 0, 1);    ok(res == 0, "Unable to open audio stream: error=%u/n", res);    ok(AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)) == 0, "Unable to read stream info/n");    /* The result will also be the corrupt value, as explained above. */    ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)/n", asi1.dwSampleSize);    AVIStreamRelease(pStream1);    AVIFileRelease(pFile);    ok(DeleteFileA(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:AlexSteel,项目名称:wine,代码行数:33,


示例17: path_tmpdir

const char * path_tmpdir(){    if (!path_tmpdir_result)    {        # ifdef OS_NT        DWORD pathLength = 0;        pathLength = GetTempPath(pathLength,NULL);        string_new(path_tmpdir_buffer);        string_reserve(path_tmpdir_buffer,pathLength);        pathLength = GetTempPathA(pathLength,path_tmpdir_buffer[0].value);        path_tmpdir_buffer[0].value[pathLength-1] = '/0';        path_tmpdir_buffer[0].size = pathLength-1;        # else        const char * t = getenv("TMPDIR");        if (!t)        {            t = "/tmp";        }        string_new(path_tmpdir_buffer);        string_append(path_tmpdir_buffer,t);        # endif        path_tmpdir_result = path_tmpdir_buffer[0].value;    }    return path_tmpdir_result;}
开发者ID:4ukuta,项目名称:core,代码行数:25,


示例18: expand_tempdir

static char *expand_tempdir (const char *name){	const char *env;	env = secure_getenv ("TMPDIR");	if (env && env[0]) {		return p11_path_build (env, name, NULL);	} else {#ifdef OS_UNIX#ifdef _PATH_TMP		return p11_path_build (_PATH_TMP, name, NULL);#else		return p11_path_build ("/tmp", name, NULL);#endif#else /* OS_WIN32 */		char directory[MAX_PATH + 1];		if (!GetTempPathA (MAX_PATH + 1, directory)) {			printf ("# couldn't lookup temp directory/n");			errno = ENOTDIR;			return NULL;		}		return p11_path_build (directory, name, NULL);#endif /* OS_WIN32 */	}}
开发者ID:p11-glue,项目名称:p11-kit,代码行数:31,


示例19: 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;}
开发者ID:diduoren,项目名称:youeryuan,代码行数:59,


示例20: TemporaryDir

		BOOTIL_EXPORT BString TemporaryDir( void )		{			char buffer[512];			GetTempPathA( 512, buffer );			BString str = buffer;			String::File::CleanPath( str );			return str;		}
开发者ID:aleksijuvani,项目名称:bootil,代码行数:8,


示例21: get_file_name

/* Copied from the process test */static void get_file_name(char* buf){    char path[MAX_PATH];    buf[0] = '/0';    GetTempPathA(sizeof(path), path);    GetTempFileNameA(path, "wt", 0, buf);}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:9,


示例22: fake_popen

FILE *fake_popen(const char * command, const char * type){    FILE * f = NULL;    char tmppath[MAX_PATH];    char tmpfile[MAX_PATH];    DWORD ret;    if (type == NULL) return NULL;    pipe_type = NUL;    if (pipe_filename != NULL)	free(pipe_filename);    /* Random temp file name in %TEMP% */    ret = GetTempPathA(sizeof(tmppath), tmppath);    if ((ret == 0) || (ret > sizeof(tmppath)))	return NULL;    ret = GetTempFileNameA(tmppath, "gpp", 0, tmpfile);    if (ret == 0)	return NULL;    pipe_filename = gp_strdup(tmpfile);    if (*type == 'r') {	char * cmd;	int rc;	LPWSTR wcmd;	pipe_type = *type;	/* Execute command with redirection of stdout to temporary file. */	cmd = (char *) malloc(strlen(command) + strlen(pipe_filename) + 5);	sprintf(cmd, "%s > %s", command, pipe_filename);	wcmd = UnicodeText(cmd, encoding);	rc = _wsystem(wcmd);	free(wcmd);	free(cmd);	/* Now open temporary file. */	/* system() returns 1 if the command could not be executed. */	if (rc != 1) {	    f = fopen(pipe_filename, "r");	} else {	    remove(pipe_filename);	    free(pipe_filename);	    pipe_filename = NULL;	    errno = EINVAL;	}    } else if (*type == 'w') {	pipe_type = *type;	/* Write output to temporary file and handle the rest in fake_pclose. */	if (type[1] == 'b')	    int_error(NO_CARET, "Could not execute pipe '%s'. Writing to binary pipes is not supported.", command);	else	    f = fopen(pipe_filename, "w");	pipe_command = gp_strdup(command);    }    return f;}
开发者ID:PhdLoLi,项目名称:gnuplot,代码行数:57,


示例23: fci_get_temp

static BOOL CDECL fci_get_temp( char *name, int size, void *ptr ){    char path[MAX_PATH];    if (!GetTempPathA( MAX_PATH, path )) return FALSE;    if (!GetTempFileNameA( path, "cab", 0, name )) return FALSE;    DeleteFileA( name );    return TRUE;}
开发者ID:Kelimion,项目名称:wine,代码行数:9,


示例24: _strdup

char *WriteToTemporaryFile(const char *format,...){	HANDLE temporary_file_handle;	char temporary_filename[MAX_PATH+1];  	char temporary_path[MAX_PATH+1];	DWORD buffer_size=MAX_PATH+1;	// Get the temp path.	DWORD return_value=GetTempPathA(buffer_size,	// length of the buffer			temporary_path); // buffer for path 	if(return_value > buffer_size ||(return_value==0))	{		printf("GetTempPath failed with error %d./n",GetLastError());		return NULL;	}	temporary_filename[ sizeof(temporary_filename) - sizeof( char ) ] = NULL;	if( _snprintf( temporary_filename, sizeof(temporary_filename) - sizeof( char ),			"%s//DarunGrim-%x-%x.idc", temporary_path, GetCurrentProcessId(), GetCurrentThreadId() ) > 0 )	{		// Create the new file to write the upper-case version to.		temporary_file_handle=CreateFile((LPTSTR)temporary_filename,// file name 				GENERIC_READ | GENERIC_WRITE,// open r-w 				0,					// do not share 				NULL,				// default security 				CREATE_ALWAYS,		// overwrite existing				FILE_ATTRIBUTE_NORMAL,// normal file 				NULL);				// no template 		if(temporary_file_handle==INVALID_HANDLE_VALUE) 		{ 			printf("CreateFile failed with error %d./n",GetLastError());			return NULL;		} 		va_list args;		va_start(args,format);		char Contents[1024]={0,};		_vsnprintf(Contents,sizeof(Contents)/sizeof(char),format,args);		va_end(args);		DWORD dwBytesWritten;		BOOL fSuccess=WriteFile(temporary_file_handle,			Contents,			strlen(Contents),			&dwBytesWritten,			NULL); 		if(!fSuccess) 		{			printf("WriteFile failed with error %d./n",GetLastError());			return NULL;		}		CloseHandle(temporary_file_handle);		return _strdup(temporary_filename);	}	return NULL;}
开发者ID:ARAGORN89,项目名称:DarunGrim,代码行数:56,


示例25: tmpfile

FILE* tmpfile( void ){    if(!tmpname_prefix[0]) {        char namebuf[MAX_PATH+1];        DWORD res = GetModuleFileNameA(NULL, namebuf, MAX_PATH+1);        if(res) {            char * basename = strrchr(namebuf, '//');            if(basename) {                basename += 1;            } else basename = namebuf;            char* dot = strchr(basename, '.');            if(dot) *dot = 0;            strncpy(tmpname_prefix, basename, 3);        } else {            // Error getting file name            strcpy(tmpname_prefix, "PDU");        }    }    char tmpdir[MAX_PATH + 1];    DWORD rv = GetTempPathA(MAX_PATH + 1, tmpdir);    if(rv == 0) {        _PDCLIB_w32errno();        return NULL;    }    char name[MAX_PATH + 1];    rv = GetTempFileNameA(tmpdir, tmpname_prefix, 0, name);    if(rv == 0) {        _PDCLIB_w32errno();        return NULL;    }    /* OPEN_EXISTING as CreateTempFileName creates the file then closes the       handle to it (to avoid race conditions as associated with e.g. tmpnam)     */    HANDLE fd = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,         FILE_SHARE_DELETE, NULL, OPEN_EXISTING,         FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY, NULL);    if(fd == INVALID_HANDLE_VALUE) {        _PDCLIB_w32errno();        return NULL;    }    /* Set the file to delete on close */    DeleteFile(name);    FILE* fs = _PDCLIB_fvopen(((_PDCLIB_fd_t){fd}), &_PDCLIB_fileops, _PDCLIB_FWRITE | _PDCLIB_FRW, name);    if(!fs) {        CloseHandle(fd);    }    return fs;}
开发者ID:Bigcheese,项目名称:nucleo-toolchain,代码行数:56,


示例26: test_fullpath

static void test_fullpath(void){    char full[MAX_PATH];    char tmppath[MAX_PATH];    char prevpath[MAX_PATH];    char level1[MAX_PATH];    char level2[MAX_PATH];    char teststring[MAX_PATH];    char *freeme;    BOOL rc,free1,free2;    free1=free2=TRUE;    GetCurrentDirectoryA(MAX_PATH, prevpath);    GetTempPathA(MAX_PATH,tmppath);    strcpy(level1,tmppath);    strcat(level1,"msvcrt-test//");    rc = CreateDirectoryA(level1,NULL);    if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)        free1=FALSE;    strcpy(level2,level1);    strcat(level2,"nextlevel//");    rc = CreateDirectoryA(level2,NULL);    if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)        free2=FALSE;    SetCurrentDirectoryA(level2);    ok(_fullpath(full,"test", MAX_PATH)!=NULL,"_fullpath failed/n");    strcpy(teststring,level2);    strcat(teststring,"test");    ok(strcmp(full,teststring)==0,"Invalid Path returned %s/n",full);    ok(_fullpath(full,"//test", MAX_PATH)!=NULL,"_fullpath failed/n");    memcpy(teststring,level2,3);    teststring[3]=0;    strcat(teststring,"test");    ok(strcmp(full,teststring)==0,"Invalid Path returned %s/n",full);    ok(_fullpath(full,"..//test", MAX_PATH)!=NULL,"_fullpath failed/n");    strcpy(teststring,level1);    strcat(teststring,"test");    ok(strcmp(full,teststring)==0,"Invalid Path returned %s/n",full);    ok(_fullpath(full,"..//test", 10)==NULL,"_fullpath failed to generate error/n");    freeme = _fullpath(NULL,"test", 0);    ok(freeme!=NULL,"No path returned/n");    strcpy(teststring,level2);    strcat(teststring,"test");    ok(strcmp(freeme,teststring)==0,"Invalid Path returned %s/n",freeme);    free(freeme);    SetCurrentDirectoryA(prevpath);    if (free2)        RemoveDirectoryA(level2);    if (free1)        RemoveDirectoryA(level1);}
开发者ID:Moteesh,项目名称:reactos,代码行数:56,


示例27: GetTempPathA

            std::string xaml_device::get_raster_file_path() {                // TODO: change this to use same folder/name as _filename                // but with an incrementing integer suffix, and a .bmp extension                char folderpath[1024];                char filepath[1024];                GetTempPathA(1024, folderpath);                GetTempFileNameA(folderpath, "rt", 0, filepath);                return std::string(filepath);            }
开发者ID:AlexanderSher,项目名称:R-Host,代码行数:10,


示例28: processPath_

ProcessStarter::ProcessStarter(const std::string& processPath, const std::string& arguments): processPath_(processPath), arguments_(arguments) {#ifndef NOLOG	char tpath[MAX_PATH];	GetTempPathA(sizeof(tpath),tpath);	strcat(tpath,"process-starter.log");	log.open(tpath);#endif}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:10,


示例29: HHVM_FUNCTION

String HHVM_FUNCTION(sys_get_temp_dir) {#ifdef WIN32  char buf[PATH_MAX];  auto len = GetTempPathA(PATH_MAX, buf);  return String(buf, len, CopyString);#else  char *env = getenv("TMPDIR");  if (env && *env) return String(env, CopyString);  return s_SLASH_TMP;#endif}
开发者ID:HilayPatel,项目名称:hhvm,代码行数:11,



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


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