gpt4 book ai didi

C# 不识别安全 token 句柄

转载 作者:可可西里 更新时间:2023-11-01 13:52:09 30 4
gpt4 key购买 nike

C#编译出错

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Security.Principal;
using System.Security.Permissions;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

[DllImport("advapi32.dll", SetLastError = true,CharSet = CharSet.Unicode)]
public static extern bool ***LogonUser***(string lpszUsername, string lpszDomain, string lpszPassword,
int dwLogonType, int dwLogonProvider, out ***SafeTokenHandle*** phToken);

In the word at the * sign (LogonUser and SafeTokenHandle).由于类型未知,我的 C# 编译器无法编译。我使用 visual studio 2012、windows 64、framework 4.0 进行开发。

请帮助。

最佳答案

SafeTokenHandle is not part of the .Net framework.我假设您的代码与 this article 有点相关, 所以你错过了定义:

public sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeTokenHandle()
: base(true)
{
}

[DllImport("kernel32.dll")]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(IntPtr handle);

protected override bool ReleaseHandle()
{
return CloseHandle(handle);
}
}

关于C# 不识别安全 token 句柄,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17642016/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com