------此人由于过于英俊,头像正面被系统永远封印----
真是海底捞月啊。。。 先说书吧:我赌你看了这本你就觉得其他的都是LJ了!《C#与.NET技术平台实战演练》,中国青年出版社的,太棒了,里面说了很多特殊的语法知识(其他书里几乎看不到)! OK,希望接下来的朋友说说自己用C#的一些技巧吧~ 我先来: 让Form拥有XP的样子方法一: 在Main()中加入语句; 即在Application.Run(); 前面加上 Application.EnableVisualStyles();
方法二: 在应用程序可执行文件目录中创建*.exe.manifest 文件 文件内容如下: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="myProcess.From1" type="win32" /> <description>MyProcess</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
程序暂停:Thread.CurrentThread.Join(100);//0.1秒钟暂停 改变分辨率
using System; using System.Runtime.InteropServices;
public class ScreenSet { public enum DMDO { DEFAULT = 0, D90 = 1, D180 = 2, D270 = 3 }
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] struct DEVMODE { public const int DM_DISPLAYFREQUENCY = 0x400000; public const int DM_PELSWIDTH = 0x80000; public const int DM_PELSHEIGHT = 0x100000; private const int CCHDEVICENAME = 32; private const int CCHFORMNAME = 32;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHDEVICENAME)] public string dmDeviceName; public short dmSpecVersion; public short dmDriverVersion; public short dmSize; public short dmDriverExtra; public int dmFields;
public int dmPositionX; public int dmPositionY; public DMDO dmDisplayOrientation; public int dmDisplayFixedOutput;
public short dmColor; public short dmDuplex; public short dmYResolution; public short dmTTOption; public short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHFORMNAME)] public string dmFormName; public short dmLogPixels; public int dmBitsPerPel; public int dmPelsWidth; public int dmPelsHeight; public int dmDisplayFlags; public int dmDisplayFrequency; public int dmICMMethod; public int dmICMIntent; public int dmMediaType; public int dmDitherType; public int dmReserved1; public int dmReserved2; public int dmPanningWidth; public int dmPanningHeight; }
[DllImport("user32.dll", CharSet=CharSet.Auto)] //static extern int ChangeDisplaySettings( DEVMODE lpDevMode, int dwFlags);
static extern int ChangeDisplaySettings( [In] ref DEVMODE lpDevMode, int dwFlags); private System.ComponentModel.Container components = null; public static void ChangeRes(int x,int y) { long RetVal=0; DEVMODE dm = new DEVMODE(); dm.dmSize= (short)Marshal.SizeOf(typeof(DEVMODE)); dm.dmPelsWidth = x; dm.dmPelsHeight= y; dm.dmDisplayFrequency=85; dm.dmFields = DEVMODE.DM_PELSWIDTH | DEVMODE.DM_PELSHEIGHT | DEVMODE.DM_DISPLAYFREQUENCY; RetVal = ChangeDisplaySettings(ref dm, 0); } }