VC6.0中怎样用特定的用户打开别的程序,跪求指导!
在小弟的程序a.exe中,需要打开b.exe。而现在面临的情况
是这样,因为a.exe是通过系统服务运行起来的.所以在任务管理器中
a.exe的用户名是SYSTEM,接下来问题在这里了,在a.exe打开的b.exe
他的运行身份也是SYSTEM,正因为这样我的b.exe运行起来后不正常.
而我现在需要把b.exe以Administrator用户来运行才可以正常使用。
b.exe是通过在a.exe(是MFC程序来的)中以ShellExecute函数来打开的。
现求助各位,希望贴出相关代码可以解决小弟的问题。
小弟的是XP系统。 mfc
[解决办法]
BOOL WINAPI CreateProcessAsUser(
__in_opt HANDLE hToken,
__in_opt LPCTSTR lpApplicationName,
__inout_opt LPTSTR lpCommandLine,
__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in_opt LPVOID lpEnvironment,
__in_opt LPCTSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation
);