void BumpStatus( long by ) /************************/ { if( !IsPatch ) { // if a patch, don't change status because denominator of status // fraction is the number of operations, not a number of bytes StatusAmount( Parts_Complete + by, Parts_Injob ); } }
static bool UseDDE( bool uninstall ) /**********************************/ { WORD dir_index, icon_number, version; int i, num_icons, num_groups; int num_installed, num_total_install; int len; DWORD temp; bool ok; char prog_name[_MAX_PATH], prog_desc[_MAX_PATH]; char icon_name[_MAX_PATH], working_dir[_MAX_PATH]; char buff[_MAX_PATH], t1[_MAX_PATH], t2[_MAX_PATH]; HWND hwnd_pm; DWORD ddeinst = 0; // Important that this is initially 0 UINT rc; HSZ happ, htopic; HCONV hconv; char progman[] = "PROGMAN"; SimGetPMGroup( t1 ); if( t1[ 0 ] == '\0' ) { return( TRUE ); } // Initiate a conversation with the Program Manager. // NOTE: No callback provided since we only issue execute commands rc = DdeInitialize( &ddeinst, NULL, APPCMD_CLIENTONLY, 0L ); if( rc != 0 ) { return( FALSE ); } happ = DdeCreateStringHandle( ddeinst, progman, CP_WINANSI ); htopic = DdeCreateStringHandle( ddeinst, progman, CP_WINANSI ); hconv = DdeConnect( ddeinst, happ, htopic, NULL ); if( hconv == (HCONV)NULL ) { return( FALSE ); } // Disable the Program Manager so that the user can't work with it // while we are doing our stuff. hwnd_pm = FindWindow( progman, NULL ); if( hwnd_pm != NULL ) { ShowWindow( hwnd_pm, SW_RESTORE ); EnableWindow( hwnd_pm, FALSE ); } if( uninstall ) { // Delete the PM Group box num_groups = SimGetNumPMGroups(); for( i = 0; i < num_groups; i++ ) { SimGetPMGroupName( i, t1 ); if( *t1 != '\0' ) { // Delete the PM Group box sprintf( buff, "[DeleteGroup(%s)]", t1 ); ok = SendCommand( ddeinst, hconv, buff ); } } goto cleanup; // I can't believe I'm doing this } else { // Delete the PM Group box to get rid of stale icons // (Don't do this for SQL install, since user may install // the server, and then install the client) sprintf( buff, "[DeleteGroup(%s)]", t1 ); ok = SendCommand( ddeinst, hconv, buff ); // re-Create the PM Group box. SimGetPMGroupFileName( t2 ); if( t2[ 0 ] == '\0' ) { #if defined( __NT__ ) sprintf( buff, "[CreateGroup(%s,0)]", t1 ); // create a personal group #else sprintf( buff, "[CreateGroup(%s)]", t1 ); #endif } else { sprintf( buff, "[CreateGroup(%s,%s)]", t1, t2 ); } ok = SendCommand( ddeinst, hconv, buff ); } // Add the individual PM files to the Group box. num_icons = SimGetNumPMProgs(); StatusLines( STAT_CREATEPROGRAMFOLDER, "" ); num_total_install = 0; for( i = 0; i < num_icons; i++ ) { if( SimCheckPMCondition( i ) ) { ++num_total_install; } } num_installed = 0; StatusAmount( 0, num_total_install ); for( i = 0; ok && ( i < num_icons ); i++ ) { if( !SimCheckPMCondition( i ) ) { continue; } SimGetPMDesc( i, prog_desc ); dir_index = SimGetPMProgName( i, prog_name ); if( strcmp( prog_name, "GROUP" ) == 0 ) { // Delete the PM Group box to get rid of stale icons sprintf( buff, "[DeleteGroup(%s)]", prog_desc ); ok = SendCommand( ddeinst, hconv, buff ); /* creating a new group */ SimGetPMParms( i, t1 ); if( t1[ 0 ] == '\0' ) { #if defined( __NT__ ) sprintf( buff, "[CreateGroup(%s,0)]", prog_desc ); // create a personal group #else sprintf( buff, "[CreateGroup(%s)]", prog_desc ); #endif } else { sprintf( buff, "[CreateGroup(%s,%s)]", prog_desc, t1 ); } } else { /* adding item to group */ if( dir_index == SIM_INIT_ERROR ) { working_dir[0] = '\0'; ReplaceVars( t2, prog_name ); strcpy( prog_name, t2 ); } else { SimDirNoSlash( dir_index, working_dir ); } // get parameters SimGetPMParms( i, t1 ); if( t1[0] != '\0' ) { // add parameters to end of prog_name len = strlen( prog_name ); prog_name[len] = ' '; ReplaceVars( &prog_name[len + 1], t1 ); } // Append the subdir where the icon file is and the icon file's name. temp = SimGetPMIconInfo( i, icon_name ); dir_index = LOWORD( temp ); icon_number = HIWORD( temp ); if( icon_number == SIM_INIT_ERROR ) { icon_number = 0; } if( dir_index != SIM_INIT_ERROR ) { SimGetDir( dir_index, t1 ); strcat( t1, icon_name ); strcpy( icon_name, t1 ); } // Add the new file to the already created PM Group. version = (WORD)GetVersion(); if( (LOBYTE( version ) > 3) || // Version 3.1 or higher (LOBYTE( version ) == 3 && HIBYTE( version ) > 0) ) { sprintf( buff, "[ReplaceItem(%s)]", prog_desc ); SendCommand( ddeinst, hconv, buff ); sprintf( buff, "[AddItem(%s,%s,%s,%d,-1,-1,%s)]", prog_name, prog_desc, icon_name, icon_number, working_dir ); } else { sprintf( buff, "[AddItem(%s%s,%s,%s,%d)]", working_dir, prog_name, prog_desc, icon_name, icon_number ); } } ok = SendCommand( ddeinst, hconv, buff ); ++num_installed; StatusAmount( num_installed, num_total_install ); if( StatusCancelled() ) break; } StatusAmount( num_total_install, num_total_install ); cleanup: // Terminate the DDE conversation with the Program Manager. DdeFreeStringHandle( ddeinst, happ ); DdeFreeStringHandle( ddeinst, htopic ); // DdeDisconnect( hconv ); // win95 setup was crashing on ddeuninitialize //(only if running from CD)removing this call seems to be an OK workaround DdeUninitialize( ddeinst ); if( hwnd_pm != NULL ) { EnableWindow( hwnd_pm, TRUE ); } return( ok ); }
static bool UseIShellLink( bool uninstall ) /*****************************************/ { WORD dir_index, icon_number; int i, num_icons, num_groups; int num_installed, num_total_install; DWORD temp; char prog_name[_MAX_PATH], prog_desc[_MAX_PATH]; char icon_name[_MAX_PATH], working_dir[_MAX_PATH]; char group[_MAX_PATH], prog_arg[_MAX_PATH], tmp[_MAX_PATH]; BOOL rc; if( uninstall ) { num_groups = SimGetNumPMGroups(); for( i = 0; i < num_groups; i++ ) { SimGetPMGroupName( i, group ); if( *group != '\0' ) { // Delete the PM Group box remove_group( group ); } } return( TRUE ); } SimGetPMGroup( group ); if( group[0] == '\0' ) { return( TRUE ); } CoInitialize( NULL ); // Create the PM Group box. if( !create_group( group ) ) { CoUninitialize(); return( FALSE ); } // Add the individual PM files to the Group box. num_icons = SimGetNumPMProgs(); StatusLines( STAT_CREATEPROGRAMFOLDER, "" ); num_total_install = 0; for( i = 0; i < num_icons; i++ ) { if( SimCheckPMCondition( i ) ) { ++num_total_install; } } num_installed = 0; StatusAmount( 0, num_total_install ); for( i = 0; i < num_icons; i++ ) { if( !SimCheckPMCondition( i ) ) { continue; } SimGetPMDesc( i, prog_desc ); dir_index = SimGetPMProgName( i, prog_name ); if( strcmp( prog_name, "GROUP" ) == 0 ) { /* creating a new group */ strcpy( group, prog_desc ); if( !create_group( group ) ) { CoUninitialize(); return( FALSE ); } } else { // Adding item to group if( dir_index == SIM_INIT_ERROR ) { working_dir[ 0 ] = '\0'; ReplaceVars( tmp, prog_name ); strcpy( prog_name, tmp ); } else { SimDirNoSlash( dir_index, working_dir ); } // Get parameters SimGetPMParms( i, tmp ); ReplaceVars( prog_arg, tmp ); // Append the subdir where the icon file is and the icon file's name. temp = SimGetPMIconInfo( i, icon_name ); dir_index = LOWORD( temp ); icon_number = HIWORD( temp ); if( icon_number == SIM_INIT_ERROR ) icon_number = 0; if( dir_index != SIM_INIT_ERROR ) { SimGetDir( dir_index, tmp ); strcat( tmp, icon_name ); strcpy( icon_name, tmp ); } // Add the new file to the already created PM Group. rc = create_icon( group, prog_name, prog_desc, prog_arg, working_dir, icon_name, icon_number ); if( rc == FALSE ) { CoUninitialize(); return( FALSE ); } } ++num_installed; StatusAmount( num_installed, num_total_install ); if( StatusCancelled() ) break; } StatusAmount( num_total_install, num_total_install ); CoUninitialize(); return( TRUE ); }