[抱歉,問個MFC的問題]要如何在console模式下,使用MFC的class |
答題得分者是:RaynorPao
|
glGameSU
一般會員 發表:3 回覆:1 積分:0 註冊:2002-08-04 發送簡訊給我 |
各位大大: 我該如何寫個console的程式,裡面可以使用MFC的class??
例如:我只是想更容易處理讀寫檔案,想利用CFile or CStdioFile
可是都不能用.... 查過MSDN後,發現個範例 //A second example for CFile::Open.
//This console program uses CFile to copy binary files. #include
#include
#include using namespace std; CWinApp theApp; int main(int argc, char *argv[])
{
if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))
{
cout << "panic: MFC couldn't initialize!" << endl;
return 1;
} // constructing these file objects doesn't open them CFile sourceFile;
CFile destFile; // see that we have a reasonable number of arguments if (argc != 3)
{
cout << "usage: " << argv[0];
cout << " " << endl;
cout << endl;
return 1;
} // we'll use a CFileException object to get error information CFileException ex; // open the source file for reading if (!sourceFile.Open(argv[1],
CFile::modeRead | CFile::shareDenyWrite, &ex))
{
// complain if an error happened
// no need to delete the ex object TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
cout << "Couldn't open source file: ";
cout << szError;
return 1;
}
else
{
if (!destFile.Open(argv[2], CFile::modeWrite |
CFile::shareExclusive | CFile::modeCreate, &ex))
{
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
cout << "Couldn't open source file: ";
cout << szError; sourceFile.Close();
return 1;
} BYTE buffer[4096];
DWORD dwRead; // Read in 4096-byte blocks,
// remember how many bytes were actually read,
// and try to write that many out. This loop ends
// when there are no more bytes to read. do
{
dwRead = sourceFile.Read(buffer, 4096);
destFile.Write(buffer, dwRead);
}
while (dwRead > 0); // Close both files destFile.Close();
sourceFile.Close();
} return 0;
} 都會出現以下兩個ERROR:
error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z) error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z) 請問這兩個function定義在 process.h 中
_beginthreadex
_endthreadex
是不是我該包進哪個.lib檔阿? 或者有更簡單的方法?
|
RaynorPao
版主 發表:139 回覆:3622 積分:7025 註冊:2002-08-12 發送簡訊給我 |
引言: error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z) error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z) 請問這兩個function定義在 process.h 中 _beginthreadex _endthreadex 是不是我該包進哪個.lib檔阿? glGameSU 你好: 請問~~你是不是用 VC 的 compiler 呢?? 如果是的話~~只需要依照下列方式更改 > (> --
------
-- 若您已經得到滿意的答覆,請適時結案!! -- -- 欲知前世因,今生受者是;欲知來世果,今生做者是 -- -- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 -- |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |