Changeset 1580


Ignore:
Timestamp:
2000-10-04T04:47:02+13:00 (24 years ago)
Author:
cs025
Message:

Fixed fault in detection of success in adding items.
This resulted in the failure to log such actions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/gsProgman.cpp

    r1547 r1580  
    175175
    176176  if (this->platform->isExplorerShell())
    177     {
    178       // add using shell controls
    179       LPITEMIDLIST pidl;
    180      
    181       if (this->platform->isUserAdministrator())
    182     {
     177  {
     178    // add using shell controls
     179    LPITEMIDLIST pidl;
     180
     181    if (this->platform->isUserAdministrator())
     182    {
    183183#if defined (__GNUC__)
    184184      // this is a hack as windows port of gcc doesn't have CSIDL_COMMON_PROGRAMS defined
    185       if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
     185        if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
    186186#else
    187       if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)
     187        if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)
    188188#endif
    189         {   
    190           return false;
    191         }
    192     }
     189        {
     190          return false;
     191        }
     192      }
     193    else
     194      {
     195        if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
     196        {
     197          return false;
     198        }
     199      }
     200    SHGetPathFromIDList(pidl, buffer);
     201
     202    // Create the folder as required
     203    FilePath *path = new FilePath(buffer, groupName);
     204    if (!CreateDirectory((char *) path->cString(), NULL))
     205      {
     206        // it probably existed already - if so skip it!
     207        DWORD reason = GetLastError();
     208      if (reason == ERROR_ALREADY_EXISTS)
     209      { return true;
     210      }
    193211      else
    194     {
    195       if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
    196         {
    197           return false;
    198         }
    199     }
    200       SHGetPathFromIDList(pidl, buffer);
    201 
    202       // Create the folder as required
    203       FilePath *path = new FilePath(buffer, groupName);
    204       if (!CreateDirectory((char *) path->cString(), NULL))
    205     {
    206       // it probably existed already - if so skip it!
    207       DWORD reason = GetLastError();
    208       if (reason != ERROR_ALREADY_EXISTS)
    209         {
    210           return false;
    211         }
    212     }
    213     }
     212      { return false;
     213      }
     214    }
     215      delete path;
     216  }
    214217  else
    215218    {
     
    300303
    301304          // store the link in the "persistent" file
    302           reply = ppf->Save(wsz, TRUE);
    303          
    304           // release the persistent file handle
    305           ppf->Release();
     305        reply = (ppf->Save(wsz, TRUE) != E_FAIL);
     306
     307          // release the persistent file handle
     308        ppf->Release();
    306309        }
    307310      psl->Release();
     
    310313    }
    311314  else
    312     {   
     315    {
    313316      // Back to the dark ages with win 3.1!
    314317     
     
    402405
    403406  if (this->platform->isExplorerShell())
    404     {
    405       // create item using the shell
    406       LPITEMIDLIST pidl;
    407       //      HRESULT hres;
    408       //      IShellLink * psl;
    409       FilePath * fullPath;
    410 
    411       // if the user is adminstrator, take the folder from the common programs folder
    412       // (in the "All Users" profile)
    413       if (this->platform->isUserAdministrator())
    414     {
     407  {
     408    // create item using the shell
     409    LPITEMIDLIST pidl;
     410    //      HRESULT hres;
     411    //      IShellLink * psl;
     412    FilePath * fullPath;
     413
     414    // if the user is adminstrator, take the folder from the common programs folder
     415    // (in the "All Users" profile)
     416    if (this->platform->isUserAdministrator())
     417    {
    415418#if defined (__GNUC__)
    416       // this is a hack as windows port of gcc doesn't have CSIDL_COMMON_PROGRAMS defined
    417       if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
     419        // this is a hack as windows port of gcc doesn't have CSIDL_COMMON_PROGRAMS defined
     420        if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
    418421#else
    419       if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)
     422        if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)
    420423#endif
    421424        {
    422425          return false;
    423426        }
    424     }
    425       // otherwise get it from the user's own programs folder in their profile
    426       else
    427     {
    428       if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
    429         {
    430           return false;
    431         }
    432     }
    433 
    434       // get path of folder from shell
    435       SHGetPathFromIDList(pidl, buffer);
    436      
    437       // delete file
    438       fullPath = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), "!.lnk");
    439       if (!DeleteFile(fullPath->cString()))
    440     {
    441       reply = false;
    442     }
    443       delete fullPath;
    444     }
    445   else
    446     {
    447       // Back to the dark ages with win 3.1!
    448 
    449       // ensure that the requisite group is active; the add icon command will
    450       // use the active group.
    451       sprintf(buffer, "[ShowGroup(%s,5)]", groupName.c_str());
    452       if (!DDEShellCommand(this->instance, buffer))
    453     {
    454       // TODO: articulate/determine possible errors; expand error handling
    455       return false;
    456     }
    457 
    458       // and now add the item itself to the active (given) group
    459       sprintf(buffer, "[DeleteItem(%s)]", iconName.c_str());
    460       if (!DDEShellCommand(this->instance, buffer))
    461     {
    462       // TODO: again work out what the problems could be
    463       return false;
    464     }
    465     }
     427      }
     428    // otherwise get it from the user's own programs folder in their profile
     429    else
     430      {
     431        if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR)
     432      {
     433          return false;
     434        }
     435      }
     436
     437    // get path of folder from shell
     438        SHGetPathFromIDList(pidl, buffer);
     439
     440    // delete file
     441    fullPath    = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), "!.lnk");
     442        if (!DeleteFile(fullPath->cString()))
     443    { reply = false;
     444        }
     445    delete fullPath;
     446  }
     447  else
     448  {
     449    // Back to the dark ages with win 3.1!
     450
     451    // ensure that the requisite group is active; the add icon command will
     452    // use the active group.
     453    sprintf(buffer, "[ShowGroup(%s,5)]", groupName.c_str());
     454    if (!DDEShellCommand(this->instance, buffer))
     455    {
     456        // TODO: articulate/determine possible errors; expand error handling
     457        return false;
     458      }
     459
     460    // and now add the item itself to the active (given) group
     461    sprintf(buffer, "[DeleteItem(%s)]", iconName.c_str());
     462    if (!DDEShellCommand(this->instance, buffer))
     463      {
     464        // TODO: again work out what the problems could be
     465        return false;
     466      }
     467  }
    466468  return reply;
    467469}
Note: See TracChangeset for help on using the changeset viewer.