【摘自网上】C#.net底层Windows API类-API函数2

转载 2011年01月17日 16:07:00

C#.net底层Windows API类-API函数2

 

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("advapi32.dll", SetLastError=true)]    

internal static extern int LsaClose(IntPtr handle);

 

[DllImport("secur32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern int LsaConnectUntrusted([In, Out] ref SafeLsaLogonProcessHandle LsaHandle);

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("secur32.dll", SetLastError=true)]    

internal static extern int LsaDeregisterLogonProcess(IntPtr handle);

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("advapi32.dll", SetLastError=true)]    

internal static extern int LsaFreeMemory(IntPtr handle);

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("secur32.dll", SetLastError=true)]    

internal static extern int LsaFreeReturnBuffer(IntPtr handle);

 

[DllImport("secur32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern int LsaGetLogonSessionData([In] ref LUID LogonId, [In, Out] ref SafeLsaReturnBufferHandle ppLogonSessionData);

 

[DllImport("secur32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern int LsaLogonUser([In] SafeLsaLogonProcessHandle LsaHandle, [In] ref UNICODE_INTPTR_STRING OriginName, [In] uint LogonType, [In] uint AuthenticationPackage, [In] IntPtr AuthenticationInformation, [In] uint AuthenticationInformationLength, [In] IntPtr LocalGroups, [In] ref TOKEN_SOURCE SourceContext, [In, Out] ref SafeLsaReturnBufferHandle ProfileBuffer, [In, Out] ref uint ProfileBufferLength, [In, Out] ref LUID LogonId, [In, Out] ref SafeTokenHandle Token, [In, Out] ref QUOTA_LIMITS Quotas, [In, Out] ref int SubStatus);    

 

[DllImport("secur32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern int LsaLookupAuthenticationPackage([In] SafeLsaLogonProcessHandle LsaHandle, [In] ref UNICODE_INTPTR_STRING PackageName, [In, Out] ref uint AuthenticationPackage); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint LsaLookupNames(SafeLsaPolicyHandle handle, int count, UNICODE_STRING[] names, ref SafeLsaMemoryHandle referencedDomains, ref SafeLsaMemoryHandle sids);  

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint LsaLookupNames2(SafeLsaPolicyHandle handle, int flags, int count, UNICODE_STRING[] names, ref SafeLsaMemoryHandle referencedDomains, ref SafeLsaMemoryHandle sids); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint LsaLookupSids(SafeLsaPolicyHandle handle, int count, IntPtr[] sids, ref SafeLsaMemoryHandle referencedDomains, ref SafeLsaMemoryHandle names); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern int LsaNtStatusToWinError([In] int status);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint LsaOpenPolicy(string systemName, ref LSA_OBJECT_ATTRIBUTES attributes, int accessMask, out SafeLsaPolicyHandle handle);    

 

[DllImport("secur32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern int LsaRegisterLogonProcess([In] ref UNICODE_INTPTR_STRING LogonProcessName, [In, Out] ref SafeLsaLogonProcessHandle LsaHandle, [In, Out] ref IntPtr SecurityMode);

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]    

internal static extern IntPtr lstrcpy(IntPtr dst, string src);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]    

internal static extern IntPtr lstrcpy(StringBuilder dst, IntPtr src);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]    

internal static extern int lstrlen(sbyte[] ptr);  

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]    

internal static extern int lstrlen(IntPtr ptr);   

 

[DllImport("kernel32.dll", CharSet=CharSet.Ansi)]    

internal static extern int lstrlenA(IntPtr ptr); 

 

[DllImport("kernel32.dll", CharSet=CharSet.Unicode)]    

internal static extern int lstrlenW(IntPtr ptr);    

internal static int MakeHRFromErrorCode(int errorCode); 

 

[DllImport("kernel32.dll", SetLastError=true, ExactSpelling=true)]    

internal static extern IntPtr MapViewOfFile(SafeFileMappingHandle handle, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, UIntPtr dwNumerOfBytesToMap);  

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool MoveFile(string src, string dst);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]   

 internal static extern SafeWaitHandle OpenEvent(int desiredAccess, bool inheritHandle, string name); 

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern SafeWaitHandle OpenMutex(int desiredAccess, bool inheritHandle, string name);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern bool OpenProcessToken([In] IntPtr ProcessToken, [In] TokenAccessLevels DesiredAccess, [In, Out] ref SafeTokenHandle TokenHandle);  

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool ReadConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead);

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe bool ReadConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* pBuffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT readRegion); 

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe int ReadFile(SafeFileHandle handle, byte* bytes, int numBytesToRead, out int numBytesRead, IntPtr mustBeZero);  

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe int ReadFile(SafeFileHandle handle, byte* bytes, int numBytesToRead, IntPtr numBytesRead_mustBeZero, NativeOverlapped* overlapped); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegConnectRegistry(string machineName, SafeRegistryHandle key, out SafeRegistryHandle result); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegCreateKeyEx(SafeRegistryHandle hKey, string lpSubKey, int Reserved, string lpClass, int dwOptions, int samDesigner, SECURITY_ATTRIBUTES lpSecurityAttributes, out SafeRegistryHandle hkResult, out int lpdwDisposition);

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegDeleteKey(SafeRegistryHandle hKey, string lpSubKey);

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string lpValueName); 

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegEnumKeyEx(SafeRegistryHandle hKey, int dwIndex, StringBuilder lpName, out int lpcbName, int[] lpReserved, StringBuilder lpClass, int[] lpcbClass, long[] lpftLastWriteTime);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegEnumValue(SafeRegistryHandle hKey, int dwIndex, StringBuilder lpValueName, ref int lpcbValueName, IntPtr lpReserved_MustBeZero, int[] lpType, byte[] lpData, int[] lpcbData);    

