Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: NT
Expertise: Beginner
Jun 22, 1998

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 CreateProcess
Private 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 CreateProcess
Private 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 constants
Private 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 CreateProcess
Private 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 Long
End Type

Private Type SECURITY_ATTRIBUTES
   nLength As Long
   lpSecurityDescriptor As Long
   bInheritHandle As Long
End Type

Private Type PROCESS_INFORMATION
   hProcess As Long
   hThread As Long
   dwProcessId As Long
   dwThreadID As Long
End Type

Private 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 Long
Private Declare Function CloseHandle _
   Lib "kernel32" _
   (ByVal hObject As Long) As Long

' API calls
Private 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 LogonUser
Private 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&
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date