updated the way vpc generating guid

This commit is contained in:
Fisual
2021-12-12 16:52:07 +07:00
parent 5008a489ae
commit 0fe2cfa99f
4 changed files with 27 additions and 41 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -36,72 +36,58 @@ public:
HKEY hKey; HKEY hKey;
int firstVer = 8; int firstVer = 8;
const int lastVer = 17; // Handle up to VS 17, AKA VS 2022 const int lastVer = 17; // Handle up to VS 17, AKA VS 2022
if ( g_pVPC->Is2010() ) if (g_pVPC->Is2010())
{ {
firstVer = 10; firstVer = 10;
} }
else if ( g_pVPC->BUse2008() ) for (int vsVer = firstVer; vsVer <= lastVer; ++vsVer)
{ {
firstVer = 9;
}
for ( int vsVer = firstVer; vsVer <= lastVer; ++vsVer )
{
// Handle both VisualStudio and VCExpress (used by some SourceSDK customers) // Handle both VisualStudio and VCExpress (used by some SourceSDK customers)
RegStartPoint searchPoints[] = const char* productName[] =
{ {
{ HKEY_LOCAL_MACHINE, "Software\\Microsoft\\VisualStudio\\%d.0\\Projects" }, // Visual Studio Professional "VisualStudio",
{ HKEY_LOCAL_MACHINE, "Software\\Microsoft\\VCExpress\\%d.0\\Projects" }, // VC Express 2010 and 2012 "VCExpress",
{ HKEY_CURRENT_USER, "Software\\Microsoft\\WDExpress\\%d.0_Config\\Projects" }, // WinDev Express -- VS Express starting with VS 2013
}; };
for ( int j = 0; j < ARRAYSIZE(searchPoints); ++j ) for (int productNumber = 0; productNumber < ARRAYSIZE(productName); ++productNumber)
{ {
RegStartPoint& searchPoint = searchPoints[ j ];
char pRegKeyName[1000]; char pRegKeyName[1000];
V_snprintf( pRegKeyName, ARRAYSIZE(pRegKeyName), searchPoint.baseDir, vsVer ); V_snprintf(pRegKeyName, ARRAYSIZE(pRegKeyName), "Software\\Microsoft\\%s\\%d.0\\Projects", productName[productNumber], vsVer);
LONG ret = RegOpenKeyEx( searchPoint.baseKey, pRegKeyName, 0, KEY_READ, &hKey ); LONG ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, pRegKeyName, 0, KEY_READ, &hKey);
if ( ret != ERROR_SUCCESS ) //if ( ret != ERROR_SUCCESS )
g_pVPC->VPCError( "Unable to open registry key %s.", pRegKeyName ); // g_pVPC->VPCError( "Unable to open registry key %s.", pRegKeyName );
for ( int i=0; i < 200; i++ ) for (int i = 0; i < 200; i++)
{ {
char szKeyName[MAX_PATH]; char szKeyName[MAX_PATH];
DWORD dwKeyNameSize = sizeof( szKeyName ); DWORD dwKeyNameSize = sizeof(szKeyName);
ret = RegEnumKeyEx( hKey, i, szKeyName, &dwKeyNameSize, NULL, NULL, NULL, NULL ); ret = RegEnumKeyEx(hKey, i, szKeyName, &dwKeyNameSize, NULL, NULL, NULL, NULL);
if ( ret == ERROR_NO_MORE_ITEMS ) if (ret == ERROR_NO_MORE_ITEMS)
break; break;
HKEY hSubKey; HKEY hSubKey;
LONG ret = RegOpenKeyEx( hKey, szKeyName, 0, KEY_READ, &hSubKey ); LONG ret = RegOpenKeyEx(hKey, szKeyName, 0, KEY_READ, &hSubKey);
if ( ret == ERROR_SUCCESS ) if (ret == ERROR_SUCCESS)
{ {
DWORD dwType; DWORD dwType;
char ext[MAX_PATH]; char ext[MAX_PATH];
DWORD dwExtLen = sizeof( ext ); DWORD dwExtLen = sizeof(ext);
ret = RegQueryValueEx( hSubKey, "DefaultProjectExtension", NULL, &dwType, (BYTE*)ext, &dwExtLen ); ret = RegQueryValueEx(hSubKey, "DefaultProjectExtension", NULL, &dwType, (BYTE*)ext, &dwExtLen);
RegCloseKey( hSubKey ); RegCloseKey(hSubKey);
// VS 2012 and beyond has the DefaultProjectExtension as vcxproj instead of vcproj // VS 2012 and beyond has the DefaultProjectExtension as vcxproj instead of vcproj
if ( ret == ERROR_SUCCESS && dwType == REG_SZ && ( V_stricmp( ext, "vcproj" ) == 0 || V_stricmp( ext, "vcxproj" ) == 0 ) ) if (ret == ERROR_SUCCESS && dwType == REG_SZ && (V_stricmp(ext, "vcproj") == 0 || V_stricmp(ext, "vcxproj") == 0))
{ {
V_strncpy( szSolutionGUID, szKeyName, ARRAYSIZE(szSolutionGUID) ); V_strncpy(szSolutionGUID, szKeyName, ARRAYSIZE(szSolutionGUID));
RegCloseKey( hKey ); RegCloseKey(hKey);
return; return;
} }
} }
} }
RegCloseKey( hKey ); RegCloseKey(hKey);
} }
//{
// char szKeyName[MAX_PATH];
// DWORD dwKeyNameSize = sizeof(szKeyName);
// V_strncpy(szSolutionGUID, szKeyName, ARRAYSIZE(szSolutionGUID));
// return;
//}
} }
g_pVPC->VPCError( "Unable to find RegKey for .vcproj or .vcxproj files in solutions." ); g_pVPC->VPCError("Unable to find RegKey for .vcproj or .vcxproj files in solutions.");
} }
virtual void GenerateSolutionFile( const char *pSolutionFilename, CUtlVector<CDependency_Project*> &projects ) virtual void GenerateSolutionFile( const char *pSolutionFilename, CUtlVector<CDependency_Project*> &projects )