– 델리게이트를 통해 특정 작업을 캡슐화할 수 있다.
[카테고리:] C#
1. 크랙하려는 어셈블리 파일을 ildasm으로 열어서 덤프를 뜬다.
폰트파일 로드 PrivateFontCollection fonts; FontFamily family = LoadFontFamily(@"F:\azuki.ttf", out fonts); theFont = new Font(family, 20.0f); // when done: theFont.Dispose(); family.Dispose(); family.Dispose(); ///////////////////////////////////////////////////////////////////////////////////////// public static FontFamily LoadFontFamily(Stream stream, out PrivateFontCollection fontCollection) { var buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); return LoadFontFamily(buffer, out fontCollection); } //public static unsafe FontFamily LoadFontFamilyUnsafe(byte[] buffer, out PrivateFontCollection fontCollection) //{ // fixed (byte* ptr = buffer) // { // fontCollection = new PrivateFontCollection(); // fontCollection.AddMemoryFont(new IntPtr(ptr), buffer.Length); // return fontCollection.Families[0]; // } //} public static FontFamily LoadFontFamily(byte[] buffer, out PrivateFontCollection fontCollection) { // pin array so we can get its address var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);…
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Configuration.Install; namespace WindowsApplication { [System.ComponentModel.RunInstaller(true)] public class SetupInstaller : System.Configuration.Install.Installer { public SetupInstaller() { this.AfterInstall += new InstallEventHandler(SetupInstaller_AfterInstall); this.BeforeInstall += new InstallEventHandler(SetupInstaller_BeforeInstall); this.Committed += new InstallEventHandler(SetupInstaller_Committed); } // 셋업 설치가 완료되었을 때 호출 void SetupInstaller_Committed(object sender, InstallEventArgs e) { // 아래 그림 3의 CustomActionData 내의 값을 읽어온다. string name = Context.Parameters["CUSTOM1"]; string age = Context.Parameters["CUSTOM2"]; MessageBox.Show(name + "\r\n" + age); } // WindowsApplication.exe 파일이 설치되기 직전에 호출 void SetupInstaller_BeforeInstall(object sender, InstallEventArgs e) { MessageBox.Show("beforeInstall"); } // WindowsApplication.exe 파일이 설치된후에 호출 void SetupInstaller_AfterInstall(object sender, InstallEventArgs e) { MessageBox.Show("afterInstall"); } } }
[그림 …
출처 : http://www.codeproject.com/KB/tips/cs_imagedownload.aspx
using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Net; using System.Text; public class DownloadImage { private string imageUrl; private Bitmap bitmap; public DownloadImage(string imageUrl) { this.imageUrl = imageUrl; } public void Download() { try { WebClient client = new WebClient(); Stream stream = client.OpenRead(imageUrl); bitmap = new Bitmap(stream); } catch (Exception e) { Console.WriteLine(e.Message); } } public Bitmap GetImage() { return bitmap; } public void SaveImage(string filename, ImageFormat format) { if (bitmap != null) { bitmap.Save(filename, format); } } }
private int GetStringLength(string str) { string s = str; byte[] temp = System.Text.Encoding.Default.GetBytes(s); return temp.Length; }
public enum DaysOfWeek { Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7 } [/CODE] [CODE]string CurrentDayString = "Sunday"; DaysOfWeek CurrentDay = DaysOfWeek.Monday; try { CurrentDay = (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), CurrentDayString);} catch { // Invalid enumeration value } switch (CurrentDay) { case DaysOfWeek.Saturday: case DaysOfWeek.Sunday: // What are you doing working on the weekend break; default: // Get back to work break; }
PDF를 생성할 수 있는 라이브러리
iText의 .NET 버전…
홈페이지 : http://itextsharp.sourceforge.net/
튜터리얼 : http://itextsharp.sourceforge.net/tutorial/index.html
DefaultTraceListener
이 클래스의 객체는 Trace와 Debug 클래스의 Listeners 컬렉션에 자동으로 추가되며, Visual Studio.NET의 출력 창 또는 메시지 상자에 메시지를 출력하는 기능을 수행한다.
TextWriterTraceListener
이 클래스의 객체는 Stream 클래스로부터 파생된 클래스에 메시지를 출력한다. 따라서 콘솔이나 파일로 메시지를 출력할 때 사용할 수 있다.
EventLogTraceListener
이 클래스의 객체에서는 윈도우즈 운영체제의 이벤트 로그로 메시지를 출력한다.
[CODE]Debug.Listeners.Add(new EventLogTraceListener(“source”));
Debug.Listeners.Add(new TextWriterTraceListener(@”d:\log.txt”));
Debug.Listeners.Add(new TextWriterTraceListener(System.Console.Out));
Debug.Assert(false, “fail message”, “fail detailmessage”);
[/CODE]