我想从注册表中获取所有启动程序可以帮助我吗? [英] I want to get all start up programs from registry can any one help me?

查看:57
本文介绍了我想从注册表中获取所有启动程序可以帮助我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

csaStartUpProgram.Add(Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce);



csaStartUpProgram.Add( Software \\Microsoft \\ Windows \\ CurrentVersion \\ Run);



csaStartUpProgram.Add(SOFTWARE \\Wow6432Node \\ \\\ Mycoftoft \\ Windows \\ CurrentVersion \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\Microsoft\\Windows\\CurrentVersion\\Run);



为(INT nStartupProgram = 0; nStartupProgram< csastartupprogram.getsize(); nstartupprogram ++)>

{







HKEY hKey;



如果(RegOpenKey(HKEY_LOCAL_MACHINE,csaStartUpProgram [nStartupProgram],&的hKey)== ERROR_SUCCESS)

{

<无线电通信/>
DWORD dwValues,dwMaxValueNameLen,dwMaxValueLen;

LONG lRet = :: RegQueryInfoKey(hKey,

NULL,NULL,// lpClass,lpcClass

NULL,// lpReserved

NULL, NULL,// lpcSubKeys,lpcMaxSubKeyLen

NULL,// lpcMaxClassLen

&dwValues,

&dwMaxValueNameLen,

&dwMaxValueLen,

NULL,// lpcbSecurityDescriptor

NULL); // lpftLastWriteTime

if(ERROR_SUCCESS == lRet)

{

//分配足以容纳最大值。长度名称和值

LPTSTR pszName =新TCHAR [dwMaxValueNameLen + 1];

LPBYTE的lpData =新的字节[dwMaxValueLen];

为( DWORD dwIndex = 0; dwIndex< dwValues; dwIndex ++)

{

DWORD dwNameSize = dwMaxValueNameLen + 1;

DWORD dwValueSize = dwMaxValueLen; <登记/>
DWORD dwType;

LRET = :: RegEnumValue(的hKey,dwIndex,pszName,&dwNameSize,0,&dwType,的lpData,&dwValueSize);

的CString strName = pszName;

if(REG_SZ == dwType)

{

CString strValue =(LPCTSTR)lpData;





}

CLog :: Log(strName + _T());

}

删除[] pszName;

删除[] lpData;

}

}

}`







我来了g输出:



Communicator,SAP_WUS_UNT,BCSSync,Communicator,SAP_WUS_UNT,BCSSync,



相同的输出是重复两次,但我希望所有程序从上面启动路径请帮助我...





我认为它指的是WoW6432Node软件的路径\\ microsoft \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\我的解决方案

csaStartUpProgram.Add(Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce);

csaStartUpProgram.Add(Software\\Microsoft\\Windows\\CurrentVersion\\Run);

csaStartUpProgram.Add(SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce);

csaStartUpProgram.Add(SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run);

for(int nStartupProgram=0;nStartupProgram<csastartupprogram.getsize();nstartupprogram++)>
{



HKEY hKey;

if (RegOpenKey(HKEY_LOCAL_MACHINE,csaStartUpProgram[nStartupProgram],&hKey) == ERROR_SUCCESS)
{

DWORD dwValues, dwMaxValueNameLen, dwMaxValueLen;
LONG lRet = ::RegQueryInfoKey(hKey,
NULL, NULL, // lpClass, lpcClass
NULL, // lpReserved
NULL, NULL, // lpcSubKeys, lpcMaxSubKeyLen
NULL, // lpcMaxClassLen
&dwValues,
&dwMaxValueNameLen,
&dwMaxValueLen,
NULL, // lpcbSecurityDescriptor
NULL); // lpftLastWriteTime
if(ERROR_SUCCESS == lRet)
{
// allocate enough to fit max. length name and value
LPTSTR pszName = new TCHAR[dwMaxValueNameLen + 1];
LPBYTE lpData = new BYTE[dwMaxValueLen];
for(DWORD dwIndex = 0; dwIndex < dwValues; dwIndex++)
{
DWORD dwNameSize = dwMaxValueNameLen + 1;
DWORD dwValueSize = dwMaxValueLen;
DWORD dwType;
lRet = ::RegEnumValue(hKey, dwIndex, pszName, &dwNameSize,0, &dwType, lpData, &dwValueSize);
CString strName = pszName;
if(REG_SZ == dwType)
{
CString strValue = (LPCTSTR)lpData;


}
CLog::Log(strName + _T(""));
}
delete []pszName;
delete []lpData;
}
}
}`



I am getting output:

Communicator, SAP_WUS_UNT, BCSSync, Communicator, SAP_WUS_UNT, BCSSync,

Same output is repeating two times but i want all programs from above start up paths please help me...


I think it is pointing to WoW6432Node Path for Software\\Microsoft\\Windows\\CurrentVersion\\Run path also this may Win32 function pointing to Wow6432Node then how to get the programs from above path....... plz give me solution

推荐答案

试试这可能是你得到任何帮助



try this may be you get any help

RegistryKey key =                           Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run");
         foreach (string Programs in key.GetValueNames())
         {
             string GetValue = key.GetValue(Programs).ToString();
             Console.WriteLine(getFilePath(GetValue));
         }


这篇关于我想从注册表中获取所有启动程序可以帮助我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