/*c# *.DLL IDE에 추가하기*/

새로운 using 구문을 사용하기 위해서 예를들어서 using System.Data.SQLite;


DLL을 함께 추가해줘야 한다. 

1. Visual Studio(IDE)에서

2. Project 트리에서

3. 참조

4. 참조추가

5. 찾아보기로 해당 DLL을 클릭후에 확인(full path)

빌드후에 정상적으로 실행이 되는지 확인한다.

SQLite을 설치한 후에 C# 프로젝트에서 System.Data.SQLite.dll를 참조한 후 using System.Data.SQLite; 네임스페이스를 참조하면, SQLite의 .NET 클래스들 (예: SQLiteConnection, SQLiteCommand, SQLiteDataReader 등)을 사용할 수 있다.

코드에 줄 번호 표시
메뉴 모음에서 도구 > 옵션 을 차례로 선택합니다. 텍스트 편집기 노드를 확장한 다음, 사용 중인 언어나 모든 언어 를 선택하여 모든 언어에 줄 번호를 켭니다. (또는 검색 상자에 줄 번호 를 입력하고 결과에서 줄 번호 설정/해제 를 선택합니다.)

줄 번호 확인란을 선택합니다.

참고>
줄 번호는 코드에 추가되지 않으며 참조용으로만 사용됩니다.

 

/*
ToInt32(String) 의 예외처리

예외
FormatException
value가 선택적 부호와 숫자 시퀀스(0~9)로 구성되어 있지 않습니다.

OverflowException
value은(는) MinValue보다 작거나 MaxValue보다 큰 숫자를 나타냅니다.
*/
/*
//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드
ToInt32(String)
숫자의 지정된 문자열 표현을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt16)
지정된 16비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt32)
지정된 32비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Single)
지정된 단정밀도 부동 소수점 숫자 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Object, IFormatProvider)
지정된 문화권별 서식 지정 정보를 사용하여, 지정된 개체의 값을 32비트 부호 있는 정수로 변환합니다.

ToInt32(String, IFormatProvider)
지정된 문화권별 서식 지정 정보를 사용하여, 숫자의 지정된 문자열 표현을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(String, Int32)
지정된 기수로 나타낸 숫자에 대한 문자열 표현을 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt64)
지정된 64비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Object)
지정된 개체의 값을 32비트 부호 있는 정수로 변환합니다.

ToInt32(SByte)
지정된 8비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Int64)
지정된 64비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Int32)
지정된 32비트 부호 있는 정수를 실제 변환 작업 없이 반환합니다.

ToInt32(Int16)
지정된 16비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Double)
지정된 배정밀도 부동 소수점 숫자 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Decimal)
지정된 10진수 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(DateTime)
이 메서드를 호출하면 InvalidCastException이 항상 throw됩니다.

ToInt32(Char)
지정된 유니코드 문자의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Byte)
지정된 8비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Boolean)
지정된 부울 값을 해당하는 32비트 부호 있는 정수로 변환합니다.
*/



string[] values = { "One", "1.34e28", "-26.87", "-18", "-6.00",
                    " 0", "137", "1601.9", Int32.MaxValue.ToString() };
int result;

foreach (string value in values)
{
   try {
      result = Convert.ToInt32(value);
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                        value.GetType().Name, value, result.GetType().Name, result);
   }
   catch (OverflowException) {
      Console.WriteLine("{0} is outside the range of the Int32 type.", value);
   }
   catch (FormatException) {
      Console.WriteLine("The {0} value '{1}' is not in a recognizable format.",
                        value.GetType().Name, value);
   }
}
// The example displays the following output:
//    The String value 'One' is not in a recognizable format.
//    The String value '1.34e28' is not in a recognizable format.
//    The String value '-26.87' is not in a recognizable format.
//    Converted the String value '-18' to the Int32 value -18.
//    The String value '-6.00' is not in a recognizable format.
//    Converted the String value ' 0' to the Int32 value 0.
//    Converted the String value '137' to the Int32 value 137.
//    The String value '1601.9' is not in a recognizable format.
//    Converted the String value '2147483647' to the Int32 value 2147483647.

/*특정 윈도우 Application에 Hook F5 Key 메세지 보내기*/

using NoName;
using NoName.Diagnostics;
using NoName.Text;//Encoding
using NoName.Runtime.InteropServices;

class HookingMessage
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int unMsg, IntPtr wParam, IntPtr lParam);

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

[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

const UInt32 WM_KEYDOWN = 0x0100;
const int VK_F5 = 0x74;

public void running()
{
IntPtr ____handle_mmm=IntPtr.Zero;
bool ____toggle;

____handle_mmm = FindWindow(null, "CONSOLE.TRIS");
____toggle=PostMessage(____handle_mmm, WM_KEYDOWN, VK_F5, 0 );

if(____toggle==true) Console.WriteLine("PostMessage succ!!");
else Console.WriteLine("PostMessage fail!!");
}
}

