본문 바로가기

Application179

C++ dll 을 C# 에서 사용하기 C++ 로 구현된 dll 사용시 포인터 사용시 C# 에서는 배열로 처리하면 된다. 또 dll 에서 포인터로 데이타를 다시 리턴 받는 경우에도 유용하다. 아래 함수의 경우 파일을 해당 사이즈 별로 저장하고 그 저장된 결과값을 다시 리턴해 준다. C++ 원형 extern "C" C_TEST_API BOOL WINAPI open_file(const char* filename, const char* filename2, int size, int compress, int dpi, float* scr_width, float* src_height, int* dst_width, int* dst_height); C# 사용 선언부 private static extern int open_file(char[] filename,.. 2010. 11. 11.
List<> 의 Exists 사용법 LIst 객체의 Find, FindAll, Exists 메소드가 있다. List 객체내의 데이타를 찾는 부분이다. 그중 Exists 사용법이다. 나머지들도 이와 비슷하니 다른것들은 직접 구현해 보길 권장한다. bool compareResult = stringList.Exists( delegate(string data) { if (data == compareString) return true; else return false; } ); if (compareResult) Console.WriteLine("같은 데이타 있다"); else Console.WriteLine("없다"); 2010. 9. 24.
콘솔 프로그램 시작 폴더 구하기. WinForm 프로그램의 경우 Applicatoin.StartupPath 이란 메소드를 이용하면 시작폴더 위치를 구할수 있다. 하지만 콘솔의 경우 System.Form 이 포함되지 않는 문제로 위의 메소드를 사용할수 없다. 네이버에서 한참 찾았지만 없다. 역시.. 구글로 가봐야 겠다. 일단 내가 구하고자 하는 답은 AppDomain.CurrentDomain.BaseDirectory.ToString() -> D:\project\C#\tempProject\bin\bebug\ 와 같다 또다른 방법은 System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase -> file://D:\project\C#\tempProject\bin\bebug\proj.. 2010. 7. 22.
Stream 을 Byte 로 바꾸자 Steam 을 Byte 로 바꾸는 함수. 좀더 빠른 처리를 위한다면 byte 의 크기를 늘려주면 되겠죠~~ public byte[] ReadSteamToByte(Stream stream) { byte[] buffer = new byte[1024]; using (MemoryStream ms = new MemoryStream()) { while (true) { int read = stream.Read(buffer, 0, buffer.Length); if (read 2010. 6. 18.