實現原理:開啟兩個檔案,迴圈讀取要追加的檔案內容,然後寫入到要被追加檔案的末尾相關api:
createfile
、setfilepointerex
、readfile
、writefile
/*
funname: filecat
param: szexistsfilepath:要被追加的檔案路徑
szaddfilepath:要追加的檔案路徑
return: false: 失敗
true: 成功
remark: 當szexistsfilepath不存在時,將會主動建立,此時作用相當於copyfile
*/bool filecat
(_in_ lpctstr szexistsfilepath, _in_ lpctstr szaddfilepath)
bool bret = false;
bool berror = false;
handle hexistfile = invalid_handle_value;
handle haddfile = invalid_handle_value;
large_integer stlargeinteger =
; stlargeinteger.quadpart =0;
byte* readbuffer =
new byte[
4096];
haddfile =
createfile
(szaddfilepath, generic_read, file_share_read,
null
, open_existing, file_attribute_normal,
null);
if(invalid_handle_value == haddfile)
hexistfile =
createfile
(szexistsfilepath, generic_write,0,
null
, open_always, file_attribute_normal,
null);
if(invalid_handle_value == hexistfile)
berror =
setfilepointerex
(hexistfile, stlargeinteger,
null
, file_end);if
(false == berror)
while
(true
)elseif(
0== dwreadcount)
dword dwwritecount =0;
berror =
writefile
(hexistfile, readbuffer, dwreadcount,
&dwwritecount,
null);
if(false == berror || dwreadcount != dwwritecount)}if
(true == berror)
fun_cleanup:if(
null
!= readbuffer)
if(invalid_handle_value != hexistfile)
if(invalid_handle_value != haddfile)
return bret;
}
Win32 複製檔案
第一種方法 include stdafx.h include include define buf size 256 int tmain int argc,tchar argv hin createfile argv 1 generic read,0,null,open existing,0,nul...
Win32實現INI檔案的讀寫
inifile.h inte ce for the cinifile class.if defined afx inifile h 3d06e4ac 5a93 4d23 84bd 1694e88fdb70 included define afx inifile h 3d06e4ac 5a93 4d2...
win32 顯示 bmp檔案
用vs2013 建立乙個win32 應用程式,空專案,專案名稱是hellobitmap 拷貝下圖的bmp格式檔案abc.bmp到專案檔案所在目錄 新增乙個bitmap資源 進入資源檢視模式 儲存一下 進入解決方案資源管理器模式 在原始檔中新增檔案 hellobitmap.cpp 內容如下 inclu...