Search results for '프로그래밍'

노트북 도난방지 0930

2008. 9. 30. 23:08
private void ScreenSaver_FormClosing(object sender, FormClosingEventArgs e)
{

e.Cancel = true;
base.OnClosing(e);
}

AlT+F4, ALT+TAB, CTLR + ESC, Windows 키를 막으려고 이리저리 검색했는데
FormClosing 이벤트로 Alt+F4 가 안막히게 구현하는 방법을 찾았다.
원래 내가 의도한건 키보드 키 자체를 안먹히게 하는거였는데.

이제 나머지 다른 키들을 인식안되게 하려고 하다가
어느 외국 사이트에서 Alt+Tab에 관한 소스를 찾았다.
그래서 신나게 소스 적용하고보니...
ALT+Tab 을 막은게 아니라 AlT+Tab 했을때 나오는 아이콘들 중에
내가 지정한 프로그램의 아이콘이 안나오게 하는 소스였다 -_-

[DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr window, int index, int value); [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr window, int index); const int GWL_EXSTYLE = -20; const int WS_EX_TOOLWINDOW = 0x00000080; const int WS_EX_APPWINDOW = 0x00040000;


//Calling after InitializeComponent, or form load events int windowStyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
SetWindowLong(this.Handle, GWL_EXSTYLE, windowStyle | TOOLWINDOW);


휴우 빨리 키 막기 기능 넣고나서
다음 기능들을 추가해야하는데 ㅠ_ㅠ
늘 삽질의 연속이군하~

박상근 프로그래밍/Laptop Guard

노트북 도난방지 0929

2008. 9. 29. 22:58

 private void ScreenSaver_KeyDown(object sender, KeyEventArgs e)
 {

            if (e.KeyCode == Keys.F4)
                e.SuppressKeyPress = true;

            // 이거 안되네 젠장할
            if (e.KeyCode == Keys.LWin)
                e.SuppressKeyPress = true;

            if (e.KeyCode == Keys.Menu)
                e.SuppressKeyPress = true;

            // 탭키가 왜 후킹이 안되지 망할
            if (e.KeyValue == 9)
                e.SuppressKeyPress = true;
}

ALT + TAB 이랑 ALT+F4 랑 windows키 를 막으려고
e.KeyCode=null 을 했더니만 읽기전용속성이라는...ㅠ_ㅠ

그래서 어찌 어찌 지속적인 삽질끝에
e.SuppressKeyPress=true 를 했더니 성공 ㅋㅋ

그런데 이상하게 windows 키랑 tab 키는 안막아진다.
탭키를 KeyCode가 아닌 KeyValue로 해서 조건 잡아도
그냥 탭키는 잘 작동하고만다.

왜일까...

쩝, 그래도 ALT+F4 는 막았다.

한단계씩~

박상근 프로그래밍/Laptop Guard

노트북 도난방지 0928

2008. 9. 28. 23:19
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WaveLib.AudioMixer;
namespace MyProgram
{
public partial class ScreenSaver : Form
{

public ScreenSaver()
{
InitializeComponent();
}

private void ScreenSaver_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Space))
{
MessageBox.Show("키보드 누르지마");
}
}

private void bt_enter_Click(object sender, EventArgs e)
{
if (tb_ckPw.Text.Equals(Main.pwd))
{
this.Dispose();
}
else ScreenSaver_Activated(sender, e);
}

private void ScreenSaver_Activated(object sender, EventArgs e)
{
SoundPlay sp = new SoundPlay();
MyMessageFilter mf = new MyMessageFilter();

Mixers mixers = new Mixers();
mixers.Playback.Lines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.DST_SPEAKERS).Volume = 50000;

Timer.Start();

if (Main.temp_Cb_Power)
{
if (SystemInformation.PowerStatus.PowerLineStatus.ToString() == "Offline")
{
sp.SoundPlayer();
Timer.Stop();
}
}

if (Main.temp_Cb_USB)
{
Application.AddMessageFilter(mf);
}

if (Main.temp_Cb_Typing)
{
}
}

private void Timer_Tick(object sender, EventArgs e)
{
ScreenSaver_Activated(sender, e);
}

private void ScreenSaver_Deactivate(object sender, EventArgs e)
{
SoundPlay sound_Stop = new SoundPlay();
sound_Stop.SoundStop();
}
}
}



기본적인 폼의 형태를 대충 갖추고,
전원장치와 USB의 해제에 대한 경고음 이벤트까지 대충 완성했다


Timer.Stop()의 위치와 유무때문에 전원해제에 대한 이벤트가 제대로 먹히지 않아서 삽질했다
이렇게 하고나서 코드들을 보니, 아... 말로만 듣던 스파게티 소스가 이런것인가 싶다.
오디오 제어 관련 소스는 하다하다 못해서
그냥 공개된 다른 이의 소스 프로젝트를 그대로 첨부해서 쓰고있고-_-
주석은 한줄도 없이 막코딩하다보니 이제 슬슬 내가 헷갈려가기도 한다.
얼른 코드 더 길어지기 전에 주석도 달고 스파게티도 좀 풀어야지

아직 갈길이 멀다.
웹카메라도 활용해야하고, 된다면 로그기록까지 남도록해야하는데
휴우~

영어랑 학과공부까지 생각하니 막막~하구나 

박상근 프로그래밍/Laptop Guard