| Prm753 |
Aug 30th, 2007 4:02 PM |
Segmentation Fault!
I keep getting a Segmentation Fault in my program and I cannot figure it out. I don't have much experience with that sort of thing, so maybe you could give me some advice.
Here is the code that seems to be generating the segfault:
:
BOOL PathExists(const char* pathtocheck)
{
struct stat St;
BOOL bRes = stat( pathtocheck, &St );
}
int IsInstalled(char *envPath, char *folderPath, int pathCheck)
{
char tempEnv[1024];
GetEnvironmentVariable(envPath, tempEnv, MAX_PATH);
strcat(tempEnv, folderPath);
// strcat(envPath, tempEnv);
// strcpy(fullPath, tempEnv);
if ( PathExists(tempEnv) == 0 )
pathCheck = 1;
// free(tempEnv);
// free(envPath);
// return pathCheck;
}
I'm calling the functions here:
:
case ID_IS_INSTALLED:
{
SendDlgItemMessage(hDlgWnd, IDC_DLG_TEXT, EM_REPLACESEL, FALSE, 0);
char buffer[MAX_PATH];
char fullPath[MAX_PATH];
char tempBuffer[1024];
int check, checkTwo, checkThree, checkFour,
checkFive, checkSix, checkSeven, checkEight,
checkNine, checkTen, checkEleven;
// HWND hwnd = GetDlgItem(hDlgWnd, IDC_DLG_TEXT);
check = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Viewpoint Media Player", check);
checkTwo = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Viewpoint Manager", checkTwo);
checkThree = IsInstalled("ALLUSERSPROFILE", "\\Viewpoint\\Viewpoint Manager", checkThree);
checkFour = IsInstalled("ALLUSERSPROFILE", "\\Viewpoint\\Viewpoint Media Player", checkFour);
checkFive = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Common", checkFive);
checkSix = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Viewpoint Experience Technology", checkSix);
checkSeven = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Viewpoint Toolbar V35", checkSeven);
checkEight = IsInstalled("PROGRAMFILES", "\\Viewpoint\\Viewpoint Toolbar", checkEight);
checkNine = IsInstalled("ALLUSERSPROFILE", "\\Viewpoint\\Viewpoint Toolbar", checkNine);
checkTen = IsInstalled("ALLUSERSPROFILE", "\\Viewpoint\\Toolbar Runtime", checkTen);
checkEleven = IsInstalled("CommonProgramFiles", "\\Viewpoint\\Toolbar Runtime", checkEleven);
strcpy(buffer, "");
strcat(buffer, "Viewpoint Media Player?\t");
if (check == 1 || checkFour == 1 || checkFive == 1 || checkSix == 1)
strcat(buffer, "YES");
else
strcat(buffer, "No");
strcat(buffer, "\r\n");
strcat(buffer, "Viewpoint Manager?\t");
if (checkTwo == 1 || checkThree == 1)
strcat(buffer, "YES");
else
strcat(buffer, "No");
strcat(buffer, "\r\n");
strcat(buffer, "Viewpoint Toolbar?\t\t");
if (checkSeven == 1 || checkEight == 1 || checkNine == 1 || checkTen == 1 || checkEleven == 1)
strcat(buffer, "YES");
else
strcat(buffer, "No");
// SetDlgItemText(hDlgWnd, IDC_DLG_TEXT, buffer);
// SetWindowText(hwnd, buffer);
SetDlgItemText(hDlgWnd, IDC_DLG_TEXT, buffer);
// free(buffer);
free(tempBuffer);
free(fullPath);
}
break;
I commented out some of those functions trying to figure out the problem. I really have no idea what to do. Some advice would be greatly appreciated. Thank you. :)
|