HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu下所有键值和 nt以上系统在: 系统所在盘:\Documents and Settings\All Users\Start Menu 系统所在盘:\Documents and Settings\你的用户名\Start Menu这个文件夹下的所有文件和子文件
// Get a pointer to the IShellLink interface. hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); if (SUCCEEDED(hres)) { IPersistFile* ppf;
// Get a pointer to the IPersistFile interface. hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if (SUCCEEDED(hres)) { WCHAR wsz[MAX_PATH];
// Ensure that the string is Unicode. MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
// TODO: Check return value from MultiByteWideChar to ensure success.
// Load the shortcut. hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres)) { // Resolve the link. hres = psl->Resolve(hwnd, 0); if (SUCCEEDED(hres)) { // Get the path to the link target. hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH); if (SUCCEEDED(hres)) { // Get the description of the target. hres = psl->GetDescription(szDescription, MAX_PATH); if (SUCCEEDED(hres)) { hres = StringCbCopy(lpszPath, sizeof(lpszPath), szGotPath); if (SUCCEEDED(hres)) { // Handle success } else // application-defined function HandleErr(hres); } } } } // Release the pointer to the IPersistFile interface. ppf->Release(); } // Release the pointer to the IShellLink interface. psl->Release(); } return hres; }
nt以上系统在:
系统所在盘:\Documents and Settings\All Users\Start Menu
系统所在盘:\Documents and Settings\你的用户名\Start Menu这个文件夹下的所有文件和子文件
QueryServiceConfig可以查询出指定服务的进程路径.
------------------------------------------------------------
按照开始菜单里程序那样,列出所有可执行文件来:
可以先SHGetSpecialFolderPath得到开始菜单的目录,列举出其中的所有shortcut,然后使用下列方法得到路径:
HRESULT ResolveIt(HWND hwnd, LPCSTR lpszLinkFile, LPSTR lpszPath)
{
HRESULT hres;
IShellLink* psl;
char szGotPath[MAX_PATH];
char szDescription[MAX_PATH];
WIN32_FIND_DATA wfd;
*lpszPath = 0; // assume failure
// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
// Get a pointer to the IPersistFile interface.
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
// Ensure that the string is Unicode.
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
// TODO: Check return value from MultiByteWideChar to ensure
success.
// Load the shortcut.
hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres))
{
// Resolve the link.
hres = psl->Resolve(hwnd, 0); if (SUCCEEDED(hres))
{
// Get the path to the link target.
hres = psl->GetPath(szGotPath,
MAX_PATH,
(WIN32_FIND_DATA*)&wfd,
SLGP_SHORTPATH); if (SUCCEEDED(hres))
{
// Get the description of the target.
hres = psl->GetDescription(szDescription, MAX_PATH); if (SUCCEEDED(hres))
{
hres = StringCbCopy(lpszPath, sizeof(lpszPath),
szGotPath);
if (SUCCEEDED(hres))
{
// Handle success
}
else
// application-defined function
HandleErr(hres);
}
}
}
} // Release the pointer to the IPersistFile interface.
ppf->Release();
} // Release the pointer to the IShellLink interface.
psl->Release();
}
return hres;
}
结束加上CoUninitialize();
idAnts(你才无聊呢) 的方法应该是可行的。
http://community.csdn.net/Expert/topic/3765/3765897.xml?temp=.4314081
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services但是这么做没那个科学。