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


C++ CopyFileA函数代码示例

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


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

示例1: load

        bool load(const arguments & args_, std::string & result) {
            HMODULE dllHandle;
            RVExtension function;

            LOG(INFO) << "Load requested [" << args_.as_string(0) << "]";

            if (_modules.find(args_.as_string(0)) != _modules.end()) {
                LOG(ERROR) << "Module already loaded [" << args_.as_string(0) << "]";
                return true;
            }

#ifdef _WINDOWS
            // Make a copy of the file to temp, and load it from there, referencing the current path name
            char tmpPath[MAX_PATH +1], buffer[MAX_PATH + 1];

            if(!GetTempPathA(MAX_PATH, tmpPath)) {
                LOG(ERROR) << "GetTempPath() failed, e=" << GetLastError();
                return false;
            }
            if(!GetTempFileNameA(tmpPath, "ace_dynload", TRUE, buffer)) {
                LOG(ERROR) << "GetTempFileName() failed, e=" << GetLastError();
                return false;
            }
            std::string temp_filename = buffer;
            if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                DeleteFile(temp_filename.c_str());
                if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                    LOG(ERROR) << "CopyFile() , e=" << GetLastError();
                    return false;
                }
            }
#else
            std::string temp_filename = args_.as_string(0);
#endif

            dllHandle = LoadLibrary(temp_filename.c_str());
            if (!dllHandle) {
                LOG(ERROR) << "LoadLibrary() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                return false;
            }

            function = (RVExtension)GetProcAddress(dllHandle, "[email protected]");
            if (!function) {
                LOG(ERROR) << "GetProcAddress() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                FreeLibrary(dllHandle);
                return false;
            }

            LOG(INFO) << "Load completed [" << args_.as_string(0) << "]";

            _modules[args_.as_string(0)] = module(args_.as_string(0), dllHandle, function, temp_filename);

            return false;
        }
开发者ID:AgentRev,项目名称:ACE3,代码行数:54,代码来源:dynloader.hpp

示例2: InstallDllToSystem32

bool InstallDllToSystem32(char *src_dirname, char *src_filename, char *dst_filename)
{
	char system32[MAX_PATH];
	char src_fullpath[MAX_PATH];
	char dst_fullpath[MAX_PATH];

	SeStrCpy(src_fullpath, sizeof(src_fullpath), src_dirname);
	SeStrCat(src_fullpath, sizeof(src_fullpath), "\\");
	SeStrCat(src_fullpath, sizeof(src_fullpath), src_filename);

	if (Is64BitCode() || IsWow64() == false)
	{
		GetSystemDirectoryA(system32, sizeof(system32));
	}
	else
	{
		GetSystemWow64DirectoryA(system32, sizeof(system32));
	}

	SeStrCpy(dst_fullpath, sizeof(dst_fullpath), system32);
	SeStrCat(dst_fullpath, sizeof(dst_fullpath), "\\");
	SeStrCat(dst_fullpath, sizeof(dst_fullpath), dst_filename);

	if (IsWin10PcapFile(dst_fullpath) == false)
	{
		char dst_backup[MAX_PATH];
		SeStrCpy(dst_backup, sizeof(dst_backup), dst_fullpath);
		SeStrCat(dst_backup, sizeof(dst_backup), ".bak");

		CopyFileA(dst_fullpath, dst_backup, false);
	}

LABEL_RETRY:
	if (CopyFileA(src_fullpath, dst_fullpath, false) == false)
	{
		char tmp[MAX_SIZE];

		wsprintfA(tmp,
			"The installation of the DLL file to the path \"%s\" failed.\r\n\r\n"
			"Make sure that there are no running programs using WinPcap DLL.",
			dst_fullpath);

		if (MessageBoxA(NULL, tmp, INSTALLER_TITLE, MB_ICONEXCLAMATION | MB_SYSTEMMODAL | MB_RETRYCANCEL) == IDRETRY)
		{
			goto LABEL_RETRY;
		}

		return false;
	}

	return true;
}
开发者ID:AmesianX,项目名称:Win10Pcap,代码行数:52,代码来源:Installer.c

