728x90
반응형
728x170
■ AdjustTokenPrivileges API 함수를 선언하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System;
using System.Runtime.InteropServices;
#region 토큰 특권 조정하기 - AdjustTokenPrivileges(tokenHandle, disableAllPrivileges, newState, bufferLength, previousState, returnLength)
/// <summary>
/// 토큰 특권 조정하기
/// </summary>
/// <param name="tokenHandle">토큰 핸들</param>
/// <param name="disableAllPrivileges">모든 특권 비활성화 여부</param>
/// <param name="newState">새로운 상태</param>
/// <param name="bufferLength">버퍼 길이</param>
/// <param name="previousState">이전 상태</param>
/// <param name="returnLength">반환 길이</param>
/// <returns>처리 결과</returns>
[DllImport("advapi32", ExactSpelling = true, SetLastError = true)]
private static extern bool AdjustTokenPrivileges
(
IntPtr tokenHandle,
bool disableAllPrivileges,
ref TOKEN_PRIVILEGES newState,
int bufferLength,
IntPtr previousState,
IntPtr returnLength
);
#endregion
#region 토큰 특권 - TOKEN_PRIVILEGES
/// <summary>
/// 토큰 특권
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TOKEN_PRIVILEGES
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 특권 카운트
/// </summary>
public int PrivilegeCount;
/// <summary>
/// LUID
/// </summary>
public long LUID;
/// <summary>
/// 속성
/// </summary>
public int Attributes;
#endregion
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WIN32' 카테고리의 다른 글
[C#/WIN32] BlockInput API 함수 선언하기 (0) | 2021.02.02 |
---|---|
[C#/WIN32] ShowWindow API 함수 선언하기 (0) | 2021.02.01 |
[C#/WIN32] FindWindow API 함수 선언하기 (0) | 2021.02.01 |
[C#/WIN32] SetCursorPos API 함수 선언하기 (0) | 2021.01.27 |
[C#/WIN32] ExitWindowsEx API 함수 선언하기 (0) | 2021.01.26 |
[C#/WIN32] LookupPrivilegeValue API 함수 선언하기 (0) | 2021.01.26 |
[C#/WIN32] OpenProcessToken API 함수 선언하기 (0) | 2021.01.26 |
[C#/WIN32] GetCurrentProcess API 함수 선언하기 (0) | 2021.01.26 |
[C#/WIN32] ExitWindowsEx API 함수 선언하기 (0) | 2021.01.26 |
[C#/WIN32] LockWorkStation API 함수 선언하기 (0) | 2021.01.26 |
댓글을 달아 주세요