windows security - How can I get the current user's SID in VB6? -
I have some old codes that we have to maintain in VB6. We need to add the ability of the current user to see the SID. Does anyone ever tell me some code that how does it show? Thanks in advance for your help!
try it
option clear '--- OpenProject Tokens Long = and H 20008 Pvt Decler as Private Constant Toucan_Ad all copyMemory Lib "Kernel 32" nicknamed "RTLMomemory" (not equal to PTO, in any form, as long as U., as long as ) Private Announcement Function GetCurrentProcess Lib "kernel32" () Long closed as the Private Declaration Function "H Nernel 32 "(Bye-H object as Long) OpenProcessToken Lib" advapi32.dll "(ByVal ProcessHandle as long as long as long as long as a personal announcement ceremony, long access to tokens are long) Long-time private announcement function GetTokenInformation Lib "advapi32.dll" (ByVal TokenHandle as Long, ByVal TokenInformationClass as Long, TokenInformation In any form, ByVal TokenInformationLength as long as long return lengths) Converters as Functions Dictasting Seed Lib "Advapi32.dll" Alias "Converted Sidestration Seeday" (ByVal lpSid as long, LP string long personal announcement as long as Localfree Lib "Kernel 32" (long as heim) Long personal announcement As long as the functional lustlen Lib "kernel32" the nickname "lstrlenA" (ByVal lpString as long), Long Demonstrate as Long Demil lNeeded in the form of GetCurrentUserSid () string Deamam hprocessid long dim hToken form of the form of baBuffer () By in Dim sBuffer As String Dim lpSid as chronically low hprocessid = GetCurrentProcess (as long as lpString in) that hprocessid & lt; & Gt; 0) Call the GetTokenInformation (HTC, 1, BY, 0, L. Einidade) = 1 then OpenProtitocon (HProCDID, TokenWad, HTCen) = 1 Redeem Baber Buffer (0Linided) '--- Enum TokenAnnanceClass {TokenUser = 1, TokenGroup = 2, ...} If GetTokenInformation (hToken, 1, baBuffer (0), UBound (baBuffer), lNeeded = 1 then call coppy (lpSid, baBuffer (0), 4) If ConvertSidToStringSid (lpSid, lpString) then sBuffer = Space (Lestling Call) Comemoration (Bye Whisb Esbufer, Bye VL LP String, Lane (Assfuffer)) Call Local Free (LP string) GetCurrentUserSid = sBuffer End if and call call Handle (HTC) and if Call CloseHandley (HprocidID) End and Function
Comments
Post a Comment