簡體   English   中英

當我的服務啟動時,為什么我的應用程序不顯示

[英]Why doesn't my application show when started by my service

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

const int SW_SHOW =5;

string Tartgetfile = @"C:\BringLog.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.FileName = Tartgetfile;
try
 {
  if (p.Start() == true)
   {
     ShowWindow(p.Handle, SW_SHOW);
     WriteToLog("PROCESS STARTED");
   }
  else
   {
    WriteToLog("FAILED TO START PROCESS");
   }
 }
catch (Exception ex)
 {
  WriteToLog("FAILED TO START PROCESS" + ex.Message+ ex.Source);
 }                     

我在服務onsessionchange事件中使用了此代碼,該服務在登錄事件中啟動了我的應用程序,但應用程序已隱藏但正在運行。 我看不到

默認情況下,服務無權訪問任何會話-登錄會話,Vista中的安全UAC,甚至普通用戶會話都無法訪問。 因此,他們沒有地方可以顯示其窗口。 很好 周圍有很多黑客,但是正確的方法可能是在Windows Station“ Winsta0”中創建進程。 設置STARTUPINFO.lpDesktop ="winsta0\\default"; 調用CreateProcess( )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM