C/C++得到系统启动项
来源:互联网 发布:ipad淘宝hd微淘在哪 编辑:程序博客网 时间:2024/05/23 21:38
1.在VC6.0里面新建一个MFC APPWizard(exe)工程:
选择基本对话:
放入CListCtrl控件:
在CListCtrl控件上单击右键,选建立类向导:
选择Member Variables那一栏:
单击Add variable…设置变量名为m_AutoRunList
void initList(CListCtrl &m_AutoRunList){ LONG lStyle; lStyle = GetWindowLong(m_AutoRunList.m_hWnd, GWL_STYLE);// 获取当前窗口style lStyle &= ~LVS_TYPEMASK; // 清除显示方式位 lStyle |= LVS_REPORT; // 设置style SetWindowLong(m_AutoRunList.m_hWnd, GWL_STYLE, lStyle);// 设置style DWORD dwStyle = m_AutoRunList.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT;// 选中某行使整行高亮(只适用与report 风格的listctrl ) dwStyle |= LVS_EX_GRIDLINES;// 网格线(只适用与report 风格的listctrl ) dwStyle |= LVS_EX_CHECKBOXES;//item 前生成checkbox 控件 m_AutoRunList.SetExtendedStyle(dwStyle); // 设置扩展风格 m_AutoRunList.InsertColumn(0, "No.",LVCFMT_LEFT, 40);// 插入列 m_AutoRunList.InsertColumn(1, "键名",LVCFMT_LEFT, 80);// 插入列 m_AutoRunList.InsertColumn(2, "键值",LVCFMT_LEFT, 500);// 插入列 }void showRunList(CListCtrl &list){ list.DeleteAllItems(); DWORD dwType = 0; DWORD dwBufferSize = MAXBYTE; DWORD dwKeySize = MAXBYTE; char szValueName[255]={0}; char szValueKey[255]={0}; HKEY hKey=NULL; LONG lRet = RegOpenKey(HKEY_CURRENT_USER,REG_RUN,&hKey); if(lRet != ERROR_SUCCESS){ AfxMessageBox("打开注册表失败"); return; } int i=0; CString strTemp; while(true) { dwBufferSize = MAXBYTE; dwKeySize = MAXBYTE; lRet = RegEnumValue(hKey,i++,szValueName,&dwBufferSize,0,0,(unsigned char *)szValueKey,&dwKeySize); if(lRet==ERROR_NO_MORE_ITEMS){ break; } strTemp.Format("%d",i); int nRow = list.InsertItem(i,strTemp);// 插入行 list.SetItemText(nRow, 1, szValueName);// 设置其它列数据 list.SetItemText(nRow, 2, szValueKey);// 设置其它列数据 ZeroMemory(szValueName,MAXBYTE); ZeroMemory(szValueKey,MAXBYTE);//清空缓冲区 }}BOOL CListDlg::OnInitDialog()//窗口初始化时调用的函数,在这里我们初始化了CListCtrl控件,用initList()和showRunList()向里面加入了内容.{ 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); } } SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here //上面是编译器自动生成的初始化代码 initList(m_AutoRunList); showRunList(m_AutoRunList); //自己添加的函数 return TRUE; // return TRUE unless you set the focus to a control}
注意:这个不需要管理员权限
阅读全文
0 0
- C/C++得到系统启动项
- linux系统启动main.c分析
- linux c获取系统启动时间
- AirTight C-65 系统启动日志
- linux c 获取系统启动时间 uptime
- C/C++系列之系统启动流程
- C/C++得到日期字符串
- c中得到系统时间
- c:forEach得到循环计数
- linux用c语言获取系统启动时长
- Android系统启动流程分析init.c和init.rc文件
- 如何得到硬盘序列号?.NET版本[C#]
- 如何得到硬盘序列号?.NET版本[C#]
- 使用C接口编写得到时间信息
- C语言练习题:得到下一秒的时间
- C 如何得到文件的大小
- C/S中得到网页的原代码
- C语言下得到文件的长度
- CMake+mingw-w64编译opencv-3.3.1
- 问题 O: 中庸之道(二)
- 广东工业大学自动化(自动控制原理)作者:Haven
- 一元钱一瓶水,两个空瓶可以换一瓶,三个盖儿可以换一瓶,20元最多能喝多少?
- Wannafly挑战赛5 A珂朵莉与宇宙【暴力枚举】
- C/C++得到系统启动项
- 问题 P: 中庸之道(三)
- PAT 1089. Insert or Merge (25) 插入排序+归并排序
- 打印Log
- Monitor项目开发走过的路~透明Dialog型Activity
- php 如何判断为空详解
- # 详解决策树、python实现决策树
- Struts2第一个拦截器
- 问题 Q: 恶魔的连营