关于CreateProcess的问题(100分)

  • 主题发起人 主题发起人 lostlove2005
  • 开始时间 开始时间
L

lostlove2005

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使用CreateProcess(, xx系统.exe , , ,)将 xx系统.exe隐藏调度出来,也就是<br>用户看不到xxx.exe系统的界面.<br>注:xxx.exe系统界面为一个登陆框,我不希望用户看到这层窗体..
 
设置lpStartupInfo参数<br>var<br> &nbsp;si:STARTUPINFO;<br> &nbsp;pi:PROCESS_INFORMATION;<br>begin<br> &nbsp;...<br> &nbsp;FillChar(si, SizeOf(si), 0);<br> &nbsp;si.dwFlags:=STARTF_USESHOWWINDOW;<br> &nbsp;si.wShowWindow:=SW_HIDE;<br> &nbsp;CreateProcess(....,si,pi);<br>end;
 
谢谢 ,我以前将<br>si.wShowWindow:=SW_HIDE; 但是没有用.<br>不知道是不是si.dwFlags:=STARTF_USESHOWWINDOW;没有这样设置.
 
要加了si.dwFlags:=STARTF_USESHOWWINDOW,si.wShowWindow才能起作用。
 
按你的说了还是不行,请叫别人,原因如下:<br>1.msdn说StartupInfo属性中的wShowWindow只对GUI程序第一次调用showwindow生效估计是一般主窗体显示的时候已经不是第一次了吧... &nbsp;^_^<br>2.If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the SW_ constants defined in Winuser.h. Otherwise, this member is ignored. <br>For GUI processes, wShowWindow specifies the default value the first time ShowWindow is called. The nCmdShow parameter of ShowWindow is ignored. In subsequent calls to ShowWindow, the wShowWindow member is used if the nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT<br>所以这个参数只是在child第一次调用ShowWindow函数时才起作用,如果child再次调用ShowWindow函数,而且参数不是SW_SHOWDEFAULT,则窗口还是会显示出来。
 
我估计要完全隐藏被你调用的程序的窗口很难了。<br>建议楼主使用变通的方法。<br>假如该登陆窗体位置固定可以,可以在调用前显示一个顶层窗体把它遮住,<br>也可以调用该程序后,不断的搜索该窗体句柄,只要找到了就把窗体捆绑到你自定义的容器里,就好隐藏了。
 
可以新建一个Desktop,使你的xxx系统运行在这个新的Desktop里面。<br>const<br> &nbsp;DESKTOP_ALL_ACCESS= DESKTOP_CREATEMENU or DESKTOP_CREATEWINDOW or<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DESKTOP_ENUMERATE or DESKTOP_HOOKCONTROL or<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DESKTOP_JOURNALPLAYBACK or<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DESKTOP_JOURNALRECORD or DESKTOP_READOBJECTS or<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DESKTOP_SWITCHDESKTOP or DESKTOP_WRITEOBJECTS;<br>const<br> &nbsp;DesktopName='MyDeskTop';<br><br>var<br> &nbsp;DesktopHandle:THandle=0;<br> &nbsp;si:STARTUPINFO;<br> &nbsp;pi:PROCESS_INFORMATION;<br><br>procedure StartRun;<br>begin<br> &nbsp;DesktopHandle:=CreateDesktop(DesktopName,nil,nil,DF_ALLOWOTHERACCOUNTHOOK,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DESKTOP_ALL_ACCESS,nil);<br> &nbsp;GetStartupInfo(si);<br> &nbsp;si.lpDesktop:=PChar(DesktopName);<br> &nbsp;CreateProcess(nil,'C:/xxx.exe',nil,nil,False,IDLE_PRIORITY_CLASS,nil,nil,si,pi);<br>end;<br><br>procedure StopRun;<br>begin<br> &nbsp;TerminateProcess(pi.hProcess,0);<br>end;
 

Similar threads

后退
顶部