本文整理汇总了C#中Microsoft.Win32.Win32Native类的典型用法代码示例。如果您正苦于以下问题:C# Win32Native类的具体用法?C# Win32Native怎么用?C# Win32Native使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Win32Native类属于Microsoft.Win32命名空间,在下文中一共展示了Win32Native类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mutex
internal Mutex(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs)
{
if (null != name && Path.MAX_PATH < name.Length)
{
throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name));
}
Contract.EndContractBlock();
CreateMutexWithGuaranteedCleanup(initiallyOwned, name, out createdNew, secAttrs);
}
示例2: CreateMutexWithGuaranteedCleanup
internal void CreateMutexWithGuaranteedCleanup(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs)
{
RuntimeHelpers.CleanupCode cleanupCode = new RuntimeHelpers.CleanupCode(MutexCleanupCode);
MutexCleanupInfo cleanupInfo = new MutexCleanupInfo(null, false);
MutexTryCodeHelper tryCodeHelper = new MutexTryCodeHelper(initiallyOwned, cleanupInfo, name, secAttrs, this);
RuntimeHelpers.TryCode tryCode = new RuntimeHelpers.TryCode(tryCodeHelper.MutexTryCode);
RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(
tryCode,
cleanupCode,
cleanupInfo);
createdNew = tryCodeHelper.m_newMutex;
}
示例3: PopulateFrom
internal void PopulateFrom(Win32Native.WIN32_FIND_DATA findData)
{
this.fileAttributes = findData.dwFileAttributes;
this.ftCreationTimeLow = findData.ftCreationTime_dwLowDateTime;
this.ftCreationTimeHigh = findData.ftCreationTime_dwHighDateTime;
this.ftLastAccessTimeLow = findData.ftLastAccessTime_dwLowDateTime;
this.ftLastAccessTimeHigh = findData.ftLastAccessTime_dwHighDateTime;
this.ftLastWriteTimeLow = findData.ftLastWriteTime_dwLowDateTime;
this.ftLastWriteTimeHigh = findData.ftLastWriteTime_dwHighDateTime;
this.fileSizeHigh = findData.nFileSizeHigh;
this.fileSizeLow = findData.nFileSizeLow;
}
示例4: Mutex
internal Mutex(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs)
{
if (name == string.Empty)
{
// Empty name is treated as an unnamed mutex. Set to null, and we will check for null from now on.
name = null;
}
#if !PLATFORM_UNIX
if (name != null && System.IO.Path.MaxPath < name.Length)
{
throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name));
}
#endif
Contract.EndContractBlock();
CreateMutexWithGuaranteedCleanup(initiallyOwned, name, out createdNew, secAttrs);
}
示例5: GetVersionEx
internal static extern bool GetVersionEx(Win32Native.OSVERSIONINFOEX osVer);
示例6: SetConsoleCursorPosition
internal static bool SetConsoleCursorPosition(IntPtr hConsoleOutput, Win32Native.COORD cursorPosition);
示例7: _GetDateNotBefore
internal static extern void _GetDateNotBefore(SafeCertContextHandle safeCertContext, ref Win32Native.FILE_TIME fileTime);
示例8: TimeZoneInformation
public TimeZoneInformation(Win32Native.DynamicTimeZoneInformation dtzi) {
Bias = dtzi.Bias;
StandardName = dtzi.StandardName;
StandardDate = dtzi.StandardDate;
StandardBias = dtzi.StandardBias;
DaylightName = dtzi.DaylightName;
DaylightDate = dtzi.DaylightDate;
DaylightBias = dtzi.DaylightBias;
}
示例9: InitializeFrom
internal void InitializeFrom(Win32Native.WIN32_FIND_DATA findData)
{
_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
_data.PopulateFrom(findData);
_dataInitialised = 0;
}
示例10: ColorAttributeToConsoleColor
[System.Security.SecurityCritical] // auto-generated
private static ConsoleColor ColorAttributeToConsoleColor(Win32Native.Color c)
{
// Turn background colors into foreground colors.
if ((c & Win32Native.Color.BackgroundMask) != 0)
c = (Win32Native.Color) (((int)c) >> 4);
return (ConsoleColor) c;
}
示例11: CreateMutexHandle
static int CreateMutexHandle(bool initiallyOwned, String name, Win32Native.SECURITY_ATTRIBUTES securityAttribute, out SafeWaitHandle mutexHandle) {
int errorCode;
bool fAffinity = false;
while(true) {
mutexHandle = Win32Native.CreateMutex(securityAttribute, initiallyOwned, name);
errorCode = Marshal.GetLastWin32Error();
if( !mutexHandle.IsInvalid) {
break;
}
if( errorCode == Win32Native.ERROR_ACCESS_DENIED) {
// If a mutex with the name already exists, OS will try to open it with FullAccess.
// It might fail if we don't have enough access. In that case, we try to open the mutex will modify and synchronize access.
//
RuntimeHelpers.PrepareConstrainedRegions();
try
{
try
{
}
finally
{
#if !FEATURE_CORECLR
Thread.BeginThreadAffinity();
#endif
fAffinity = true;
}
mutexHandle = Win32Native.OpenMutex(Win32Native.MUTEX_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name);
if(!mutexHandle.IsInvalid)
{
errorCode = Win32Native.ERROR_ALREADY_EXISTS;
}
else
{
errorCode = Marshal.GetLastWin32Error();
}
}
finally
{
if (fAffinity) {
#if !FEATURE_CORECLR
Thread.EndThreadAffinity();
#endif
}
}
// There could be a race condition here, the other owner of the mutex can free the mutex,
// We need to retry creation in that case.
if( errorCode != Win32Native.ERROR_FILE_NOT_FOUND) {
if( errorCode == Win32Native.ERROR_SUCCESS) {
errorCode = Win32Native.ERROR_ALREADY_EXISTS;
}
break;
}
}
else {
break;
}
}
return errorCode;
}
示例12: SetConsoleScreenBufferSize
internal static bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, Win32Native.COORD size);
示例13: IsKeyDownEvent
[System.Security.SecurityCritical] // auto-generated
private static bool IsKeyDownEvent(Win32Native.InputRecord ir) {
return (ir.eventType == Win32Native.KEY_EVENT && ir.keyEvent.keyDown);
}
示例14: WriteConsoleOutput
internal static bool WriteConsoleOutput(IntPtr hConsoleOutput, Win32Native.CHAR_INFO* buffer, Win32Native.COORD bufferSize, Win32Native.COORD bufferCoord, ref Win32Native.SMALL_RECT writeRegion);
示例15: VirtualQuery
internal static UIntPtr VirtualQuery(void* address, ref Win32Native.MEMORY_BASIC_INFORMATION buffer, UIntPtr sizeOfBuffer);