Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the createprocessasuser function

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use the createprocessasuser function, the article is very detailed, has a certain reference value, interested friends must read it!

If you want to create a complex UI program interface to the desktop user Session through the service, you need to use the CreateProcessAsUser function to create a new process for the user to run the corresponding program. Open the Interop class and continue adding the following code:

CreateProcessAsUser function prototype

BOOLWINAPICreateProcessAsUser (

_ In_opt_HANDLEhToken

_ In_opt_LPCTSTRlpApplicationName

_ Inout_opt_LPTSTRlpCommandLine

_ In_opt_LPSECURITY_ATTRIBUTESlpProcessAttributes

_ In_opt_LPSECURITY_ATTRIBUTESlpThreadAttributes

_ In_BOOLbInheritHandles

_ In_DWORDdwCreationFlags

_ In_opt_LPVOIDlpEnvironment

_ In_opt_LPCTSTRlpCurrentDirectory

_ In_LPSTARTUPINFOlpStartupInfo

_ Out_LPPROCESS_INFORMATIONlpProcessInformation

)

Sample code that uses CreateProcessAsUser

-CreateProcessEx.h file-

# ifndef_CREATE_PROCESS_EX_H_

# define_CREATE_PROCESS_EX_H_

# include

# include "tchar.h"

# pragmacomment (lib, "shell32")

# pragmacomment (lib, "user32")

# pragmacomment (lib, "Advapi32.lib")

/ / start the process with normal permissions

BOOLCreateProcessLow (TCHAR*lpApplicationName

TCHAR*lpCommandLine=NULL

TCHAR*lpDirectory=NULL

UINTnShow=SW_SHOWNORMAL)

/ / start the process with administrator privileges

BOOLCreateProcessHigh (TCHAR*strProcessName

TCHAR*strCommandLine=NULL

TCHAR*lpDirectory=NULL

UINTnShow=SW_SHOWNORMAL)

# endif//_CREATE_PROCESS_EX_H_

-CreateProcessEx.h file-

-CreateProcessEx.cpp file-

# include "CreateProcessEx.h"

# include

Usingnamespacestd

The above is all the contents of the article "how to use the createprocessasuser function". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report