⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autorundlg.cpp

📁 AppWizard has created this autorun application for you. This application not only demonstrates the
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// autorunDlg.cpp : implementation file
//

#include "stdafx.h"
#include "autorun.h"
#include "autorunDlg.h"

#include<Tlhelp32.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BOOL tftf=false;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
typedef struct tagKBDLLHOOKSTRUCT {

    DWORD   vkCode;

    DWORD   scanCode;

    DWORD   flags;

    DWORD   time;

    DWORD   dwExtraInfo;

} KBDLLHOOKSTRUCT, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);//挂钩函数
static HHOOK hkb=NULL;
HINSTANCE hins; //钩子函数所在模块的句柄
#define WH_KEYBOARD_LL 13
#define HKCU HKEY_CURRENT_USER
#define ARUN HKEY_LOCAL_MACHINE
#define WM_MYMESSAGE 20
LPCTSTR autorun =
	"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
LPCTSTR ppth =
	"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Getip";
LPCTSTR Autogetip = "autorun";	
		
class CAboutDlg : public CDialog
{
public:
	bool xxss;
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	afx_msg void OnButton1();
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT

}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutorunDlg dialog

CAutorunDlg::CAutorunDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAutorunDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAutorunDlg)
	m_ExitWindow = -1;
	m_sec = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CAutorunDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAutorunDlg)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Control(pDX, IDC_RADIO1, m_radio);
	DDX_Radio(pDX, IDC_RADIO1, m_ExitWindow);
	DDX_Text(pDX, IDC_EDIT1, m_sec);
	DDV_MinMaxLong(pDX, m_sec, 1, 100000);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAutorunDlg, CDialog)
	//{{AFX_MSG_MAP(CAutorunDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RUN, OnRun)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutorunDlg message handlers

BOOL CAutorunDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
    nu=1;
	xs=true;

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	 
	// TODO: Add extra initialization here
	    char szFilePath[150];
		DWORD type_2=REG_SZ; 
		LPBYTE autorunn=new BYTE[200]; 
		DWORD autorunn_size=200;
	    AfxGetMainWnd()->MoveWindow(0,0,330,90, true);
		xs=false;
		SetDlgItemText(IDC_BUTTON2,"显示[&D]");
		hins=AfxGetApp()->m_hInstance;
		hkb=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)KeyboardProc,hins,0);//设置低级键盘钩子
        HKEY at;
		if(::GetModuleFileName(NULL, szFilePath,150))
		{
		    if(RegOpenKey(ARUN,autorun,&at)!=ERROR_SUCCESS)         //打开注册表
      			RegCreateKey(HKCU,autorun, &at);  
			 
		    long   ret2=::RegQueryValueEx(at, "autorun", NULL,&type_2,autorunn, &autorunn_size); //查询注册表USER键值
            if(ret2!=ERROR_SUCCESS) 
			{  
                 RegSetValueEx(at,Autogetip, NULL,REG_SZ, (BYTE*)szFilePath, 150);  
         	}
		    else
			{
				RegSetValueEx(at,Autogetip, NULL,REG_SZ, (BYTE*)szFilePath, 150);  
				DWORD Style=::GetWindowLong(AfxGetMainWnd()->m_hWnd,GWL_EXSTYLE);     //获取窗口样式
	            Style=WS_EX_TOOLWINDOW;                     
	            ::SetWindowLong(AfxGetMainWnd()->m_hWnd,GWL_EXSTYLE,Style); //设置窗口样式
	            ::MoveWindow(AfxGetMainWnd()->m_hWnd,0,0,0,0,TRUE);       //设置窗口大小
			}
			                            
	                
		}
	
	
		

		//////////////////////////////////////////////////////////////
		
		return TRUE;  // return TRUE  unless you set the focus to a control
}

void CAutorunDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CAutorunDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CAutorunDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CAutorunDlg::OnRun() 
{
	// TODO: Add your control notification handler code here
	int panduan=0;
	for(int k=1;k<11;k++)
	{
		if(path[k].IsEmpty())
			panduan++;
		if(k==10)
			panduan++;
	}
	if(panduan!=0)
	{
	    UpdateData(true);
	    CString lin;
	    if(m_radio.GetCheck()==1||(m_sec>0)&&(m_sec<100000))
		{
		

		
	            if(m_radio.GetCheck()==1)         //如果RADIO选中 也就是如果用户选择关机
				{
top:
				if(nu>10)                         //如果序号大于10    该循环意图:自动查找数组为NULL的数组项再向里面写入数据
	            		nu=1;

					if(path[nu].IsEmpty())
					{   
						char a[100];
						CString ddd;
						CString  cc="                    1$";
 				        itoa(nu,a,100);
						path[nu]=cc+a;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -