可以在Win7上使用MSYS2使用终止程序

发布于 2025-01-24 22:45:44 字数 770 浏览 5 评论 0原文

我正在制作像发射器一样的GTK3应用程序。我使用MSYS2和MSVC2010在Linux和Windows7中开发。每一个都很好,除了我无法使用 terminateProcess ,因为我会收到此警告:

implicit declaration of function 'TerminateProcess'

这是代码的一部分:

#if defined(G_OS_WIN32)
#if defined(__GNUC__)
#include <w32api.h>
#define WINVER WindowsXP
#define _WIN32_WINNT WindowsXP
#define _WIN32_WINDOWS WindowsXP
#define _WIN32_IE IE7
#endif
#include <processthreadsapi.h>
#endif
#include <gtk/gtk.h>

// ...

void kill_process (GPid pid)
{
#if defined(G_OS_WIN32)
    TerminateProcess (pid, 0);
#else
    kill (pid, SIGTERM);
#endif
    g_spawn_close_pid (pid);
}

上述功能 kill_process 在Linux和Windows中的预期工作(MSVC 2010),但与MSYS2 Mingw64相关...有什么想法吗?

I'm making in gtk3 app that behaves like a launcher. I'm developing in linux and windows7 with msys2 and msvc2010. Everyhing is fine except that I can't use TerminateProcess because I get this warning:

implicit declaration of function 'TerminateProcess'

This is part of the code:

#if defined(G_OS_WIN32)
#if defined(__GNUC__)
#include <w32api.h>
#define WINVER WindowsXP
#define _WIN32_WINNT WindowsXP
#define _WIN32_WINDOWS WindowsXP
#define _WIN32_IE IE7
#endif
#include <processthreadsapi.h>
#endif
#include <gtk/gtk.h>

// ...

void kill_process (GPid pid)
{
#if defined(G_OS_WIN32)
    TerminateProcess (pid, 0);
#else
    kill (pid, SIGTERM);
#endif
    g_spawn_close_pid (pid);
}

The above function kill_process works as expected in linux and in windows (msvc 2010), but it doesn't with msys2 mingw64... any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文