全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:955
推到 Plurk!
推到 Facebook!

使用new 產生物件??

答題得分者是:axsoft
tpchen
一般會員


發表:3
回覆:7
積分:2
註冊:2003-08-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-24 23:43:56 IP:61.64.xxx.xxx 未訂閱
我的Project不具備Form。 但我想使用VCL的元件,如TADOConnection。 因此,當我想產生一個物件時如TADOConnection *adoConnection = new TADOConnection(0); 在編譯時期沒有錯誤。 在執行時期卻出現如下圖的錯誤。 不知,有哪位先進知道如何解決這個問題?
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-25 00:15:21 IP:211.76.xxx.xxx 未訂閱
tpchen您好:    請參閱此篇文章試試 Resolving strange runtime errors in my VCL enabled console application. - by Borland Developer Support Staff http://community.borland.com/article/0,1410,26084,00.html    原文如下: Resolving strange runtime errors in my VCL enabled console application. - by Borland Developer Support Staff    Abstract: A bug in the Console Wizard makes it possible to create a broken project when using the VCL. This document explains the problem and workarounds.    Symptoms:  Access violation at application start up or shut down. Access violation when dynamically allocating STL objects. STL strings lose data for no reason. Most likely to happen in VCL enabled console applications created with Console Wizard.  Problem: Any application that uses the VCL must be compiled with the thread safety compiler setting and linked to the VCL enabled runtime library (cp32mt.lib or cp32mti.lib). The IDE usually takes care of these settings for you, based on the project type you select. Unfortunately, a bug in the Console Wizard makes it possible to create a VCL enabled console project that does not compile for thread safety, but does link to the correct library. Inside the Console Wizard (File | New... | Console Wizard), you'll notice that the 'Multithread' box grays out when you check 'Use VCL' but does not become checked if it was not checked to begin with. Clicking 'OK' when 'VCL' is checked and 'Multithreaded' is not checked causes the error condition. Solution: For new projects, make sure 'Multithreaded' is checked if you are using the VCL. For existing projects, you must manually fix the problem in the project file. Open the project file (.BPR file) in an external editor such as notepad. Search for the line beginning with:
/*開心的事情別隱藏在心裡,分享給別人知道會更快樂的*/
/*得到新知識別隱藏在心裡,分享給別人了解會更清楚的*/
發表人 - axsoft 於 2003/08/25 00:17:15
tpchen
一般會員


發表:3
回覆:7
積分:2
註冊:2003-08-24

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-25 14:59:35 IP:211.75.xxx.xxx 未訂閱
這是一個解決的方式。我在new Project時,確實沒有將MultiThread的選項打開。 但是,我最後的解決方式是在我主程式一開始使加入 CoInitialize(NULL); 並在程式結尾處加入CoUninitialize();。
系統時間:2024-06-28 8:27:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!