Changeset 1580 for trunk/gsinstaller
- Timestamp:
- 2000-10-04T04:47:02+13:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/gsProgman.cpp
r1547 r1580 175 175 176 176 if (this->platform->isExplorerShell()) 177 178 179 180 181 182 {177 { 178 // add using shell controls 179 LPITEMIDLIST pidl; 180 181 if (this->platform->isUserAdministrator()) 182 { 183 183 #if defined (__GNUC__) 184 184 // 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) 186 186 #else 187 if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)187 if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 188 188 #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 } 193 211 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 } 214 217 else 215 218 { … … 300 303 301 304 // store the link in the "persistent" file 302 reply = ppf->Save(wsz, TRUE);303 304 305 305 reply = (ppf->Save(wsz, TRUE) != E_FAIL); 306 307 // release the persistent file handle 308 ppf->Release(); 306 309 } 307 310 psl->Release(); … … 310 313 } 311 314 else 312 { 315 { 313 316 // Back to the dark ages with win 3.1! 314 317 … … 402 405 403 406 if (this->platform->isExplorerShell()) 404 405 406 407 408 409 410 411 412 413 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 { 415 418 #if defined (__GNUC__) 416 // this is a hack as windows port of gcc doesn't have CSIDL_COMMON_PROGRAMS defined417 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) 418 421 #else 419 if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR)422 if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 420 423 #endif 421 424 { 422 425 return false; 423 426 } 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 } 466 468 return reply; 467 469 }
Note:
See TracChangeset
for help on using the changeset viewer.