devxlogo

NT API

NT API

Question:
I am trying to use the CreateProcessAsUser API function. If I put the declaration found in the win32api.txt, the program responds, “Can’t found DLL entry point” (Lib kernel32 function CreateProcessAsUserA).

Answer:
You didn’t give the declaration you are using, but the following should work:

' Constants used with CreationFlags in CreateProcessPrivate Const NORMAL_PRIORITY_CLASS As Long = &H20&Private Const HIGH_PRIORITY_CLASS As Long = &H80&Private Const IDLE_PRIORITY_CLASS As Long = &H40&Private Const REALTIME_PRIORITY_CLASS As Long = &H100&' Constants used with CreateProcessPrivate Const STARTF_USESHOWWINDOW As Long = &H1&Private Const STARTF_USESIZE As Long = &H2&Private Const STARTF_USEPOSITION As Long = &H4&Private Const STARTF_USECOUNTCHARS As Long = &H8&Private Const STARTF_USEFILLATTRIBUTE As Long = &H10&Private Const STARTF_RUNFULLSCREEN As Long = &H20&Private Const STARTF_FORCEONFEEDBACK As Long = &H40&Private Const STARTF_FORCEOFFFEEDBACK As Long = &H80&Private Const STARTF_USESTDHANDLES As Long = &H100&Private Const CREATE_SEPARATE_WOW_VDM As Long = &H800&' ShowWindow constantsPrivate Enum ShowWindow   SW_HIDE = 0&   SW_NORMAL = 1&   SW_SHOWNORMAL = 1&   SW_SHOWMINIMIZED = 2&   SW_MAXIMIZE = 3&   SW_SHOWMAXIMIZED = 3&   SW_SHOWNOACTIVATE = 4&   SW_SHOW = 5&   SW_MINIMIZE = 6&   SW_SHOWMINNOACTIVE = 7&   SW_SHOWNA = 8&   SW_RESTORE = 9&   SW_MAX = 10&   SW_SHOWDEFAULT = 10&End Enum' Structures used with CreateProcessPrivate Type STARTUPINFO   cb As Long   lpReserved As Long   lpDesktop As Long   lpTitle As Long   dwX As Long   dwY As Long   dwXSize As Long   dwYSize As Long   dwXCountChars As Long   dwYCountChars As Long   dwFillAttribute As Long   dwFlags As Long   wShowWindow As Integer   cbReserved2 As Integer   lpReserved2 As Long   hStdInput As Long   hStdOutput As Long   hStdError As LongEnd TypePrivate Type SECURITY_ATTRIBUTES   nLength As Long   lpSecurityDescriptor As Long   bInheritHandle As LongEnd TypePrivate Type PROCESS_INFORMATION   hProcess As Long   hThread As Long   dwProcessId As Long   dwThreadID As LongEnd TypePrivate Declare Function CreateProcessAsUser _   Lib "kernel32" Alias "CreateProcessAsUserA" _   (ByVal hToken As Long, _    ByVal lpApplicationName As String, _    ByVal lpCommandLine As String, _    ByVal lpProcessAttributes As Long, _    ByVal lpThreadAttributes As Long, _    ByVal bInheritHandles As Long, _    ByVal dwCreationFlags As Long, _    ByVal lpEnvironment As Long, _    ByVal lpCurrentDirectory As String, _    lpStartupInfo As STARTUPINFO, _    lpProcessInformation As PROCESS_INFORMATION) As LongPrivate Declare Function CloseHandle _   Lib "kernel32" _   (ByVal hObject As Long) As Long' API callsPrivate Declare Function LogonUser _   Lib "Advapi32" Alias "LogonUserA" _   (ByVal lpszUsername As String, _    ByVal lpszDomain As Any, _    ByVal lpszPassword As String, _    ByVal dwLogonType As Long, _    ByVal dwLogonProvider As Long, _    phToken As Long) As Long' Constants used by LogonUserPrivate Const LOGON32_PROVIDER_DEFAULT As Long = 0&Private Const LOGON32_PROVIDER_WINNT35 As Long = 1&Private Const LOGON32_LOGON_INTERACTIVE As Long = 2&Private Const LOGON32_LOGON_NETWORK As Long = 3&Private Const LOGON32_LOGON_BATCH As Long = 4&Private Const LOGON32_LOGON_SERVICE As Long = 5&

See also  How to Avoid Money Transfer Scams  
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist