API 1.获取机器唯一标识 class DeviceUniqueID { /* HRESULT GetDeviceUniqueID( LPBYTE pbApplicationData, DWORD cbApplictionData, DWORD dwDeviceIDVersion, LPBYTE pbDeviceIDOutput, DWORD* pcbDeviceIDOutput ); */ [DllImport("coredll.dll")] private extern static int GetDeviceUniqueID([In, Out] byte[] appdata, int cbApplictionData, int dwDeviceIDVersion, [In, Out] byte[] deviceIDOuput, out uint pcbDeviceIDOutput); public static byte[] GetDeviceID(string AppString) { // Call the GetDeviceUniqueID byte[] AppData = new byte[AppString.Length]; for (int count = 0; count < AppString.Length; count++) AppData[count] = (byte)AppString[count]; int appDataSize = AppData.Length; byte[] DeviceOutput = new byte[20]; uint SizeOut = 20; GetDeviceUniqueID(AppData, appDataSize, 1, DeviceOutput, out SizeOut); return DeviceOutput; } public static string GetDeviceIDString() { byte[] buffer = GetDeviceID("MyAppString"); StringBuilder sb = new StringBuilder(); for (int x = 0; x < buffer.Length; x++) { sb.Append(string.Format("{0:x2}", buffer[x])); } //唯一号 //MessageBox.Show(sb.Tostring()); return sb.ToString(); } } 2.隐藏窗口右上角ok按钮 class FormHelper { public static void HideDoneButton(IntPtr hWnd,UInt32 SHDB) { SHDoneButton(hWnd, SHDB); } public const UInt32 SHDB_SHOW = 0x0001; public const UInt32 SHDB_HIDE = 0x0002; [DllImport("aygshell.dll")] private static extern bool SHDoneButton(IntPtr hWnd, UInt32 dwState); } 3.