=1)>_
FriendStructureTOKEN_PRIVILEGES
'///
'///SpecifiesthenumberofentriesinthePrivilegesarray.
'///
PublicPrivilegeCountAsInteger
'///
'///SpecifiesanarrayofLUID_AND_ATTRIBUTESstructures.EachstructurecontainstheLUIDandattributesofaprivilege.
'///
PublicPrivilegesAsLUID_AND_ATTRIBUTES
EndStructure
'///
'///ImplementsmethodstoexitWindows.
'///
PublicClassWindowsController
'///Requiredtoenableordisabletheprivilegesinanaccesstoken.
PrivateConstTOKEN_ADJUST_PRIVILEGESAsInteger=&H20
'///Requiredtoqueryanaccesstoken.
PrivateConstTOKEN_QUERYAsInteger=&H8
'///Theprivilegeisenabled.
PrivateConstSE_PRIVILEGE_ENABLEDAsInteger=&H2
'///Specifiesthatthefunctionshouldsearchthesystemmessage-tableresource(s)fortherequestedmessage.
PrivateConstFORMAT_MESSAGE_FROM_SYSTEMAsInteger=&H1000
'///Forcesprocessestoterminate.Whenthisflagisset,thesystemdoesnotsendtheWM_QUERYENDSESSIONandWM_ENDSESSIONmessages.Thiscancausetheapplicationstolosedata.Therefore,youshouldonlyusethisflaginanemergency.
PrivateConstEWX_FORCEAsInteger=4
'///
'///TheLoadLibraryfunctionmapsthespecifiedexecutablemoduleintotheaddressspaceofthecallingprocess.
'///
'///Pointertoanull-terminatedstringthatnamestheexecutablemodule(eithera.dllor.exefile).Thenamespecifiedisthefilenameofthemoduleandisnotrelatedtothenamestoredinthelibrarymoduleitself,asspecifiedbytheLIBRARYkeywordinthemodule-definition(.def)file.
'///Ifthefunctionsucceeds,thereturnvalueisahandletothemodule.
Ifthefunctionfails,thereturnvalueisNULL.Togetextendederrorinformation,callMarshal.GetLastWin32Error.
PrivateDeclareAnsiFunctionLoadLibraryLib"kernel32"Alias"LoadLibraryA"(ByVallpLibFileNameAsString)AsIntPtr
'///
'///TheFreeLibraryfunctiondecrementsthereferencecountoftheloadeddynamic-linklibrary(DLL).Whenthereferencecountreacheszero,themoduleisunmappedfromtheaddressspaceofthecallingprocessandthehandleisnolongervalid.
'///
'///HandletotheloadedDLLmodule.TheLoadLibraryorGetModuleHandlefunctionreturnsthishandle.
'///Ifthefunctionsucceeds,thereturnvalueisnonzero.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,callMarshal.GetLastWin32Error.
PrivateDeclareAnsiFunctionFreeLibraryLib"kernel32"(ByValhLibModuleAsIntPtr)AsInteger
'///
'///TheGetProcAddressfunctionretrievestheaddressofanexportedfunctionorvariablefromthespecifieddynamic-linklibrary(DLL).
'///
'///HandletotheDLLmodulethatcontainsthefunctionorvariable.TheLoadLibraryorGetModuleHandlefunctionreturnsthishandle.
'///Pointertoanull-terminatedstringcontainingthefunctionorvariablename,orthefunction'sordinalvalue.Ifthisparameterisanordinalvalue,itmustbeinthelow-orderword;thehigh-orderwordmustbezero.
'///Ifthefunctionsucceeds,thereturnvalueistheaddressoftheexportedfunctionorvariable.
Ifthefunctionfails,thereturnvalueisNULL.Togetextendederrorinformation,callMarshal.GetLastWin32Error.
PrivateDeclareAnsiFunctionGetProcAddressLib"kernel32"(ByValhModuleAsIntPtr,ByVallpProcNameAsString)AsIntPtr
'///
'///TheSetSuspendStatefunctionsuspendsthesystembyshuttingpowerdown.DependingontheHibernateparameter,thesystemeitherentersasuspend(sleep)stateorhibernation(S4).IftheForceFlagparameterisTRUE,thesystemsuspendsoperationimmediately;ifitisFALSE,thesystemrequestspermissionfromallapplicationsanddevicedriversbeforedoingso.
'///
'///Specifiesthestateofthesystem.IfTRUE,thesystemhibernates.IfFALSE,thesystemissuspended.
'///Forcedsuspension.IfTRUE,thefunctionbroadcastsaPBT_APMSUSPENDeventtoeachapplicationanddriver,thenimmediatelysuspendsoperation.IfFALSE,thefunctionbroadcastsaPBT_APMQUERYSUSPENDeventtoeachapplicationtorequestpermissiontosuspendoperation.
'///IfTRUE,thesystemdisablesallwakeevents.IfFALSE,anysystemwakeeventsremainenabled.
'///Ifthefunctionsucceeds,thereturnvalueisnonzero.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,callMarshal.GetLastWin32Error.
PrivateDeclareAnsiFunctionSetSuspendStateLib"powrprof"(ByValHibernateAsInteger,ByValForceCriticalAsInteger,ByValDisableWakeEventAsInteger)AsInteger
'///
'///TheOpenProcessTokenfunctionopenstheaccesstokenassociatedwithaprocess.
'///
'///Handletotheprocesswhoseaccesstokenisopened.
'///Specifiesanaccessmaskthatspecifiestherequestedtypesofaccesstotheaccesstoken.Theserequestedaccesstypesarecomparedwiththetoken'sdiscretionaryaccess-controllist(DACL)todeterminewhichaccessesaregrantedordenied.
'///Pointertoahandleidentifyingthenewly-openedaccesstokenwhenthefunctionreturns.
'///Ifthefunctionsucceeds,thereturnvalueisnonzero.
Ifthefunctionfails,thereturnvalueiszero.Togetextendederrorinformation,callMarshal.GetLastWin32Error.
PrivateDeclareAnsiFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsIntPtr,ByValDesiredAccessAsInteger,ByRefTokenHandleAsIntPtr)AsInteger
'///
'///TheLookupPrivilegeValuefunctionretrievesthelocallyuniqueidentifier(LUID)usedonaspecifiedsystemtolocallyrepresentthespecifiedprivilegename.
'///
'///Pointertoanull-terminatedstringspecifyingthenameofthesystemonwhichtheprivilegenameislookedup.Ifanullstringisspecified,thefunctionattemptstofindtheprivilegenameonthelocalsystem.
'///Pointertoanull-terminatedstringthatspecifiesthenameoftheprivilege,asdefinedintheWinnt.hheaderfile.Forexample,thisparametercouldspecifytheconstantSE_SECURITY_NAME,oritscorrespondingstring,"SeSecurityPrivilege".
'///Pointertoavariablethatreceivesthelocallyuniqueidentifierbywhichtheprivilegeisknownonthesystem,sp