Acrobat Reader无法关闭 [英] Acrobat reader not closing

查看:317
本文介绍了Acrobat Reader无法关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经写成关闭acrobat阅读器的应用程序.但是由于某种原因,acrobat Reader进程正在运行,但是窗口关闭了.

I have written as application which closes acrobat reader. But for some reason acrobat reader process is running but window got close.

任何人都可以让我知道我的代码有什么问题吗?

Can any one let me know if any thing is wrong with my code?

代码段:

 

BOOL CALLBACK EnumFunction(HWND hwnd,LPARAM lParam)

BOOL CALLBACK EnumFunction( HWND hwnd, LPARAM lParam )

{

     DWORD dwProcID = *(((LPDWORD)lParam);

    DWORD dwProcID = * ((LPDWORD) lParam);

     DWORD dwID = 0;

    DWORD dwID = 0;

     char arr [260] = {0};

     char arr[260] = {0};

     if(GetWindowThreadProcessId(hwnd,& dwID)&&  (dwID == dwProcID))

    if (GetWindowThreadProcessId(hwnd, &dwID) &&  (dwID == dwProcID))

     {

    {

          PostMessage(hwnd,WM_CLOSE,0,0);

          PostMessage(hwnd, WM_CLOSE, 0, 0);

    }

    }

 

    返回TRUE;

    return TRUE ;

}

 

 

 

VOID TerminateAppn(HWND hWnd)

VOID TerminateAppn(HWND hWnd)

{

 

     DWORD    dwPID = 0,dwThread = 0;

    DWORD    dwPID = 0, dwThread = 0;

 

     dwThread = GetWindowThreadProcessId(hWnd,& dwPID);

    dwThread = GetWindowThreadProcessId(hWnd, &dwPID);

    //  EnumFunction()将WM_CLOSE发布到其PID的所有顶级窗口

    // EnumFunction() posts WM_CLOSE to all top level windows whose PID

    //与您的进程匹配.

    // matches your process's.

     EnumDesktopWindows(NULL,(WNDENUMPROC)&EnumFunction,(LPARAM)& dwPID);

    EnumDesktopWindows(NULL, (WNDENUMPROC) EnumFunction, (LPARAM) &dwPID) ;

  }

  }

 

int _tmain(int argc,_TCHAR * argv [])

int _tmain(int argc, _TCHAR* argv[])

{

     HWND hWnd = FindWindow(_T("AcrobatSDIWindow"),_T("Adob​​e Reader")));

    HWND hWnd = FindWindow(_T("AcrobatSDIWindow"), _T("Adobe Reader"));

     TerminateAppn(hWnd);

    TerminateAppn(hWnd);

    返回0;

    return 0;

}

您可以运行该程序,然后查看acrobat Reader是否关闭.我已经尝试使用Acrobat Reader 9.1

You can run this program and see acrobat reader is not closing. I have tried with acrobat reader 9.1

 

推荐答案

好吧,您只发布了WM_CLOSE,您实际上不能保证这实际上会退出应用程序.最好的尝试是发布WM_QUIT消息.
Well, you are only posting WM_CLOSE, you can't actually guarantee that this will actually quit the application. The best thing to try is post the WM_QUIT message.


这篇关于Acrobat Reader无法关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