⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winapi.cs

📁 车载GPS?今天这个就是最好的工具
💻 CS
字号:
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace GEROSYS
{
	/// <summary>
	/// WinApi 的摘要说明。
	/// </summary>
	public class WinApi
	{
		public WinApi()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		[StructLayout(LayoutKind.Sequential)]
			public struct OSVersionInfo
		{
			public int OSVersionInfoSize;
			public int majorVersion;
			public int minorVersion;
			public int buildNumber;
			public int platformId;
			[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
			public string versionstring;
		}

		[StructLayout(LayoutKind.Sequential)]
			public struct SECURITY_ATTRIBUTES
		{
			public int nLength;
			public int lpSecurityDescriptor;
			public int bInheritHandle;
		}

		public const int GWL_EXSTYLE = (-20);
		public const int GW_OWNER = 4;
		public const int SW_RESTORE = 9;
		public const int SW_SHOW = 5;
		public const int WS_EX_TOOLWINDOW = 0x80;
		public const int WS_EX_APPWINDOW = 0x40000;

		[DllImport("kernel32.dll", EntryPoint="CreateDirectoryA")]
		public static extern bool CreateDirectory(string lpPathName, SECURITY_ATTRIBUTES lpSecurityAttribut);

		public delegate bool EnumWindowsCallback(int hWnd, int lParam) ;

		[DllImport("user32.dll", EntryPoint="EnumWindows")]
		public static extern int EnumWindows(EnumWindowsCallback callback, int lParam);
    
		[DllImport("user32.dll", EntryPoint="EnumWindows", SetLastError=true,
			 CharSet=CharSet.Ansi, ExactSpelling=true,
			 CallingConvention=CallingConvention.StdCall)]
		public static extern int EnumWindowsDllImport(EnumWindowsCallback callback, int lParam);

		[DllImport( "user32.dll", EntryPoint="FindWindow", CharSet=CharSet.Auto )]
		public static extern int FindWindow(string lpClassName, string lpWindowName);
    
		[DllImport( "user32.dll", EntryPoint="FindWindow", CharSet=CharSet.Auto )]
		public static extern int FindWindowAny(int lpClassName, int lpWindowName);

		[DllImport( "user32.dll", EntryPoint="FindWindow", CharSet=CharSet.Auto )]
		public static extern int FindWindowNullClassName(int lpClassName, string lpWindowName);

		[DllImport( "user32.dll", EntryPoint="FindWindow", CharSet=CharSet.Auto )]
		public static extern int FindWindowNullWindowCaption(string lpClassName, int lpWindowName);

		[DllImport( "user32.dll", EntryPoint="GetClassNameA" )]
		public static extern int GetClassName(int hwnd, StringBuilder lpClassName, int cch);
    
		[DllImport( "kernel32.dll", EntryPoint="GetDiskFreeSpaceA" )]
		public static extern int GetDiskFreeSpace(string lpRootPathName,
			ref int lpSectorsPerCluster,
			ref int lpBytesPerSector,
			ref int lpNumberOfFreeClusters,
			ref int lpTotalNumberOfClusters);

		[DllImport( "kernel32.dll", EntryPoint="GetDiskFreeSpaceExA" )]
		[CLSCompliant(false)]
		public static extern int GetDiskFreeSpaceEx(string lpRootPathName,
			ref int lpFreeBytesAvailableToCaller,
			ref int lpTotalNumberOfBytes,
			ref UInt32 lpTotalNumberOfFreeBytes);

		[DllImport( "kernel32.dll", EntryPoint="GetDriveTypeA" )]
		public static extern int GetDriveType(string nDrive);

		[DllImport( "user32.dll", EntryPoint="GetParent" )]
		public static extern int GetParent(int hwnd);
    
		[DllImport( "Kernel32.dll", EntryPoint="GetVersionExA", CharSet=CharSet.Ansi )]
		public static extern bool GetVersionEx(ref OSVersionInfo osvi);
    
		[DllImport( "user32.dll", EntryPoint="GetWindow" )]
		public static extern int GetWindow(int hwnd, int wCmd);
    
		[DllImport( "user32.dll", EntryPoint="GetWindowLongA" )]
		public static extern int GetWindowLong(int hwnd, int nIndex);
    
		[DllImport( "user32.dll", EntryPoint="GetWindowTextA" )]
		public static extern void GetWindowText(int hWnd, StringBuilder lpstring, int nMaxCount);
    
		[DllImport( "user32.dll", EntryPoint="IsIconic" )]
		public static extern bool IsIconic(int hwnd);
    
		[DllImport( "Powrprof.dll", EntryPoint="IsPwrHibernateAllowed" )]
		public static extern int IsPwrHibernateAllowed();
    
		[DllImport( "user32.dll", EntryPoint="IsWindowVisible" )]
		public static extern bool IsWindowVisible(int hwnd);
    
		[DllImport( "user32.dll", EntryPoint="SetForegroundWindow" )]
		public static extern int SetForegroundWindow(int hwnd);
    
		[DllImport( "Powrprof.dll", EntryPoint="SetSuspendState" )]
		public static extern int SetSuspendState(int Hibernate, int ForceCritical, int DisableWakeEvent);
 
   

		[DllImport( "TecoPhone.dll", EntryPoint="tecoPhone_dial" )]
		public static extern int tecoPhone_dial(string phoneNumber);
    
		[DllImport( "tecoSMS.dll", EntryPoint="tecoSMS_send" )]
		public static extern int tecoSMS_send(int iComIndex,string phoneNumber,string message);

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -