VC debugging tips (rookie level)

zhaozj2021-02-16  38

1. How to view the error message in the debug state (getLastError ())?

You can usually get the error number with getLastError () and then use formatMessage (...) to get an error description.

Here is a more direct approach: add @ Err, HR at Watch Window

2. How do I know if the program has memory leaks?

In the VC development environment, the program is run in the debug state, and the test may occur, close the program, close the program, view the run information in the Output window. If a leak occurs, there will be records in Output.

Of course, it is not possible to rely entirely on this way to find that the program runs with memory leaks.

3. When a variable meets a certain condition, stop in the breakpoint.

As the following segment:

2 int ilocation;

...

30 ILOCATION

...

Requirements: There is a breakpoint in Line30 and want to stop in this breakpoint when ILocation> 100.

Solution:

1. Set breakpoints in line30, Press Alt F9 OR selection menu [edit] | [BreakPoints]

2. Select the [clocation] page, select the breakpoint above in Listbox.

3. Click [Condition], enter iLocation> 100 in the first editing box

4. [OK]

Note: I published an article for the first time, I hope I can help everyone :-)

转载请注明原文地址:https://www.9cbs.com/read-26571.html

New Post(0)