2013-08-02 41 views
0

我必須擴展終端服務器軟件才能使用Windows 8.1。 該場景如下:以編程方式在c#中隱藏Windows 8.1的瓦片

兩臺電腦:一臺運行客戶端軟件,另一臺運行服務器。 服務器的操作系統是Windows 8.1

當用戶按下客戶端PC上的按鈕時,它會通過虛擬通道向服務器PC打開RDP連接。 必須有一個登錄,並且必須隱藏磁貼,並且軟件的服務器部分也應該被啓動。

爲了隱藏在早期版本中,我們使用下面的命令窗口的普通桌面:

// For Windows Vista and Windows 7 hide the Status-Bar and all Desktop-Icons 
int a_hWndTaskBar  = FindWindow("Shell_TrayWnd", null); 
int a_hWndStart  = FindWindow("Button", "Start"); 
int a_hWndDesktop  = FindWindow("Progman", null); 
bool a_bResult   = false; 

try 
{ 
    a_bResult = SetWindowPos(a_hWndTaskBar, 0, 0, 0, 0, 0, SWP_HIDEWINDOW); 
    a_bResult = SetWindowPos(a_hWndStart, 0, 0, 0, 0, 0, SWP_HIDEWINDOW); 
    a_bResult = ShowWindow(a_hWndDesktop, SW_HIDE); 
} 
catch(Exception e) 
{ 
    MessageBox.Show(e.Message); 
} 

我有什麼爲了與Windows 8.1,以實現這一目標呢?

問候 馬庫斯

回答

0

這裏:對我的作品:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Runtime.InteropServices; 

namespace Constants.UI 
{ 

    public class Taskbar 
    { 
     [DllImport("user32.dll")]// For Windows Mobile, replace user32.dll with coredll.dll 
     private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 

     [DllImport("user32.dll", SetLastError = true)] 
     private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); 

     [DllImport("user32.dll")] 
     private static extern int ShowWindow(int hwnd, int command); 

     private const int SW_HIDE = 0; 
     private const int SW_SHOW = 1; 

     protected static int Handle 
     { 
      get 
      { 
       return HandlePtr.ToInt32(); 
      } 
     } 
     protected static IntPtr HandlePtr 
     { 
      get 
      { 
       return FindWindow("Shell_TrayWnd", ""); 
      } 
     } 
     protected static int StartHandle 
     { 
      get 
      { 
       int hStart = FindWindow("Button", "Start").ToInt32(); 
       if (hStart == 0) 
       { 
        hStart = FindWindowEx(HandlePtr, IntPtr.Zero, "Start", null).ToInt32(); //windows 8 
       } 
       return hStart; 
      } 
     } 

     private Taskbar() 
     { 
      // hide ctor 
     } 
     static object lockAccess = new object(); 
     public static void Show() 
     { 
      try 
      { 
       lock (lockAccess) 
       { 
        ShowWindow(Handle, SW_SHOW); 
        ShowWindow(StartHandle, SW_SHOW); 
       } 
      } 
      catch { } 
     } 

     public static void Hide() 
     { 
      try 
      { 
       lock (lockAccess) 
       { 
        ShowWindow(Handle, SW_HIDE); 
        ShowWindow(StartHandle, SW_HIDE); 
       } 
      } 
      catch { } 
     } 
} 
相關問題