示例3: S9xSaveConfigFile

static bool S9xSaveConfigFile(ConfigFile &conf){

	configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex"));
	int times = 0;
	DWORD waitVal = WAIT_TIMEOUT;
	while(waitVal == WAIT_TIMEOUT && ++times <= 150) // wait at most 15 seconds
		waitVal = WaitForSingleObject(configMutex, 100);

	// save over the .conf file if it already exists, otherwise save over the .cfg file
	std::string	fname;
	fname=S9xGetDirectory(DEFAULT_DIR);
	fname+=SLASH_STR S9X_CONF_FILE_NAME;

	// ensure previous config file is not lost if we crash while writing the new one
	std::string	ftemp;
	{
		CopyFileA(fname.c_str(), (fname + ".autobak").c_str(), FALSE);

		ftemp=S9xGetDirectory(DEFAULT_DIR);
		ftemp+=SLASH_STR "config_error";
		FILE* tempfile = fopen(ftemp.c_str(), "wb");
		if(tempfile) fclose(tempfile);
	}

	bool ret = try_save(fname.c_str(), conf);

	remove(ftemp.c_str());
	remove((fname + ".autobak").c_str());

	ReleaseMutex(configMutex);
	CloseHandle(configMutex);

	return ret;
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:34,代码来源:wconfig.cpp

示例4: 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,代码来源:integrity.c

示例5: main

int main()
{
	char filename[MAX_PATH]={0};
	SetConsoleTitleA("Simple PE64 Viewer");
bgn:
	printf("Simple PE64 Viewer\n====================\nAuthor: Tesla.Angela\nVersion: 0.01\nSupport: PE32+ file\n\n\n");
	printf("输入文件名(支持文件拖拽,直接按回车则默认打开ntoskrnl.exe,输入exit退出):");
	gets(filename);
	if (FileLen(filename)==0)
	{
		if( stricmp(filename,"exit") )
		{
			CopyFileA("c:\\windows\\system32\\ntoskrnl.exe","c:\\ntoskrnl.exe",0);
			strcpy(filename,"c:\\ntoskrnl.exe");
			printf("c:\\ntoskrnl.exe\n");
		}
		else
			goto end;
	}
	ShowPE64Info(filename);
	clrscr();
	goto bgn;
end:
	DeleteFileA("c:\\ntoskrnl.exe");
	return 0;
}
开发者ID:340211173,项目名称:LookDrvCode,代码行数:26,代码来源:main.cpp

示例6: GameConfig

bool GameDeploymentUtil::createGameConfig( const std::string& targetDir, const GameDeploymentInfo& info )
{
   ResourcesManager& resMgr = TSingleton< ResourcesManager >::getInstance();
   Filesystem& fs = resMgr.getFilesystem();


   GameConfig* config = new GameConfig();
   config->m_renderingPipelinePath = info.m_renderingPipelinePath;
   config->m_worldModelPath = info.m_worldModelPath;

   // save it in this filesystem
   FilePath gameConfigPath( "game.gcf" );
   ReflectionSerializationUtil::saveObject( config, gameConfigPath );

   // destroy the config instance
   delete config;

   // move it to the destination
   std::string gameConfigSourcePath = gameConfigPath.toAbsolutePath( fs );
   std::string gameConfigDestPath = targetDir + "/" + gameConfigPath.c_str();
   bool deploymentSuccessful = CopyFileA( gameConfigSourcePath.c_str(), gameConfigDestPath.c_str(), false ); 

   // delete the temporary file
   fs.remove( gameConfigPath );

   return deploymentSuccessful;
}
开发者ID:dabroz,项目名称:Tamy,代码行数:27,代码来源:GameDeploymentUtil.cpp

示例7: CopyDirectoryA

    /*
     *  CopyDirectoryA
     *      WinAPI-like function that copies the full directory @szFrom to @szTo
     *      If @szTo doesn't exist, it is created
     */
    inline BOOL CopyDirectoryA(LPCTSTR szFrom, LPCTSTR szTo)
    {
        if(CreateDirectoryA(szTo, NULL))
        {
            ForeachFile(szFrom, "*.*", false, [&szFrom, &szTo](ModLoaderFile& file)
            {
                CHAR szToFile[MAX_PATH], szFromFile[MAX_PATH];
                const char* pPath = file.filename;
                
                sprintf(szToFile, "%s\\%s", szTo, pPath);
                sprintf(szFromFile, "%s\\%s", szFrom, pPath);

                if(file.is_dir) // Call myself again for recursion
                    CopyDirectoryA(szFromFile, szToFile);
                else
                    CopyFileA(szFromFile, szToFile, FALSE);

                return true;
            });
            
            return TRUE;
        }
        
        return FALSE;
    }
开发者ID:Whitetigerswt,项目名称:sa-modloader,代码行数:30,代码来源:modloader_util_path.hpp

示例8: get_exe_dir

ngspice::ngspice()
	:m_sendDataDebug(0)
	,m_flagPrompt(false)
	,m_running(false)
	,m_flagCheckLoadCircuit(false)
	//,m_breakTest(false)
{
	string path = get_exe_dir();
	SetCurrentDirectoryA(path.c_str());

	static int copy = 1;
	string dll = FormatString(100, "ngspice%d.dll", copy++);
	BOOL success = CopyFileA("ngspice.dll", dll.c_str(), FALSE);
	m_mod = LoadLibrary(dll.c_str());
	ngSpice_Init		= (Func_ngSpice_Init)GetProcAddress(m_mod, "ngSpice_Init");
	ngSpice_Init_Sync	= (Func_ngSpice_Init_Sync)GetProcAddress(m_mod, "ngSpice_Init_Sync");
	ngSpice_Command		= (Func_ngSpice_Command)GetProcAddress(m_mod, "ngSpice_Command");
	ngGet_Vec_Info		= (Func_ngGet_Vec_Info)GetProcAddress(m_mod, "ngGet_Vec_Info");
	ngSpice_Circ		= (Func_ngSpice_Circ)GetProcAddress(m_mod, "ngSpice_Circ");
	ngSpice_CurPlot		= (Func_ngSpice_CurPlot)GetProcAddress(m_mod, "ngSpice_CurPlot");
	ngSpice_AllPlots	= (Func_ngSpice_AllPlots)GetProcAddress(m_mod, "ngSpice_AllPlots");
	ngSpice_AllVecs		= (Func_ngSpice_AllVecs)GetProcAddress(m_mod, "ngSpice_AllVecs");
	ngSpice_running		= (Func_ngSpice_running)GetProcAddress(m_mod, "ngSpice_running");
	ngSpice_SetBkpt		= (Func_ngSpice_SetBkpt)GetProcAddress(m_mod, "ngSpice_SetBkpt");

	int ret = ngSpice_Init(procSendChar, procSendStat, procControlledExit, procSendData, procSendInitData, procBGThreadRunning, this);
}
开发者ID:vcnt,项目名称:ingspice,代码行数:27,代码来源:ngspice.cpp

示例9: fclose

/*----------------------------------------------------------------------------*
*  NAME
*      SetImageFileName
*
*  DESCRIPTION
*      The file name of the image to be transferred.
*---------------------------------------------------------------------------*/
bool ImageFileHandler::OpenImageFile()
{
    bool fileOpened = false;
    if(mImgFile != NULL)
    {
        fclose(mImgFile);
        mImgFile = NULL;
    }

    FILE *imgFile = NULL;              // The image file to transfer
    // Try to open the specified file
    if(0 == fopen_s(&imgFile, mAsciiFileName, "rb+"))
    {
       fclose(imgFile);
       //if(fopen_s(&mImgFile, "OTATemp.img", "w+")) == 0)
       DeleteFileA(mTempFileName);
       CopyFileA(mAsciiFileName, mTempFileName, FALSE);

       if(0 == fopen_s(&mImgFile, mTempFileName, "rb+"))
       {
          fileOpened = true;

          // Try to determine the length of the specified file
          mImgFileSize = readFileLength(mImgFile);

          ResetTransfer();
       }
    }
    return (fileOpened && (mImgFileSize > 0));
}
开发者ID:NemProjects,项目名称:CSR1010-MMA9550,代码行数:37,代码来源:uEnergyImage.cpp

示例10: win32_InitGmbDll

internal void win32_InitGmbDll(win32_gmbdll *dll) {
  // note(caf): we make a copy because otherwise visual studio's debugger holds
  // the dll and pdb open and we can't compile a new one over it
  if (!CopyFileA("\\build\\gmb.dll", "\\build\\gmb_copy.dll", 0)) {
    // todo(caf): handle errors
    return;
  }
  // this isn't great. we should deal with this differently so we don't have to
  // delete the original
  // DeleteFileA("\\build\\gmb.dll");
  dll->Handle = LoadLibraryA("\\build\\gmb_copy.dll");
  if (!dll->Handle) {
    dll->gmbMainLoop = &gmbMainLoopStub;
    errord((char *)"Failed to LoadLibraryA()");
  } else {
    gmb_main_loop *ml =
        (gmb_main_loop *)GetProcAddress(dll->Handle, "gmbMainLoop");
    if (!ml) {
      dll->gmbMainLoop = &gmbMainLoopStub;
      errord((char *)"Failed to GetProcAddress()");
    }
    dll->gmbMainLoop = ml;
    HANDLE lastDllHandle;
    lastDllHandle = CreateFileA("\\build\\gmb_copy.dll", 0, FILE_SHARE_WRITE, 0,
                                OPEN_EXISTING, 0, 0);
    if (lastDllHandle != INVALID_HANDLE_VALUE) {
    }
    // note(caf): we check the _modified_ date because silly me, creation date
    // is literally the time the file with that name first existed
    GetFileTime(lastDllHandle, 0, 0, &dll->lastCreationDate);
    CloseHandle(lastDllHandle);
  }
}
开发者ID:cfredmakecode,项目名称:gmb,代码行数:33,代码来源:win32_gmb.cpp

示例11: copy_file

bool copy_file(const path & from_p, const path & to_p, bool overwrite) {
	bool ret = CopyFileA(from_p.string().c_str(), to_p.string().c_str(), !overwrite) == TRUE;
	if(!ret) {
		LogWarning << "CopyFileA(" << from_p << ", " << to_p << ", " << !overwrite << ") failed! " << GetLastErrorString();
	}
	return ret;
}
开发者ID:DaveMachine,项目名称:ArxLibertatis,代码行数:7,代码来源:FilesystemWindows.cpp

示例12: srcp

bool Path::copy( const QString & src, const QString & dest )
{
	Path srcp( src ), destp( dest );
	if( !srcp.fileExists() || !destp.dir().dirExists() )
		return false;
#ifdef Q_OS_WIN
	bool s_unc = false, d_unc = false;
	
	QString srcw( srcp.path() );
	srcw = srcw.replace( "/", "\\" );
	QString destw( destp.path() );
	destw = destw.replace( "/", "\\" );
	
	if( srcw[0] == '\\' && srcw[1] == '\\' ) s_unc = true;
	if( destw[0] == '\\' && destw[1] == '\\' ) d_unc = true;
	srcw.replace( "\\\\", "\\" );
	if( s_unc ) srcw = "\\" + srcw;
	destw.replace( "\\\\", "\\" );
	if( d_unc ) destw = "\\" + destw;
	
	bool ret = CopyFileA( srcw.toLatin1(), destw.toLatin1(), false ) != 0;
	if( !ret ) {
		DWORD err = GetLastError();
		LOG_1( "Copy failed with error: " + QString::number(err) );
		LOG_1( "Src: " + srcw +  "Dest: " + destw );
	}
	return ret;
#else
	system( QString( "cp " + srcp.path() + " " + destp.path() ).toLatin1() );
	return true;
#endif
}
开发者ID:EntityFXCode,项目名称:arsenalsuite,代码行数:32,代码来源:path.cpp

示例13: poco_assert

void FileImpl::copyToImpl(const std::string& path) const
{
	poco_assert (!_path.empty());

	if (CopyFileA(_path.c_str(), path.c_str(), FALSE) == 0)
		handleLastErrorImpl(_path);
}
开发者ID:trafficsim-jp,项目名称:poco,代码行数:7,代码来源:File_WIN32.cpp

示例14: PrepareFirstRun

VOID PrepareFirstRun(LPCSTR lpExePath)
{
	CHAR chFolderPath[MAX_PATH];

	GetTempPath(RTL_NUMBER_OF(chFolderPath)-1, chFolderPath);

	GetTempFileName(chFolderPath, NULL, 0, g_chExePath);
	PathRemoveExtension(g_chExePath);
	PathAddExtension(g_chExePath, ".exe");
	CopyFileA(lpExePath, g_chExePath, FALSE);

	GetTempFileName(chFolderPath, NULL, 0, g_chDllPath);
	PathRemoveExtension(g_chDllPath);
	PathAddExtension(g_chDllPath, ".dll");
	CopyFileA(lpExePath, g_chDllPath, FALSE);
	SetFileDllFlag(g_chDllPath);
}
开发者ID:AlexWMF,项目名称:Carberp,代码行数:17,代码来源:dropper.cpp

示例15: sttSaveAvatar

static int sttSaveAvatar()
{
	FILE* in;
	SHA1Context sha;
//	MD5Context md5;
	unsigned char buf[ 512 ];
	char tFileName[ MAX_PATH ];
	int i, pictureType;
	int bIsFirst = 1;
	struct _stat statbuf;
	uint8_t digest[20];

	if (_stat(szFileName, &statbuf)) return 1;
	if (statbuf.st_size > 6 * 1024) return 1;
	
	TlenGetAvatarFileName( NULL, tFileName, sizeof tFileName );
	if ( CopyFileA( szFileName, tFileName, FALSE ) == FALSE ) {
		JabberLog( "Copy failed with error %d", GetLastError() );
		return 1;
	}
	SHA1Reset(&sha);
//	md5_init(&md5);
	in = fopen( tFileName, "rb" );
	if ( in == NULL )
		return 1;

	while( !feof( in )) {
		int bytes = fread( buf, 1, sizeof buf, in );
		if ( bIsFirst ) {
			pictureType = JabberGetPictureType( buf );
			bIsFirst = 0;
		}
		SHA1Input(&sha, buf, bytes);
//		md5_update(&md5, buf, bytes);
	}
	fclose( in );
	if ( pictureType == PA_FORMAT_UNKNOWN )
		return 1;
	SHA1Result(&sha, digest);
//	md5_finalize(&md5);
	for (i=0;i<20;i++) {
//		unsigned int val = (md5.state[i>>2] >> 8*(i%4)) & 0xFF;
		sprintf( buf+( i<<1 ), "%02x", digest[i]);
	}
	DBWriteContactSettingString(NULL, jabberProtoName, "AvatarHash", buf);
	DBWriteContactSettingDword(NULL, jabberProtoName, "AvatarFormat", pictureType);
	if (userAvatarHash != NULL) {
		free (userAvatarHash);
		userAvatarHash = NULL;
	}
	userAvatarHash = strdup(buf);
	userAvatarFormat = pictureType;
	TlenGetAvatarFileName(NULL, szFileName, MAX_PATH);
	if ( strcmp( szFileName, tFileName ))
		MoveFileA( tFileName, szFileName );
	return 0;
}
开发者ID:BackupTheBerlios,项目名称:mtlen-svn,代码行数:57,代码来源:tlen_userinfo.c


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