1. 시스템 상태를 얻어오거나 제어하는 함수
[DllImport("user32.dll", EntryPoint="SystemParametersInfoA")]
public static extern bool SystemParametersInfo ( int uiAction, int uiParam, [MarshalAs(UnmanagedType.Bool)] ref bool pvParam, int fWinIni );
public const int SPI_GETSCREENSAVEACTIVE = 0x10; // 16
public const int SPI_SETSCREENSAVEACTIVE = 0x11; // 17
public const int SPI_GETSCREENSAVERRUNNING = 0x72; // 97
public const int SPI_SETSCREENSAVERRUNNING = 0x61; // 114
public const int SPIF_UPDATEINIFILE = 0x0001;
public const int SPIF_SENDCHANGE = 0x0002;
2. 화면상태(해상도, 창 위치)를 제어하는 함수
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE
{
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)] public string dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
public short dmSize;
public short dmDriverExtra;
public int dmFields;
public short dmOrientation;
public short dmPaperSize;
public short dmPaperLength;
public short dmPaperWidth;
public short dmScale;
public short dmCopies;
public short dmDefaultSource;
public short dmPrintQuality;
public short dmColor;
public short dmDuplex;
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string dmFormName;
public short dmLogPixels;
public short 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")]
public static extern int EnumDisplaySettings (string deviceName, int modeNum, ref DEVMODE devMode );
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(ref DEVMODE devMode, int flags);
public const int ENUM_CURRENT_SETTINGS = -1;
public const int CDS_UPDATEREGISTRY = 0x01;
public const int CDS_TEST = 0x02;
public const int DISP_CHANGE_SUCCESSFUL = 0;
public const int DISP_CHANGE_RESTART = 1;
public const int DISP_CHANGE_FAILED = -1;
[DllImport("user32.dll")]
public static extern int SetWindowPos (System.IntPtr hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
public const int HWND_NOTOPMOST = -2;
public const int HWND_TOPMOST = -1;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOSIZE = 0x0001;
3. OS의 버전을 구하는 함수
[StructLayout(LayoutKind.Sequential)]
public struct OSVERSIONINFO
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public String szCSDVersion;
}
[DllImport("kernel32", EntryPoint="GetVersionExA")]
public static extern bool GetVersionEx ( ref OSVERSIONINFO lpVersionInformation );
public const byte VK_NUMLOCK = 0x90;
public const int KEYEVENTF_EXTENDEDKEY = 0x0001;
public const int KEYEVENTF_KEYUP = 0x0002;
public const int VER_PLATFORM_WIN32_NT = 2;
public const int VER_PLATFORM_WIN32_WINDOWS = 1;
4. 윈도우 핫키 등록 함수
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(
IntPtr hWnd, // window to receive hot-key notification
int id, // identifier of hot key
uint fsModifiers, // key-modifier flags
uint vk // virtual-key code
);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(
IntPtr hWnd, // window associated with hot key
int id // identifier of hot key
);
5. 키보드의 상태를 제어하는 함수
[DllImport("user32.dll")]
public static extern int GetKeyState ( int nVirtKey );
[DllImport("user32.dll")]
public static extern int GetKeyboardState ( byte[] keyBuffer );
[DllImport("user32.dll")]
public static extern int SetKeyboardState ( byte[] keyBuffer );
[DllImport("user32.dll")]
public static extern void keybd_event ( byte bVk, byte bScan, int dwFlags, int dwExtraInfo );
'Tech: > .NET·C#' 카테고리의 다른 글
Oracle .NET Data Provider (0) | 2008.06.26 |
---|---|
.NET Framework을 복구할 때 (0) | 2008.06.26 |
.NET Zero Deployment 요약 (0) | 2008.06.26 |
웹 서비스 사용시 공식 네임스페이스 (0) | 2008.06.26 |
유용한 Regular Expression (0) | 2008.06.26 |