| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 520 人关注过本帖
标题:C#编程遇到问题求各位帮个忙
只看楼主 加入收藏
那年秋天
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-12-8
收藏
 问题点数:0 回复次数:3 
C#编程遇到问题求各位帮个忙
我C# 刚入门   培训了3个月  培训的叫老师叫我们做一个超市结账系统  
要求以下功能
1、用户登陆功能
2、用户离开锁屏功能,重新登陆需要输入当前用户的密码
3、结账功能:显示出详细的商品数量,价格,及总价。
4、确定结账前的删除选中商品功能
  那个离开锁屏的功能我弄了 好几天还是没头绪
诚心希望哪个高手, 能帮帮我啊!  
 小弟在此感激不尽!(最好附远吗)
搜索更多相关主题的帖子: 培训 用户 最好 
2012-12-08 22:11
hjywyj
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:1114
专家分:2611
注 册:2010-4-14
收藏
得分:0 
给你个源码参考一下,这个是模拟死机的程序,和你的锁屏功能差不多,开了个线程扼杀了任务管理器和win+R打开的运行窗口。输入"abcd"解锁,如果输入错误可以按回车重新输入


 public partial class Form1 : Form
    {
        Thread thread;
        string str = "";
        public Form1()
        {
            InitializeComponent();
        }
        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hwnd, int msg, int wparam, int iparam);
        [DllImport("gdi32.dll")]
        private static extern IntPtr CreateDC(
        string lpszDriver, // 驱动名称
        string lpszDevice, // 设备名称
        string lpszOutput, // 无用,可以设定位"NULL"
        IntPtr lpInitData // 任意的打印机数据
        );

        [DllImport("gdi32.dll")]
        private static extern bool BitBlt(
        IntPtr hdcDest, //目标设备的句柄
        int nXDest, // 目标对象的左上角的X坐标
        int nYDest, // 目标对象的左上角的X坐标
        int nWidth, // 目标对象的矩形的宽度
        int nHeight, // 目标对象的矩形的长度
        IntPtr hdcSrc, // 源设备的句柄
        int nXSrc, // 源对象的左上角的X坐标
        int nYSrc, // 源对象的左上角的X坐标
        System.Int32 dwRop // 光栅的操作值
        );
        private void KillTaskmgr()
        {
            var processinfo = Process.GetProcesses();
            foreach (var pro in processinfo)
            {
                if (pro.ProcessName == "taskmgr" || pro.ProcessName == "cmd")
                {
                    try
                    {
                        pro.Kill();
                    }
                    catch { }
                }

            }
            IntPtr ip = FindWindow(null, "运行");
            if (ip != IntPtr.Zero)
            {
                SendMessage(ip, 0x10, 0, 0);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.ShowInTaskbar = false;
            thread = new Thread(KillTaskmgr);
            thread.Start();
            WindowState = FormWindowState.Maximized;
            this.Visible = false;
            IntPtr p1 = CreateDC(Screen.AllScreens[0].DeviceName, null, null, IntPtr.Zero);
            Graphics g1 = Graphics.FromHdc(p1);
            Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
            Graphics g2 = Graphics.FromImage(bmp);
            IntPtr p2 = g2.GetHdc();
            IntPtr p3 = g1.GetHdc();
            BitBlt(Graphics.FromImage(bmp).GetHdc(), 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, p3, 0, 0, 13369376);
            g1.ReleaseHdc(p3);
            g2.ReleaseHdc(p2);
            BackgroundImage = bmp;
            this.Visible = true;
        }
        protected override CreateParams CreateParams
        {
            get
            {
                const int CS_NOCLOSE = 0x200;
                CreateParams cp = base.CreateParams;
                cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
                return cp;
            }

        }
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                str = "";
            else
                str += e.KeyCode.ToString();
            if (str.ToLower().Trim() == "abcd")
            {
                if (thread.ThreadState == System.Threading.ThreadState.Running)
                    try
                    {
                        thread.Abort();
                    }
                    catch
                    {
                        ;
                    }
                this.Close();
            }
        }
    }
2012-12-09 08:46
那年秋天
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-12-8
收藏
得分:0 
谢谢你
2012-12-09 09:57
zdd19891214
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2012-12-27
收藏
得分:0 
我也来试试运行下,新手上路啊
2012-12-27 19:40
快速回复:C#编程遇到问题求各位帮个忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035731 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved