Bonjour,
suite a mon probleme d hier (ICI)
j ai utilisé l API Createprocesswithlogon j ai un probleme pour l argument startupinfo : Type d argument byref incomptatible j ai tenté pas mal de truc mais la je séche...
voici mon code :
ds un module :
et ds ma form :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 Private Const SW_SHOWNORMAL = 1 Private Const LOGON_WITH_PROFILE = &H1& Private Const LOGON_NETCREDENTIALS_ONLY = &H2& Private Const CREATE_DEFAULT_ERROR_MODE = &H4000000 Private Const CREATE_NEW_CONSOLE = &H10& Private Const CREATE_NEW_PROCESS_GROUP = &H200& Private Const CREATE_SEPARATE_WOW_VDM = &H800& Private Const CREATE_SUSPENDED = &H4& Private Const CREATE_UNICODE_ENVIRONMENT = &H400& Private Const ABOVE_NORMAL_PRIORITY_CLASS = &H8000& Private Const BELOW_NORMAL_PRIORITY_CLASS = &H4000& Private Const HIGH_PRIORITY_CLASS = &H80& Private Const IDLE_PRIORITY_CLASS = &H40& Private Const NORMAL_PRIORITY_CLASS = &H20& Private Const REALTIME_PRIORITY_CLASS = &H100& Public Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String 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 Public Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessID As Long dwThreadID As Long End Type Declare Function CreateProcessWithLogon Lib "Advapi32" Alias "CreateProcessWithLogonW" (ByVal lpUsername As Long, ByVal lpDomain As Long, ByVal lpPassword As Long, ByVal dwLogonFlags As Long, ByVal lpApplicationName As Long, ByVal lpCommandLine As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInfo As PROCESS_INFORMATION) As Long
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Private Sub Form_Load() TB_Nb_Echantillons.Text = Configuration.L_Nb_Echantillons_Fluox.Caption TB_Nb_Echantillons_ICP.Text = Configuration.L_Nb_Echantillons_ICP.Caption TB_Repertoire_Courant.Text = Configuration.L_Rep_Courant L_Nb_Elems.Caption = Configuration.L_Nb_Intnsity Dim Startup As STARTUPINFO Dim ProcessInf As PROCESS_INFORMATION Dim return_value As Long Dim app_to_run As String Startup.cb = Len(Startup) lpDomain = "." 'C'est ce qu'il faut mettre pour XP lpUsername = "bob" lpPassword = "bob" 'app_to_run = App.Path & "CelVal.exe" 'On veut lancer Half life par exemple lpApplicationName = App.Path & "CelVal.exe" lpCommandLine = vbNullString lpCurrentDirectory = vbNullString 'Login = "bob" 'Nom du compte sur lequel on veut se logger 'Pass = "bob" 'Mot de passe pour ce compte return_value = CreateProcessWithLogon(StrPtr(lpUsername), StrPtr(lpDomain), StrPtr(lpPassword), LOGON_WITH_PROFILE, StrPtr(lpApplicationName), StrPtr(lpCommandLine), CREATE_DEFAULT_ERROR_MODE Or CREATE_NEW_CONSOLE Or CREATE_NEW_PROCESS_GROUP, ByVal 0&, StrPtr(lpCurrentDirectory), StartInfo, ProcessInfo) End Sub
Partager