使用OutputDebugString除錯視窗程式

2021-08-21 23:27:35 字數 1344 閱讀 2120

學程式設計是從dos下開始的,用了一定時間的tc2.0,使得養成了用printf輸出變數值進行除錯的壞習慣。到了寫視窗程式時,就遇到了些麻煩。

視窗程式沒有方便的進行控制台輸出的方法(其實是我不知道),於是,用了幾年的用messagebox進行輸出的除錯手段,太麻煩了,因為messagebox會打斷程式流程,還要人為手動讓它繼續執行,這是最讓人惱火的。

後來用上了vc.net2003,發現有outputdebugstring這個除錯api,在ide下除錯,則會把它的輸出定向到ide中的debugger上。

再後來發現了debugtrack,它可以截獲outputdebugstring的輸出,而不用開其它笨重的debugger。

於是,照著它的參考文件,自己寫了個截獲outputdebugstring輸出的程式llyf debugcapture。

debugcapture完全按照這份文件(

if (hbufreadyevent == null)

hdatareadyevent = createevent(

null, // no security attributes

false, // auto-reset event

false, // initial state is nonsignaled

"dbwin_data_ready" // object name

);if (hbufreadyevent == null)

while(1)

debugstring = *((struct dbwin_buffer*)(sm.buffer()));

entercriticalsection(&criticalsection);

//display the result string

//including pid,output string, process path

item = mainform->debuglistview->items->add();

item->caption = inttostr(mainform->debuglistview->items->count);

item->subitems->add(inttostr(debugstring.dwprocessid));

item->subitems->add(debugstring.data);

item->subitems->add(getprocesspath(debugstring.dwprocessid, szfilename));

listview_ensurevisible(mainform->debuglistview->handle,mainform->debuglistview->items->count-1,false);

使用GraphEdit使用

1 註冊元件。其實乙個filter就是乙個com元件,所以使用之前需要註冊,可以有兩種方法對元件進行註冊。1.直接使用命令。命令列下輸入 regsvr32 hqtlystd.ax 編譯之後你會在工程目錄下的debug中找到hqtlystd.ax,這個就是要用的filter 即可註冊成功。2.vc6....

MySQL使用學習使用 mysql學習使用

1 mysql學習 1 安裝 ubuntu下直接安裝 apt get install mysql server 2 檢查伺服器是否啟動 sudo netstat tap grep mysql,如果啟動成功,出現以下資訊 tcp00localhost.localdomain mysql listen ...

學習使用CSDN markdown使用

建立乙個自定義列表 如何建立乙個註腳 注釋也是必不可少的 katex數學公式 新的甘特圖功能,豐富你的文章 uml 圖表 flowchart流程圖 匯出與匯入 你好!這是你第一次使用markdown編輯器所展示的歡迎頁。如果你想學習如何使用markdown編輯器,可以仔細閱讀這篇文章,了解一下mar...