Posted on 2007/01/30 16:25
Filed Under Development/C# Application

닷넷 환경에서는 메모리가 회수되지 않는 경우가 흔한다.

다음은 닷넷에서 win32를 이용한 메모리 강제 회수 방법이다.

using System.Runtime.InteropServices;

#region 강제 메모리 회수


[DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]


private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize);





public static void FlushMemory() {


    GC.Collect();


    GC.WaitForPendingFinalizers();


    if (Environment.OSVersion.Platform == PlatformID.Win32NT) {

        SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
  }


}

#endregion


관련 아티클 : http://www.gosu.net/GosuWeb/ArticleMSView.aspx?ArticleCode=342
2007/01/30 16:25 2007/01/30 16:25

Posted on 2006/10/30 18:39
Filed Under Development/C# Application













string query = "SELECT * FROM member WHERE mem_id = 'TakeOne'";

MySqlCommand command = new MySqlCommand(query, connect);



//결과값이 없는 쿼리를 날릴때

//command.ExecuteNonQuery();



//결과값이 있을때

MySqlDataReader reader = command.ExecuteReader();

reader.Read();            

MessageBox.Show(reader["mname"].ToString());

command.Connection.Close();


2006/10/30 18:39 2006/10/30 18:39

Posted on 2006/10/30 18:21
Filed Under Development/C# Application





Dll 파일



MySqlClient\CharSetMap.cs 101번째 줄 수정해서 Dll 새로 생성

mapping.Add("euckr", 949);

mapping.Add("euc_kr", 949);

www.mysql.org에서 제공하는 connector에서는 이부분이 주석처리 되어있다.



닷넷에서는 이 파일을 참조추가 한후 사용하면 된다.
2006/10/30 18:21 2006/10/30 18:21

Posted on 2006/05/18 14:52
Filed Under Development/C# Application





그전에는 그렇게 방법을 모르겠더니...



이번에 하니까 의외로 쉽게 찾았다.



IntPtr wndHdle = IntPtr.Zero;

wndHdle = FindWindow("Progman", "Program Manager");

IntPtr wndDC = GetWindowDC(wndHdle);

IntPtr child = ChildWindowFromPoint(wndHdle, 0, 0);

IntPtr child2 = ChildWindowFromPoint(child, 0, 0);

DesktopWindow d = new DesktopWindow();

SetParent(d.Handle, child2);

d.Show();



일단 Progman이 바탕화면 윈도우이다. 여기에다가 폼을 출력하면 아이콘이 가려진다.



아이콘 뒤에 출력하려면 wndHdle의 자식창의 자식창에 출력을 해야 아이콘 뒤에 출력된다.



나중에 만들 프로그램에 쓰일수 있겠군 ㅋ

2006/05/18 14:52 2006/05/18 14:52

Posted on 2006/03/29 10:37
Filed Under Development/C# Application

/// <summary>

/// 실제 캡쳐

/// </summary>

/// <param name="fileName"></param>

public void captureFlash(string fileName) {

  IntPtr window = albumCapture.Handle;

  IntPtr dc = NativeCalls.GetDC(window);

  IntPtr bitmaps = NativeCalls.GetCurrentObject(dc, 7);  

  Image image = Image.FromHbitmap(bitmaps);



  long jpegQuality = 100L;

  EncoderParameters ep = new EncoderParameters(1);

  ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, jpegQuality);

  ImageCodecInfo ici = GetEncoderInfo("image/jpeg");

  image.Save(fileName, ici, ep);

}

private static ImageCodecInfo GetEncoderInfo(String mimeType)

{

  int j;

  ImageCodecInfo[] encoders;

  encoders = ImageCodecInfo.GetImageEncoders();

  for (j = 0; j < encoders.Length; ++j)

  {

   if (encoders[j].MimeType == mimeType)

    return encoders[j];

  }

  return null;

}





아놔~~ 역시 새분야는 어렵다..

2006/03/29 10:37 2006/03/29 10:37

Posted on 2006/03/07 14:56
Filed Under Development/C# Application

닷넷 2003에서 테스트할경우 전혀~ 문제가 없던 놈이



2005에서 테스트해보니 ActiveX 가져오기 실패 라는 이딴 말을 한다.



잠시 황당했지만 자료는 금방 찾을수 있었다.



머 영어로 어쩌고 했지만 즉 2005버전에서는 문제가 있다는 말이다.



때문에~

my project\obj\Debug

요 위치에 다음 파일을 살짝 끼워줘야 제대로 동작한다.

2006/03/07 14:56 2006/03/07 14:56

Posted on 2006/02/27 17:24
Filed Under Development/C# Application

1. 먼저 '도구 상자'에서 우클릭 -> '항목 추가/제거' 메뉴에서 다음과 같이 Shockwave Flash Object를 추가



2. Shockwave Flash Object 컨트롤을 생성



3. 생성된 Shockwave Flash Object에 플래시를 로드한다.

private void Form1_Load(object sender, System.EventArgs e) 
{ 
        axShockwaveFlash1.Movie = System.IO.Directory.GetCurrentDirectory() + "\\test.swf"; 
} 






4. 플래시에 값 보내기



-씨샵 코드-

axShockwaveFlash1.SetVariable("CVals", "씨샵에서 ...");




-플래시 코드-

function hello(prop, oldVal, newVal, speedLimit) {
 test_txt.text = "안녕 " + newVal;
}

watch("CVals", hello);






5. 플래시에서 씨샵으로 값 보내기



-씨샵 코드

  private void axShockwaveFlash1_FSCommand(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent e)
  {
   if(e.command=="test") 
   { 
    System.Windows.Forms.MessageBox.Show(e.args); 
    Application.Exit(); 
   }    
  }




-플래시 코드-

 image.onRelease = function() {
  fscommand("test", "안녕하세요");
 };

2006/02/27 17:24 2006/02/27 17:24

Counter

· Total
: 361645
· Today
: 93
· Yesterday
: 110