Home > Software engineering >  Cut in VB6.0 by use in Windows 7 advapi32. DLL
Cut in VB6.0 by use in Windows 7 advapi32. DLL

Time:10-06

Private Const LOGON32_LOGON_INTERACTIVE=2
Private Const LOGON32_PROVIDER_DEFAULT=0

Private Enum TOKEN_TYPE
TokenPrimary=1
TokenImpersonation
End Enum

Private Enum SECURITY_IMPERSONATION_LEVEL
SecurityAnonymous=0
SecurityIdentification
SecurityImpersonation
SecurityDelegation
End Enum
Private Declare Function LogonUser Lib "advapi32. DLL Alias" _
"LogonUserA" _
(ByVal lpszUsername As String, _
ByVal lpszDomain As String, _
ByVal lpszPassword As String, _
ByVal dwLogonType As Long, _
ByVal dwLogonProvider As Long, _
PhToken As Long As Long)

Private Declare Function DuplicateTokenEx _
Lib "advapi32. DLL" (ByVal hExistingToken As Long, _
ByVal dwDesiredAccess As Long, _
ByVal lpTokenAttributes As Long, _
ImpersonationLevel As SECURITY_IMPERSONATION_LEVEL, _
ByVal TokenType As TOKEN_TYPE, _
PhNewToken As Long) As Boolean


Private Sub Command1_Click ()
Dim the Result As Long
Dim htoken As Long
Dim hNewToken As Long, As Long I
Result=LogonUser (" Administrator ", ""," 111 ", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, htoken)
MsgBox htoken
MsgBox DuplicateTokenEx (htoken, 0, I, SECURITY_IMPERSONATION_LEVEL SecurityImpersonation, TOKEN_TYPE. TokenPrimary, hNewToken)
MsgBox hNewToken
End Sub


Want hNewToken values, the code in the xp environment can get the result, but not under Windows 7, should be user permissions,
Hope ace to give the solution

CodePudding user response:

You must make your program "with administrator,"
Program without permission is not oneself up permissions, otherwise the safety of the system is false,

CodePudding user response:

reference 1st floor Tiger_Zhao response:
you must make your program "with administrator,"
Program without permission is not oneself up permissions, otherwise the safety of the system is false,

This program is an adaptation of vb.net, there is no problem in vb.net

CodePudding user response:

Since doubt permission problems, don't you try out this possible?

CodePudding user response:

refer to the second floor fly291 response:
Quote: refer to 1st floor Tiger_Zhao response:

You must make your program "with administrator,"
Program without permission is not oneself up permissions, otherwise the safety of the system is false,

This program is an adaptation of vb.net, there is no problem in vb.net

A great god, and the vb code started from today, as I really do not know how

CodePudding user response:

Compiled exe file right-click on processing, with administrator,

CodePudding user response:

reference 4 floor fly291 response:
Quote: refer to the second floor fly291 response:

Quote: refer to 1st floor Tiger_Zhao response:

You must make your program "with administrator,"
Program without permission is not oneself up permissions, otherwise the safety of the system is false,

This program is an adaptation of vb.net, there is no problem in vb.net

The great god, vb code started from today, as I really do not know how

Try or not

CodePudding user response:

reference 5 floor Tiger_Zhao reply:
compile processing right-click exe file, use administrator,
tried or not

CodePudding user response:

Determine the.net application can successfully under Windows 7?
So GetLastError get error messages, see what wrong,
  •  Tags:  
  • API
  • Related