如何在mfc中的clistctrl中加载启动程序? [英] How to load startup programs in clistctrl in mfc?
本文介绍了如何在mfc中的clistctrl中加载启动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有List控件,我想用它管理启动程序
首先我需要加载启动程序抱歉我没有任何想法
去做吗?这就是我要找的......
请帮助!!!
我尝试过:
I have List control and I wanted to manage startup programs using it
for that first I need to load start up programs Sorry I don't have any Idea how
to do it? That's what I'm looking for...
Please Help!!!
What I have tried:
// This is a list control...
m_lstStartupProgram.InsertColumn(0,_T("File Name"),LVCF_TEXT,180);
m_lstStartupProgram.InsertColumn(1,_T("File Location"),LVCF_TEXT,230);
m_lstStartupProgram.InsertColumn(2,_T("Key"),LVCF_TEXT,280);
void CStartupBoosterPage::LoadStartupsToList()
{
//Here I want to write code...
}
推荐答案
没有简单的解决方案来获取启动程序列表,因为有多个位置可以定义启动程序。
但你可以检索使用WMI或PowerShell的列表。因此,最简单的解决方案是将它们作为命令行进程执行,将输出重定向到文本文件,以及读取和解析该文件。请参阅通过命令行或PowerShell生成启动程序列表 [ ^ ]使用WMI和PowerShell。
要执行进程,请使用 system,_wsystem [ ^ ]或 CreateProcess功能(Windows) [ ^ 。应将输出写入临时文件(请参阅 GetTempFileName函数(Windows) [ ^ ])阅读后应将其删除。阅读文本文件应该没问题。使用WMI时,您必须逐行处理文本文件并将行拆分为它的列(使用strtok
,CString :: Tokenize
,或AfxExtractSubString
)。使用PowerShell输出,项目由空行分隔,列以标识符为前缀(当使用上面链接中的命令时)。
There is no simple solution to get the list of startup programs because there are multiple locations where startup programs are defined.
But you can retrieve a list using WMI or PowerShell. So the simplest solution would be executing those as command line processes, redirecting the output to a text file, and read and parse that file. See Generate a List of Startup Programs via Command Line or PowerShell[^] for using WMI and the PowerShell.
To execute processes use system, _wsystem[^] or CreateProcess function (Windows)[^]. The output should be written to a temporary file (see GetTempFileName function (Windows)[^]) which should be deleted after reading it. Reading a text file should be no problem. When using WMI you have to process the text file line by line and split the lines into it's column (usestrtok
,CString::Tokenize
, orAfxExtractSubString
). With the PowerShell output, items are separated by empty lines and the columns are prefixed with an identifier (when using the command from the above link).
这篇关于如何在mfc中的clistctrl中加载启动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文