Desktop Functions: Smart Device Functions:
|
Search Results for "32" in [All]kernel321: 1 2: 777 3: 8
[DllImport("kernel32.dll", SetLastError=true)]
Declare Function 8 Lib "kernel32.dll" (TODO) As TODO
[DllImport("Kernel32.dll", SetLastError=true)]
Private Declare Function ActivateActCtx Lib "Kernel32" (ByVal hActCtx As IntPtr, _ 5: ActiveActCtx
[DllImport("Kernel32.dll", SetLastError=true)]
Declare Function ActiveActCtx Lib "Kernel32.dll" (TODO) As TODO 6: AddAtom
[DllImport("kernel32.dll")]
[DllImport("kernel32", SetLastError = true)]
Declare Function AddConsole Lib "kernel32" (ByVal Source As String, ByVal Target As String, ByVal ExeName As String) As Boolean
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
[DllImport("kernel32.dll")] 10: AllocConsole
[DllImport("kernel32.dll")]
MsgBox(String.Format("Failed to attach console with error: {0}", Marshal.GetLastWin32Error())) 11: APIGetVersionEx
[DllImport("kernel32", SetLastError = true)]
Private Declare Function GetVersionEx Lib "kernel32.dll" _ 12: AreFileApisANSI
[DllImport("kernel32.dll", ExactSpelling=true)]
[DllImport("kernel32.dll")]
<DllImport("kernel32.dll", SetLastError:=True)> _ 14: AttachConsole,
[DllImport("kernel32.dll", SetLastError = true)]
Declare Function AttachConsole, Lib "kernel32.dll" (dwProcessId as uint) As bool
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32",SetLastError=true)]
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32", SetLastError = true)]
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32.dll", SetLastError=true)]
if (!AttachConsole(ATTACH_PARENT_PROCESS) && Marshal.GetLastWin32Error() == ERROR_ACCESS_DENIED) 15: AttachConsole
[DllImport("kernel32.dll", SetLastError = true)]
Declare Function AttachConsole, Lib "kernel32.dll" (dwProcessId as uint) As bool
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32",SetLastError=true)]
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32", SetLastError = true)]
/// To get extended error information, call Marshal.GetLastWin32Error.</returns>
[DllImport("kernel32.dll", SetLastError=true)]
if (!AttachConsole(ATTACH_PARENT_PROCESS) && Marshal.GetLastWin32Error() == ERROR_ACCESS_DENIED) 16: BackupRead
[DllImport("kernel32.dll")]
<DllImport("kernel32.dll")> _ 17: BackupWrite
[DllImport("kernel32.dll")] 18: Beep
[DllImport("kernel32.dll", SetLastError=true)]
<DllImport("kernel32.dll", SetLastError := False)> _ calls SetLastError. the last error can be retrieved with Marshal.GetLastWin32Error().
if (hResource.ToInt32() == 0) {
throw new Win32Exception(Marshal.GetLastWin32Error());
throw new Win32Exception(Marshal.GetLastWin32Error());
throw new Win32Exception(Marshal.GetLastWin32Error()); 20: BuildCommDCB
[DllImport("kernel32.dll")] 21: CancelIo
[DllImport("kernel32.dll")]
[DllImport("Kernel32.dll", SetLastError = true, ExactSpelling = true)]
Declare Function CheckRemoteDebuggerPresent Lib "kernel32.dll"
Declare Function CheckRemoteDebuggerPresent Lib "kernel32.dll" _ 23: ClearCommBreak
[DllImport("kernel32.dll")]
Declare Auto Function ClearCommBreak Lib "kernel32.dll" (hFile As IntPtr) As Boolean 24: ClearCommError
[DllImport("kernel32.dll")] 25: CloseHandle
[DllImport("kernel32.dll", SetLastError=true)]
<DllImport("kernel32.dll", SetLastError:=True)> _
Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal hObject As IntPtr) As Boolean
Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Integer) As Integer
[DllImport("kernel32", SetLastError : true)] For .NET 2.0, consider using Microsoft.Win32.SafeHandles.SafeFileHandle instead. It can be used where IntPtr is used. If you use a SafeFileHandle, do not call CloseHandle as the CLR will close it for you (even if it's already closed). [DllImport("kernel32", SetLastError=true)] 26: CommConfigDialog
[DllImport("kernel32.dll")] 27: CompareString
[DllImport("kernel32.dll",CharSet=CharSet.Unicode, SetLastError=true)]
Public Enum EComparationFlags As UInt32
Public Enum EComparationResult As Int32
Public Declare Unicode Function CompareStringEx Lib "kernel32" (ByVal strLocaleName As String, ByVal dwComparationFlags As EComparationFlags, ByVal str1 As String, ByVal iLength1 As Int32, ByVal str2 As String, ByVal iLength2 As Int32, ByVal pVersionInformation As IntPtr, ByVal pReserved As IntPtr, ByVal lParam As IntPtr) As EComparationResult 28: CompareStringEx [DllImport("kernel32.dll",CharSet=CharSet.Unicode)]
[DllImport("kernel32.dll", SetLastError=true)]
Declare Function CompareStringEx Lib "kernel32.dll" (TODO) As TODO 29: ConnectNamedPipe
[DllImport("kernel32.dll")] 30: ConsoleFunctions
// http://pinvoke.net/default.aspx/kernel32/AddConsoleAlias.html
[DllImport("kernel32", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/AllocConsole.html
[DllImport("kernel32", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/AttachConsole.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/CreateConsoleScreenBuffer.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/FillConsoleOutputAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/FillConsoleOutputCharacter.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/FlushConsoleInputBuffer.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/FreeConsole.html
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
// http://pinvoke.net/default.aspx/kernel32/GenerateConsoleCtrlEvent.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleAlias.html
[DllImport("kernel32", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleAliases.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleAliasesLength.html
[DllImport("kernel32", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleAliasExes.html
[DllImport("kernel32", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleAliasExesLength.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleCP.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleCursorInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleDisplayMode.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleFontSize.html
[DllImport("kernel32.dll", SetLastError = true)]
Int32 nFont
// http://pinvoke.net/default.aspx/kernel32/GetConsoleHistoryInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleMode.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleOriginalTitle.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleOutputCP.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleProcessList.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleScreenBufferInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleScreenBufferInfoEx.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleSelectionInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleTitle.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetConsoleWindow.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetCurrentConsoleFont.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetCurrentConsoleFontEx.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetLargestConsoleWindowSize.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetNumberOfConsoleInputEvents.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetNumberOfConsoleMouseButtons.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/GetStdHandle.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/HandlerRoutine.html
// http://pinvoke.net/default.aspx/kernel32/PeekConsoleInput.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/ReadConsole.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleInput.html
[DllImport("kernel32.dll", EntryPoint = "ReadConsoleInputW", CharSet = CharSet.Unicode)]
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutput.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutputAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutputCharacter.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/ScrollConsoleScreenBuffer.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleActiveScreenBuffer.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCP.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCtrlHandler.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCursorInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCursorPosition.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleDisplayMode.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleHistoryInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleMode.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleOutputCP.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleScreenBufferInfoEx.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleScreenBufferSize.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleTextAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleTitle.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetConsoleWindowInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetCurrentConsoleFontEx.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/SetStdHandle.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/WriteConsole.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleInput.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutput.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutputAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutputCharacter.html
[DllImport("kernel32.dll", SetLastError = true)]
const uint LF_FACESIZE = 32;
[DllImport("kernel32.dll")] To compile an application that uses this function, define WIN32WINNT as 0x0400 or later. 32: COORD 33: CopyFile
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 pbCancel,
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, _
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 pbCancel,
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, _ 34: CopyFileEx
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 pbCancel,
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, _
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 pbCancel,
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, _ 35: CreateActCtxW
[DllImport("Kernel32.dll", SetLastError=true)]
[DllImport("Kernel32.dll", SetLastError=true)]
Declare Function CreateActCtxW Lib "Kernel32.dll" (TODO) As TODO
[DllImport("Kernel32.dll")]
UInt32 dwDesiredAccess,
UInt32 dwShareMode,
UInt32 flags,
[DllImport("Kernel32.dll")]
UInt32 dwDesiredAccess,
UInt32 dwShareMode,
UInt32 flags,
Int32 err = Marshal.GetLastWin32Error();
throw new System.ComponentModel.Win32Exception(err); 37: CreateDirectory
[DllImport("kernel32.dll")] 39: CreateEvent
<DllImport("kernel32.dll", _
[DllImport("kernel32.dll")] The following class object provides some interprocess event signaling style synchronization within the .NET environment. Specifically, using named events, processes can signal each other out of an effecient wait. This reach goes beyond .NET can allow .NET and Win32 processes to signal each other. There are some security issues, in that the default security context of the process is used.
/// processes in both .NET and Win32 with the same event signaling capability.
/// Win32 security is a critical issue. This class does not support specifically
////////// Interop information for managing a Win32 event ////////////
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", SetLastError=true)]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32 milliseconds); 40: CreateFiber
[DllImport("kernel32.dll")] 41: CreateFile
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
<DllImport("kernel32.dll", SetLastError:= true, CharSet:= CharSet.Auto)> _
_hMMF = Win32API.OpenFileMapping(Win32API.FileMapAccess.FileMapAllAccess, false, Name);
_hMMF = Win32API.CreateFileMapping(_fs, Win32API.FileMapProtection.PageReadWrite, Int64.MaxValue, Name);
throw new Win32Exception();
Win32API.SYSTEM_INFO sysinfo = new Win32API.SYSTEM_INFO();
Win32API.GetSystemInfo(ref sysinfo);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.UnmapViewOfFile(hMVF);
Win32API.CloseHandle(_hMMF);
internal sealed class Win32API
[DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);
int Hi = (Int32)(ddMaxSize / Int32.MaxValue);
int Lo = (Int32)(ddMaxSize % Int32.MaxValue);
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr MapViewOfFile(IntPtr hFileMapping, FileMapAccess dwDesiredAccess, Int32 dwFileOffsetHigh, Int32 dwFileOffsetLow, Int32 dwNumberOfBytesToMap);
internal static IntPtr MapViewOfFile(IntPtr hFileMapping, FileMapAccess dwDesiredAccess, Int64 ddFileOffset, Int32 dwNumberOfBytesToMap)
int Hi = (Int32)(ddFileOffset / Int32.MaxValue);
int Lo = (Int32)(ddFileOffset % Int32.MaxValue);
[DllImport("kernel32.dll")]
Int32 dwNumberOfBytesToFlush);
[DllImport("kernel32")]
[DllImport("kernel32", SetLastError = true)]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
<DllImport("kernel32.dll", SetLastError:= true, CharSet:= CharSet.Auto)> _
_hMMF = Win32API.OpenFileMapping(Win32API.FileMapAccess.FileMapAllAccess, false, Name);
_hMMF = Win32API.CreateFileMapping(_fs, Win32API.FileMapProtection.PageReadWrite, Int64.MaxValue, Name);
throw new Win32Exception();
Win32API.SYSTEM_INFO sysinfo = new Win32API.SYSTEM_INFO();
Win32API.GetSystemInfo(ref sysinfo);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Win32API.UnmapViewOfFile(hMVF);
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
throw new Win32Exception();
Win32API.UnmapViewOfFile(hMVF);
Win32API.CloseHandle(_hMMF);
internal sealed class Win32API
[DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);
int Hi = (Int32)(ddMaxSize / Int32.MaxValue);
int Lo = (Int32)(ddMaxSize % Int32.MaxValue);
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr MapViewOfFile(IntPtr hFileMapping, FileMapAccess dwDesiredAccess, Int32 dwFileOffsetHigh, Int32 dwFileOffsetLow, Int32 dwNumberOfBytesToMap);
internal static IntPtr MapViewOfFile(IntPtr hFileMapping, FileMapAccess dwDesiredAccess, Int64 ddFileOffset, Int32 dwNumberOfBytesToMap)
int Hi = (Int32)(ddFileOffset / Int32.MaxValue);
int Lo = (Int32)(ddFileOffset % Int32.MaxValue);
[DllImport("kernel32.dll")]
Int32 dwNumberOfBytesToFlush);
[DllImport("kernel32")]
[DllImport("kernel32", SetLastError = true)]
[DllImport("kernel32.dll")] 43: CreateHardLink
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
[DllImport('kernel32.dll', SetLastError:=true, CharSet:=CharSet.Auto)]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[DllImport("kernel32.dll", SetLastError = true)] 45: CreateJobObject
[DllImport("kernel32.dll", CharSet=CharSet.Unicode)]
<DllImport("kernel32.dll", CharSet := CharSet.Unicode)> _ 46: CreateMailslot
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
Declare Function CreateMailslot Lib "kernel32.dll" _
ByVal nMaxMessageSize As UInt32, _
ByVal lReadTimeoutAs As UInt32, _
[DllImport("kernel32.dll", SetLastError = true)] 48: CreateMutex
[DllImport("kernel32.dll")]
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, setlasterror:=True)> _
//// Win32Calls.cs ////////////////////////////
namespace nsWin32Calls
/// Win32 calls encapsulation object.
public class Win32Calls
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll")]
using nsWin32Calls; // encapsulates Win32 calls
ipHMutex = Win32Calls.CreateMutex( ipMutexAttr,
int iGLE = Marshal.GetLastWin32Error();
if (iGLE == Win32Calls.ERROR_ALREADY_EXISTS)
Win32Calls.ReleaseMutex( ipHMutex );
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("advapi32.dll", SetLastError=true)]
[DllImport("advapi32.dll", SetLastError=true)]
lastError = Marshal.GetLastWin32Error();
throw new MutexCreationException( string.Format( "Failed to initialize security descriptor. Win32 error num: '{0}'", lastError ) );
lastError = Marshal.GetLastWin32Error();
throw new MutexCreationException( string.Format( "Failed to set security descriptor DACL. Win32 error num: '{0}'", lastError ) );
lastError = Marshal.GetLastWin32Error();
lastError = Marshal.GetLastWin32Error();
throw new MutexCreationException( string.Format( "Unable to create or open mutex. Win32 error num: '{0}'", lastError ) ); 49: CreateNamedPipe
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", EntryPoint = "CreateFile", SetLastError = true)]
UInt32 dwDesiredAccess, UInt32 dwShareMode,
IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition,
UInt32 dwFlagsAndAttributes,
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", EntryPoint = "PeekNamedPipe", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true)]
/*[DllImport("kernel32.dll", SetLastError = true)]
private const UInt32 GENERIC_READ = 0x80000000;
private const UInt32 GENERIC_WRITE = 0x40000000;
private const Int32 INVALID_HANDLE_VALUE = -1;
private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;
private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;
private const UInt32 OPEN_EXISTING = 3;
if (handle.ToInt32() == INVALID_HANDLE_VALUE)
int err = Marshal.GetLastWin32Error();
throw new Win32Exception(err,
string.Format("NamedPipeStream.Open failed, win32 error code {0}, pipename '{1}' ",err,pipename));
if (handle.ToInt32() == INVALID_HANDLE_VALUE)
throw new Win32Exception("Error creating named pipe " + name + " . Internal error: " + Marshal.GetLastWin32Error().ToString());
uint lastErr = (uint)Marshal.GetLastWin32Error();
if ((uint)Marshal.GetLastWin32Error() == ERROR_PIPE_CONNECTED)
throw new Win32Exception(Marshal.GetLastWin32Error(), "ReadFile failed");
int err = (int)Marshal.GetLastWin32Error();
throw new Win32Exception(err,"Writing to the stream failed"); 50: CreatePipe
[DllImport("kernel32.dll")]
Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long 51: CreateProcess
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
<DllImport("kernel32.dll")> _
dwCreationFlags As UInt32, _
Const NORMAL_PRIORITY_CLASS AS UInt32 = &h2
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32")] 54: CreateThread
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[DllImport("kernel32.dll")] 55: CreateTimerQueue
[DllImport("kernel32.dll")]
<DllImport("kernel32.dll")> _
[DllImport("kernel32.dll")] public class CreateToolhelp32SnapshotFlags
public const uint TH32CS_SNAPHEAPLIST = 0x00000001;
public const uint TH32CS_SNAPPROCESS = 0x00000002;
public const uint TH32CS_SNAPTHREAD = 0x00000004;
public const uint TH32CS_SNAPMODULE = 0x00000008;
public const uint TH32CS_SNAPMODULE32 = 0x00000010;
public const uint TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE);
public const uint TH32CS_INHERIT = 0x80000000; Use as the first argument to CreateToolhelp32Snapshot()
[DllImport("kernel32.dll", SetLastError=true)]
static extern IntPtr CreateToolhelp32Snapshot(SnapshotFlags dwFlags, uint th32ProcessID);
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Shared Function CreateToolhelp32Snapshot(ByVal dwFlags As SnapshotFlags, ByVal th32ProcessID As UInteger) As IntPtr You may find that you when calling CreateToolhelp32Snapshot that you must specify SnapshotFlag.NoHeaps in addition to any other flags or you will get an invalid handle and an "Out of Memory" error (ERROR_NOT_ENOUGH_MEMORY = 0x8). This is a seemingly undocumented flag. See the bottom of the MSDN page http://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx
Module32 = 0x00000010,
private struct PROCESSENTRY32
internal UInt32 dwSize;
internal UInt32 cntUsage;
internal UInt32 th32ProcessID;
internal IntPtr th32DefaultHeapID;
internal UInt32 th32ModuleID;
internal UInt32 cntThreads;
internal UInt32 th32ParentProcessID;
internal Int32 pcPriClassBase;
internal UInt32 dwFlags;
[DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern IntPtr CreateToolhelp32Snapshot([In]UInt32 dwFlags, [In]UInt32 th32ProcessID);
[DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern bool Process32First([In]IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern bool Process32Next([In]IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[DllImport("kernel32", SetLastError = true)]
PROCESSENTRY32 procEntry = new PROCESSENTRY32();
procEntry.dwSize = (UInt32)Marshal.SizeOf(typeof(PROCESSENTRY32));
handleToSnapshot = CreateToolhelp32Snapshot((uint)SnapshotFlags.Process, 0);
if (Process32First(handleToSnapshot, ref procEntry))
if (pid == procEntry.th32ProcessID)
parentProc = Process.GetProcessById((int)procEntry.th32ParentProcessID);
} while (Process32Next(handleToSnapshot, ref procEntry));
throw new ApplicationException(string.Format("Failed with win32 error code {0}", Marshal.GetLastWin32Error())); PROCESSENTRY32, Process32First, Process32Next
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
public static extern Int32 WaitForSingleObject(IntPtr handle, int milliseconds);
handle = Win32.PowerManagement.CreateWaitableTimer(IntPtr.Zero, true, "");
Win32.PowerManagement.SetWaitableTimer(handle, ref duetime, 0, null, IntPtr.Zero, true);
int ret = Win32.PowerManagement.WaitForSingleObject(handle, (int)Win32.PowerManagement.INFINITE); 60: csepeli lászló Cut off search results after 60. Please refine your search. |