kraen4468
初階會員
![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:66 回覆:112 積分:35 註冊:2003-12-04
發送簡訊給我
|
我想寫一個開啟檔案下面是找到的API可是我不知道怎麼用它呢
HANDLE CreateFile( LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDistribution,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
copy); ~我還在學習狀態希望多多向您學習~
|
kraen4468
初階會員
![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:66 回覆:112 積分:35 註冊:2003-12-04
發送簡訊給我
|
還有這個用法翻譯了還是看不太懂
CopyAFile(
LPSTR szFullPathSrc,
LPSTR szFullPathDst,
INT cmo,
INT fAppend
);
~我還在學習狀態希望多多向您學習~
|
erosme
初階會員
![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:5 回覆:44 積分:29 註冊:2002-12-23
發送簡訊給我
|
Dear Kraen4468, 你何不用下列簡單方法. #include 〈stdio.h〉 FILE *file1;
char x;
file1 = fopen("FileName","r"); while(!feof(file1))
{
fread(&x,1,1,file1);
......
}
fclose(file1); 發表人 - erosme 於 2004/02/21 02:50:27
|
kraen4468
初階會員
![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:66 回覆:112 積分:35 註冊:2003-12-04
發送簡訊給我
|
不過我還是解不過CreateFile的用法 ~我還在學習狀態希望多多向您學習~
|
axsoft
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](http://earthday.link.org.tw/images/EARTHfinal.gif) 發表:681 回覆:1056 積分:969 註冊:2002-03-13
發送簡訊給我
|
引言:
不過我還是解不過CreateFile的用法 ~我還在學習狀態希望多多向您學習~
kraen4468您好:
希望下面方法能幫的上忙
<>>
< class="code"> HANDLE hFile;
DWORD dwBytesWritten,dwPos;
AnsiString string;
hFile = CreateFile("testfile.txt", // LPCTSTR lpFileName
GENERIC_WRITE, // DWORD dwDesiredAccess
0, // DWORD dwShareMode
NULL, // LPSECURITY_ATTRIBUTES lpSecurityAttributes
CREATE_ALWAYS, // DWORD dwCreationDistribution
FILE_ATTRIBUTE_NORMAL, // DWORD dwFlagsAndAttributes
NULL); // HANDLE hTemplateFile copy
if(hFile == INVALID_HANdlE_VALUE)
{
ErrorProcessor();
return;
}
LockFile(hFile,0,0,GetFileSize(hFile,NULL),0); string = "This is context.";
WriteFile(hFile, string.c_str(), string.Length(), &dwBytesWritten, NULL); UnlockFile(hFile,0,0,GetFileSize(hFile,NULL),0);
CloseHandle(hFile);
CopyFile and CopyFileEx
The CopyFile function copies a file from one location to another. The basic syntax is as follows:
CopyFile("src.fil", "dest.fil", true); You can copy files to the same drive, to another drive, or even to another machine on a network. The third parameter indicates what Windows should do if the file already exists in the target location. When this parameter is true, then Windows doesn't overwrite the existing file; it reports an error instead. When this parameter is false, then Windows will overwrite the existing file.
You can attain more control over copy operations by using CopyFileEx rather than CopyFile. Among other things, CopyFileEx allows you to use a callback function that's called periodically during the copy operation. You could use this callback function to display the progress of the copy operation. Unfortunately, CopyFileEx is available only in the Windows NT API. /*生活是一種藝術,用心生活才能享受生活*/
|