获取软件所有快捷方式名称,判断本地是否安装,并打开

2019-04-14 20:10发布

// 获取快捷方式路径 char* getApplicationLnkLocation(HKEY locType , TCHAR lpValueName[]) { MyLog::getSingletonPtr()->log("NativeOperate|NativePlugin|getApplicationLnkLocation[start]"); HKEY hKey; LONG nResult = 0; DWORD dwSize = 0; // 数据长度 // char* reAppPath = "C:ProgramDataMicrosoftWindowsStart MenuPrograms"; TCHAR lpSubKey[] = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"; //TCHAR lpValueName[] = "Common Programs"; nResult = RegOpenKeyEx(locType, lpSubKey, NULL, KEY_READ, &hKey); if( nResult != ERROR_SUCCESS ) { return NULL; } // 第一次调用,获取数据长度 RegQueryValueEx(hKey, lpValueName, NULL, NULL, NULL, &dwSize); // 缓冲区长度 // 动态分配缓冲区 LPBYTE dataBuf = new BYTE[dwSize]; // 第二次调用,获取数据 RegQueryValueEx(hKey, lpValueName, NULL, NULL, dataBuf, &dwSize); // 关闭 RegCloseKey(hKey); MyLog::getSingletonPtr()->log("NativeOperate|NativePlugin|getApplicationLnkLocation[end]"); // 释放缓冲区 return (char*)dataBuf; } /******************************* * 函数名:TraverseFolder * 输入参数:lpPath(路径) * 输入参数:lnk(用来保存找到的lnk文件名) * 功能遍历文件夹函数 *********************************/ bool TraverseFolder(LPCTSTR lpPath,const char* lnk) { //MyLog::getSingletonPtr()->log("NativeOperate|NativePlugin|TraverseFolder[start]"); //MyLog::getSingletonPtr()->log("NativeOperate|NativePlugin|TraverseFolder[start]--lpPath='+%s+'--lnk='+%s+'",lpPath, lnk); TCHAR szFind[MAX_PATH] = {_T("