遇到一个奇怪的事情
汇编版程序代码:
.386 .model flat,stdcall option casemap:none include windows.inc include user32.inc include kernel32.inc include gdi32.inc includelib gdi32.lib includelib user32.lib includelib kernel32.lib include shlwapi.inc includelib shlwapi.lib EnumChileProc proto :HWND ,:LPARAM StrCmp proto Str1:DWORD,Str2:DWORD,dwLen:dword StrLen proto strx:DWORD .data szWindowName db "资源编辑器",0 szWindowText db 1024 dup (?) szStrCmp db "文件(F)",0 dwStrlen dword ? .data? hWindow Dword ? .code start: invoke FindWindow,NULL,offset szWindowName mov hWindow,eax .if eax!=0 invoke MessageBox,NULL,offset szWindowName,NULL,MB_OK .endif invoke EnumChildWindows,hWindow,offset EnumChileProc,NULL invoke ExitProcess,NULL EnumChileProc proc hChildWnd:HWND,lParam:LPARAM invoke GetWindowText,hChildWnd,offset szWindowText,1024 ;invoke StrCmp,offset szWindowText,offset szStrCmp invoke MessageBox,NULL,offset szWindowText,NULL,MB_OK ret EnumChileProc endp
C语言版
程序代码:
#include <stdio.h> #include <stdlib.h> #include <windows.h> BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam) { char text[1024]; GetWindowText(hwnd,text,1024); printf("%s\n",text); return 1; } int main() { HWND hWnd; char *str="资源编辑器"; hWnd=FindWindow(NULL,str); if(hWnd==0){ printf("not find\n"); return 0; } EnumChildWindows(hWnd,EnumChildProc,NULL); return 0; }
程序完成的功能都是一样的 查找指定窗口标题名为 资源编辑器 并获取指定窗口子窗口文字的功能
但是汇编能找到窗口
C语言版的确找不到窗口
百思不得七届 求大侠开到