EvoTalk

28 八月, 2006

EnumWindows Debug Error

Posted by: asd In: 科技新知| 軟體使用 ()

VC6下用 Debug 模式執行EnumWindow 發生如下圖有關暫存器 ESP 的錯誤,Release 模式又ok

C++:
  1. EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
  2.  
  3. BOOL EnumWindowsProc(HWND hWnd, long lParam)
  4. {
  5. char Buff[1000], NameOfClass[1000];
  6. HWND hChild;
  7. GetWindowText(hWnd, Buff, 1000);
  8. GetClassName(hWnd, NameOfClass, 1000);
  9. if (strcmp(NameOfClass, "Notepad") == 0) {
  10. hChild = GetWindow(hWnd, GW_CHILD);
  11. GetClassName(hChild, NameOfClass, 1000);
  12. GetWindowText(hChild, Buff, 1000);
  13. g_hWnd = hChild;
  14. return FALSE;
  15. }
  16. return TRUE;
  17. }

ESP Error

Solution

do NOT use the compile option "/Gz", this option changes the calling convention

/Gd __cdecl calling convention
/Gr __fastcall calling convention
/Gz __stdcall calling convention

Tags: ,

Releated Posts



No Responses to "EnumWindows Debug Error"

Comment Form