EnumWindowsProc enmWinProc = new EnumWindowsProc(WindowsProc);
 EnumWindows(enmWinProc, 0);在C/S程序里面是正常的写成了windows服务后, 会出现索引越界报错:发生了未处理的异常[color=#FF0000]/("System.IndexOutofRangeException")[color]主要代码如下:
---------------------------        [DllImport("user32.dll")]
        public static extern int EnumWindows(EnumWindowsProc x, int y);        [DllImport("user32.dll")]
        public static extern int GetWindowText(int hwnd, StringBuilder lpstring, int cch);       public static bool WindowsProc(int hWnd, int lParam)
        {
            StringBuilder vBuffer = new StringBuilder(256);
            GetWindowText(hWnd, vBuffer, vBuffer.Capacity);
            string S = vBuffer.ToString();
            int I = S.IndexOf("_mybook_Client");
            if (I > 0)
            {
                S = S.Remove(I, S.Length - I);
                qqlist += S + Environment.NewLine;
            }
            return true;
        }