[DllImport("advapi32.dll", CharSet=CharSet.Ansi)]    

internal static extern int RegEnumValueA(SafeRegistryHandle hKey, int dwIndex, StringBuilder lpValueName, ref int lpcbValueName, IntPtr lpReserved_MustBeZero, int[] lpType, byte[] lpData, int[] lpcbData);    

 

[DllImport("advapi32.dll")]    

internal static extern int RegFlushKey(SafeRegistryHandle hKey);

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegOpenKeyEx(SafeRegistryHandle hKey, string lpSubKey, int ulOptions, int samDesired, out SafeRegistryHandle hkResult);  

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegQueryInfoKey(SafeRegistryHandle hKey, StringBuilder lpClass, int[] lpcbClass, IntPtr lpReserved_MustBeZero, ref int lpcSubKeys, int[] lpcbMaxSubKeyLen, int[] lpcbMaxClassLen, ref int lpcValues, int[] lpcbMaxValueNameLen, int[] lpcbMaxValueLen, int[] lpcbSecurityDescriptor, int[] lpftLastWriteTime);   

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, ref int lpData, ref int lpcbData);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, ref long lpData, ref int lpcbData);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, [Out] byte[] lpData, ref int lpcbData);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]   

internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, [Out] char[] lpData, ref int lpcbData);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, StringBuilder lpData, ref int lpcbData);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, byte[] lpData, int cbData);  

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]  

internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, string lpData, int cbData);  

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, ref int lpData, int cbData); 

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]    

internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, ref long lpData, int cbData);

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool ReleaseMutex(SafeWaitHandle handle);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool RemoveDirectory(string path);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool ReplaceFile(string replacedFileName, string replacementFileName, string backupFileName, int dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool ResetEvent(SafeWaitHandle handle);    

internal static SafeFileHandle SafeCreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);    

 

[DllImport("user32.dll", SetLastError=true)]    

internal static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult);  

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleCP(uint codePage); 

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("kernel32.dll", SetLastError=true)]    internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine handler, bool addOrRemove);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleCursorInfo(IntPtr hConsoleOutput, ref CONSOLE_CURSOR_INFO cci);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleCursorPosition(IntPtr hConsoleOutput, COORD cursorPosition);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleOutputCP(uint codePage);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, COORD size);  

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, short attributes);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool SetConsoleTitle(string title);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe bool SetConsoleWindowInfo(IntPtr hConsoleOutput, bool absolute, SMALL_RECT* consoleWindow);

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool SetCurrentDirectory(string path);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetEndOfFile(SafeFileHandle hFile); 

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool SetEnvironmentVariable(string lpName, string lpValue);  

 

[DllImport("kernel32.dll")]    

internal static extern int SetErrorMode(int newMode);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool SetEvent(SafeWaitHandle handle); 

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool SetFileAttributes(string name, int attr);    