class Program
{
public static void Main()
{
HookingMessage nm = new HookingMessage();
nm.running();
}
}



/*
namespace:System
Int To Double -> Convert.ToDouble(int or double)
Double to Int -> Convert.ToInt32(double)
*/

class TrisWidthHeight : Form
{
int titledepth, widthdepth, heightdepth;
public TrisWidthHeight()
{
titledepth = this.Height - this.ClientRectangle.Height;
titlewidth = Convert.ToInt32(Convert.ToDouble(titledepth / 10.0)) * 7
titleheight = Convert.ToInt32(Convert.ToDouble(titledepth / 10.0)) * 4
this.Width = titlewidth;
this.Height = titleheight;
}





using NoName;
using NoName.Timers;

class Program
{
public static void Main()
{
ExampleManageCls nm = new ExampleManageCls();
nm.running();
}
}

class ExampleManageCls
{
Timer tm = new Timer();
DateTime endTime;

public void running()
{
tm.Elapsed += new ElapsedEventHandler(____time_tick);
tm.Interval = 1000;
tm.Start();

endTime = DateTime.Now.AddMinutes(1);

while(true)
{
if(endTime<DateTime.Now)
{
break;
}
}
}

void ____time_tick(object sender, ElapsedEventArgs e)
{
Console.WriteLine(DateTime.Now.ToString() + "/" + endTime.ToString());
}
}

/*RESULT-------------------------------------------------------
2022-03-28 오전 9:56:47/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:48/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:49/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:50/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:51/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:52/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:53/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:54/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:55/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:56/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:57/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:58/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:59/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:00/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:01/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:02/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:03/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:04/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:05/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:06/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:07/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:08/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:09/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:10/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:11/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:12/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:13/2022-03-28 오전 9:57:13

D:\tmp\console>
-------------------------------------------------------*/

/*
*상속안할경우 나오는 에러메세지*/


Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

ex12.cs(18,26): error CS0115: 'WindowsFrmManage.ProcessCmdKey(ref NoName.Windows.Forms.Message,
        NoName.Windows.Forms.Keys)': 재정의할 적절한 메서드를 찾을 수 없습니다.
ex12.cs(40,26): error CS0115: 'WindowsFrmManage.WndProc(ref NoName.Windows.Forms.Message)': 재정의할 적절한 메서드를 찾을 수 없습니다.

using NoName;
using NoName.Windows.Forms;

class Program
{
public static void Main(string[] args)
{
Application.Run(new WindowsFrmManage());
}
}
class WindowsFrmManage
{
public WindowsFrmManage() {}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x0100, WM_KEYUP = 0x0101, WM_CHAR = 0x0102, WM_SYSKEYDOWN = 0x0104, WM_SYSKEYUP = 0x0105, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
         switch (keyData.ToString())
{
case "Down"   :
break;
case "Escape" :
Application.Exit();
break;
         default:
             break;
         }
     }
return base.ProcessCmdKey(ref msg, keyData);
}

protected override void WndProc(ref Message m)//sdw_mh12e
{
const int WM_KEYDOWN = 0x0100, WM_KEYUP = 0x0101, WM_CHAR = 0x0102, WM_SYSKEYDOWN = 0x0104, WM_SYSKEYUP = 0x0105, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

base.WndProc(ref m);

switch(m.Msg)
{
case WM_PAINT :
break;
default:
break;
}
}
}


using NoName;
using NoName.Windows.Forms;

class FrmIndex006 : Form
{
public FrmIndex006()
{
Console.WriteLine(">>>>FrmIndex006");
}
}

class FrmIndex007 : FrmIndex006
{
public FrmIndex007()
{
Console.WriteLine(">>>>FrmIndex007");
}
}

class FrmIndex008 : FrmIndex007
{
public FrmIndex008()
{
Console.WriteLine(">>>>FrmIndex008");
}
}

class FrmIndex009 : FrmIndex008
{
public FrmIndex009()
{
Console.WriteLine(">>>>FrmIndex009");
}
}

class FrmIndex010 : FrmIndex009
{
public FrmIndex010()
{
Console.WriteLine(">>>>FrmIndex010");
}
}

class FrmMain : FrmIndex010
{
public FrmMain()
{
Console.WriteLine(">>>>FrmMain");
}
protected override void WndProc(ref Message m)
{
const int WM_KEYDOWN = 0x0100, WM_SYSKEYDOWN = 0x0104, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

base.WndProc(ref m);

try
{
switch(m.Msg)
{
case WM_PAINT :
DialogResult dialogResult = MessageBox.Show(">>Quit OK!!", "Inform",
              MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

if (dialogResult == DialogResult.OK) Application.Exit();
break;
default:
break;
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
/*
D:\tmp\console>sample
>>>>FrmIndex006
>>>>FrmIndex007
>>>>FrmIndex008
>>>>FrmIndex009
>>>>FrmIndex010
>>>>FrmMain

D:\tmp\console>
*/

class Program
{
public static void Main()
{
Application.Run(new FrmMain());
}
}


+ Recent posts