In C #:
This example shows how to get call stack in. net. Call Stack is representedStacktraceClass and a method call is representedStackframeClass. You can get the frames usingStacktrace. getframesMethod. It returns array of frames. Frame with index 0 is current executing method, frame 1 is calling method, next frame is its caller and so on.
FollowingExample writes call stack method names. It creates an instance of stacktrace (call stack), gets all frames (method CILS) and writes the method names.
[C #]
Using system. diagnostics; [stathread] public static void main () {stacktrace = new stacktrace (); // get call stack stackframe [] stackframes =Stacktrace. getframes(); // Get method CILS (frames) // write call stack method names foreach (stackframe in stackframes) {console. writeline (Stackframe. getmethod (). Name); // Write method name }}
In Win32:
Http://www.codeproject.com/KB/threads/StackWalker.aspx