internal static long SetFilePointer(SafeFileHandle handle, long offset, SeekOrigin origin, out int hr); 

 

[DllImport("kernel32.dll", EntryPoint="SetFilePointer", SetLastError=true)]    

private static extern unsafe int SetFilePointerWin32(SafeFileHandle handle, int lo, int* hi, int origin);

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe bool SetFileTime(SafeFileHandle hFile, FILE_TIME* creationTime, FILE_TIME* lastAccessTime, FILE_TIME* lastWriteTime); 

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern void SetLastError(int errorCode);    

 

[DllImport("advapi32.dll", EntryPoint="SetSecurityInfo", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint SetSecurityInfoByHandle(SafeHandle handle, uint objectType, uint securityInformation, byte[] owner, byte[] group, byte[] dacl, byte[] sacl); 

 

[DllImport("advapi32.dll", EntryPoint="SetNamedSecurityInfoW", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern uint SetSecurityInfoByName(string name, uint objectType, uint securityInformation, byte[] owner, byte[] group, byte[] dacl, byte[] sacl);    

 

[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]    

internal static extern bool SetVolumeLabel(string driveLetter, string volumeName); 

 

[DllImport("shfolder.dll", CharSet=CharSet.Auto)]    

internal static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath); 

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), DllImport("oleaut32.dll", CharSet=CharSet.Unicode)]    

internal static extern IntPtr SysAllocStringLen(string src, int len);  

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("oleaut32.dll")]    

internal static extern void SysFreeString(IntPtr bstr);    

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("oleaut32.dll")]    

internal static extern int SysStringLen(IntPtr bstr);    

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern int SystemFunction040([In, Out] SafeBSTRHandle pDataIn, [In] uint cbDataIn, [In] uint dwFlags);    

 

[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]    

internal static extern int SystemFunction041([In, Out] SafeBSTRHandle pDataIn, [In] uint cbDataIn, [In] uint dwFlags); 

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern bool UnlockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("kernel32.dll", ExactSpelling=true)]    

internal static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);    

internal static SafeFileHandle UnsafeCreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);    

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe void* VirtualAlloc(void* address, UIntPtr numBytes, int commitOrReserve, int pageProtectionMode);    

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe bool VirtualFree(void* address, UIntPtr numBytes, int pageFreeMode);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe IntPtr VirtualQuery(void* address, ref MEMORY_BASIC_INFORMATION buffer, IntPtr sizeOfBuffer);  

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern uint WaitForMultipleObjects(uint nCount, IntPtr[] handles, bool bWaitAll, uint dwMilliseconds);   

 

[DllImport("kernel32.dll")]    

internal static extern unsafe int WideCharToMultiByte(uint cp, uint flags, char* pwzSource, int cchSource, byte* pbDestBuffer, int cbDestBuffer, IntPtr null1, IntPtr null2);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe bool WriteConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO* buffer, COORD bufferSize, COORD bufferCoord, ref SMALL_RECT writeRegion);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero);    

 

[DllImport("kernel32.dll", SetLastError=true)]    

internal static extern unsafe int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped);    

 

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("kernel32.dll", SetLastError=true)]    

internal static extern void ZeroMemory(IntPtr handle, uint length);

 

举报

相关文章推荐

一些实用的网站

一些实用的网站

Mybatis 高级结果映射 ResultMap Association Collection

转:http://blog.csdn.net/ilovejava_2010/article/details/8180521

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

Maven POM.xml标签详解

//转载自:http://blog.csdn.net/qq_25827845/article/details/74456076 <project xmlns="http://maven.apache...

Maven POM.xml 标签详解

关于maven的核心配置文件pom.xml中的标签所做的一个总结

Spring三种主要装配机制

在XML中进行显式配置在Java中显式配置隐式的bean发现机制和自动装配 Spring从两个角度来实现自动装配  1. 组件扫描():Spring会自动扫描bean  2. 自动装配():Sp...

list遍历里面的坑

list遍历里面的坑

spring常用注解

开启自动扫描功能 @Configuration把一个类作为一个IoC容器,它的某个方法头上如果注册了@Bean,就会作为这个Spring容器中的Bean。 @Scope注解 作用域 @...

VB.NET调用Windows API函数(整理中)

1、发送Windows消息: Private Declare Auto Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)