标题:GetWindowThreadProcessId,无法正常获取进程ID,
只看楼主
asd577586785
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-7-30
结帖率:50%
已结贴  问题点数:0 回复次数:1 
GetWindowThreadProcessId,无法正常获取进程ID,
我写了一个程序,其他要用到GetWindowThreadProcessId获取进程ID
GetWindowThreadProcessId(hWnd,lpdwProcessId)
hWnd
目标窗口句柄
lpdwProcessId
函数在这里返回进程ID,

函数返回值:
线程ID

我好想没有翻译错吧!~~~~~
这个函数执行完成后,lpdwProcessId 这个变量返回了零,进程ID获取不了,
 返回值: 返回的好想是线程ID,这个函数执行完后后返回的值非零,应该是线程ID,我也无法验证,下面是源程序 大家帮我看看是哪里错误了

        .386
        .model flat,stdcall
        option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include        windows.inc
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDD_DLG1     EQU    1000    ;主窗口
IDC_BTN2     EQU    1002    ;按钮
IDC_Hd         EQU    1001    ;
IDC_SetHd     EQU    1003    ;编辑框_句柄
IDC_ID         EQU    1004   
IDC_SetID     EQU    1005    ;编辑框_进程ID
IDC_SetjinchengHd EQU    1006    ;编辑框_进程句柄
IDC_STC1     EQU    1007
ICO_MAIN     EQU    100
IDC_CALL     EQU    00402360h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .data?
hInstance    dd    ?
hWndMain    dd    ?
ThreadID    dd    ?
ThreadHa    dd    ?
CreateThreadID    dd    ?

        .const
lpWindowName    db    'MyGame',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain    proc    uses ebx edi esi hWnd,wMsg,wParam,lParam        
        mov    eax,wMsg
        .if    eax ==    WM_CLOSE
            invoke    EndDialog,hWnd,NULL
        .elseif    eax ==    WM_INITDIALOG
            invoke    LoadIcon,hInstance,ICO_MAIN
            invoke    SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
        .elseif    eax ==    WM_COMMAND
            mov    eax,wParam
            .if    ax == IDC_BTN2
                invoke    FindWindow,NULL,addr lpWindowName        ;获取窗口句柄
                mov    hWndMain,eax
                invoke    SetDlgItemInt,hWnd,IDC_SetHd,hWndMain,TRUE    ;把窗口句柄设置到编辑框内   
                invoke    GetWindowThreadProcessId,hWndMain,ThreadID    ;获取进程ID
                invoke    SetDlgItemInt,hWnd,IDC_SetID,ThreadID,TRUE
                invoke    OpenProcess,PROCESS_ALL_ACCESS,FALSE,ThreadID    ;获取进程句柄
                mov    ThreadHa,eax
                invoke    SetDlgItemInt,hWnd,IDC_SetjinchengHd,ThreadHa,TRUE
                invoke    CreateRemoteThread,ThreadHa,NULL,0,IDC_CALL,NULL,0,CreateThreadID
            .endif
        .else
            mov    eax,FALSE
            ret
        .endif
        mov    eax,TRUE
        ret
_ProcDlgMain endp
start:
        invoke    GetModuleHandle,NULL
        mov    hInstance,eax
        invoke    DialogBoxParam,hInstance,IDD_DLG1,NULL,offset _ProcDlgMain,NULL
        invoke    ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        end    start


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
下面是RC资源

#define IDD_DLG1 1000
#define IDC_BTN2 1002
#define IDC_Hd 1001
#define IDC_SetHd 1003
#define IDC_ID 1004
#define IDC_SetID 1005
#define IDC_SetjinchengHd 1006
#define IDC_STC1 1007
#define ICO_MAIN 100

#include <resource.h>

IDD_DLG1 DIALOGEX 10,10,186,72
CAPTION "远程调用CALL"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
  CONTROL "远程调用 加血",IDC_BTN2,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,123,3,57,15
  CONTROL "窗口Hd:",IDC_Hd,"Static",WS_CHILDWINDOW|WS_VISIBLE,6,6,41,9
  CONTROL "",IDC_SetHd,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,48,3,54,15,WS_EX_CLIENTEDGE
  CONTROL "进程ID:",IDC_ID,"Static",WS_CHILDWINDOW|WS_VISIBLE,6,27,33,9
  CONTROL "",IDC_SetID,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,48,24,54,15,WS_EX_CLIENTEDGE
  CONTROL "",IDC_SetjinchengHd,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,48,42,54,15,WS_EX_CLIENTEDGE
  CONTROL "进程Hd:",IDC_STC1,"Static",WS_CHILDWINDOW|WS_VISIBLE,6,45,36,9
END

ICO_MAIN ICON DISCARDABLE "Main.ico"
搜索更多相关主题的帖子: option 源程序 
2011-09-21 16:30
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
得分:20 
pdwProcessId [out, optional]

    Type: LPDWORD

    A pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not.

一个指针 指向接收进程ID的变量

懂了么。。
2011-09-21 20:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-350503-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091675 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved