检查是否在 X Window 中运行

标签 c x11

Linux C 程序:

什么函数调用可以检查是否在 X Window 中运行?

如果不在 X Window 中,则 printf。

最佳答案

你的意思是这样的:

#include <X11/Xlib.h>

  // ...

  char *display_name = NULL;

  /* connect to X server */
  if ( (display=XOpenDisplay(display_name)) == NULL )
  {
    //printf or whatever
  }

关于检查是否在 X Window 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14860899/

相关文章:

c++ - 不同数据类型的二进制格式

opengl - 如何在 C 中使用 GLX_EXT_texture_from_pixmap 将 X11 Pixmap 用作 OpenGL 纹理?

c++ - 在QT应用程序中制作一个透明孔

ssh - 无法使用 Putty 通过 ssh 启动 X11

c - 如何分析 R 包中的底层 C 代码?

c - c 中的 char 指针数组

c - 如何在 Ubuntu 10.04 (lucid) 上安装 xlibs-dev?

keyboard - Dyalog APL 劫持 Windows Key 并且不归还它(Fedora 32/Gnome,Free Licence,Kitty)

vim - 在gvim中设置默认字体

c - pthread总线错误