LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 534|回复: 0

帮忙看一下这个程序哪里有错,谢谢

[复制链接]
发表于 2004-6-10 16:08:13 | 显示全部楼层 |阅读模式

  1. #include <X11/Intrinsic.h>
  2. #include <stdio.h>
  3. Window FindWindow(Display* pDisplay, Window start, char* name)
  4. {
  5.   Status stat;
  6.   int i,num;
  7.   Window w,root,parent;
  8.   Window* children = NULL;
  9.   char* title;
  10.   if(XFetchName(pDisplay, start, &title) == 1)
  11.   {
  12.     if (strcmp(name, title)==0)
  13.     {
  14.       XFree(title);
  15.       return start;
  16.     }
  17.     XFree(title);
  18.   }
  19.   stat = XQueryTree(pDisplay, start, &root, &parent, &children, &num);
  20.   if (stat == 1)
  21.   {
  22.     /* search each child window for a match: */
  23.     for (i = num; i > 0; i--)
  24.     {
  25.       if (XFetchName(pDisplay, start, &title )==1)
  26.       {
  27.         if (strcmp(name, title)==0)
  28.         {
  29.           /*found it*/
  30.           XFree(title);
  31.           return start;
  32.         }
  33.         XFree(title);
  34.       }
  35.     }
  36.     /*search the descendents of each child for a match:*/
  37.     for (i = num; i > 0; i--)
  38.     {
  39.       w == FindWindow(pDisplay, children[i], name);
  40.       if (w != 0)
  41.       {
  42.         XFree(children);
  43.         return w;
  44.       }
  45.     }
  46.     if (children != NULL)
  47.     {
  48.       XFree(children);
  49.     }
  50.   }
  51.   return 0;
  52. }
  53. int main(int argc, char* argv[])
  54. {
  55. //  Widget toplevel = XtInitialize(argv[0], "Get_URL", NULL, 0, &argc, argv);
  56. //  Display *dpy = XtDisplay(toplevel);
  57.   Display *dpy = XOpenDisplay(0);
  58.   FindWindow(dpy,DefaultRootWindow(dpy),"rdesktop");
  59.   return 1;
  60. }
  61.    
复制代码

这个程序是我用来找rdesktop窗口的,编译运行后出现如下错误:
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x211
  Serial number of failed request:  682
  Current serial number in output stream:  682
应该怎么改啊?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表