본문 바로가기

Code

(117)
.NET Compact Framework Project Sample using System; using System.Windows.Forms; namespace SmartDeviceProject1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.tabControl1.Height = this.Height; } private void inputPanel1_EnabledChanged(object sender, EventArgs e) { this.SuspendLayout(); if (this.inputPanel1.Enabled) { this.tabControl1.Height = this.Height - this.inputPanel1.Bounds.Height; } else { th..
[C/C++ vs C#] static (1) function 내부에서 static variable 선언 가능 #include void main() { static int i = 0; // valid } method 내부에서 static variable 선언 불가능 static field 선언 가능 using System; namespace Sample { class Program { static void Main(string[] args) { static int i = 0; // compile time error } private static int number = 0; // valid } }
[C/C++ vs C#] sizeof sizeof(variable) 가능 #include using namespace std; void main() { int i = 0; cout
[C/C++] C++/CLI Command Line Compile Sample 아래 링크를 참조하자. http://www.simpleisbest.net/archive/2007/01/19/1568.aspx using namespace System; void main() { Console::WriteLine("Hello World"); } 위 코드를 아래와 같이 컴파일하자. cl.exe /clr hello.cpp 2008/06/05 - Mixing Unmanaged C++, C++/CLI, and C# code
Cursor.Position, SetCursorPos, mouse_event 샘플코드 Cursor.Position, SetCursorPos, mouse_event 를 이용해서 마우스를 컨트롤하는 샘플코드이다. 원하는 위치로 이동할 수도 있고, 마우스 클릭도 조절할 수 있다. using System; using System.Drawing; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; namespace MouseSample { class Program { static void Main(string[] args) { Point myPoint = new Point(); myPoint.X = 10; myPoint.Y = 10; Cursor.Position = myPoint; Thre..
Process : Thread를 이용한 메모장에 키 입력하기 메모장이 실행되기를 기다렸다가, 메모장에 문장을 입력하는 샘플코드이다. Thread를 이용한 것이다. 이것은 AutoIt, AutoHotKey 같은 Task Automation 프로그램 대용으로 활용할 수 있다. using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; namespace ProcessTest { class Program { static void Main(string[] args) { ThreadStart myThreadStart = new ThreadStart(DoWork); Thread myThread = new ..
Process : 메모장에 키 입력하기 메모장에 Hello World 문장을 입력하는 샘플코드이다. using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; namespace ProcessTest { class Program { static void Main(string[] args) { Process[] myProcesses = Process.GetProcessesByName("notepad"); foreach (Process item in myProcesses) { SetForegroundWindow(item.MainWindowHandle); Thread.Sleep(..
Process : Notepad 종료 샘플코드 현재 실행중인 메모장을 모두 종료시키는 샘플코드이다. using System; using System.Diagnostics; namespace ProcessTest { class Program { static void Main(string[] args) { Process[] myProcesses = Process.GetProcessesByName("notepad"); foreach (Process item in myProcesses) { // Close process by sending a close message to its main window. item.CloseMainWindow(); // Free resources associated with process. item.Close(); } } } }