Creating drive objects

[Autolink] Menu

Captured from a message in a public CompuServe Forum
Author: Dick Goran, (see EMail Addresses)

 
/* TEST210.CMD - Build drives objects on the Desktop */
/* /----------------------------------\              */
/* |  WARNING - drives objects are    |              */
/* |  neither deletable nor shredable |              */
/* | --- the following was added ---  |              */
/* |        Bernd Schemmer            |              */
/* |  You need BlackHole or a similar |              */
/* |  tool to delete drive objects.   |              */
/* \----------------------------------/              */
/*                                                   */

  call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"
  call SysLoadFuncs

  boot_drive    = LEFT( VALUE( "RUNWORKPLACE",, "OS2ENVIRONMENT" ), 2 )
  drive_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  local_drives  = SysDriveMap( "A", "LOCAL" )

  floppy_resource      = "32 " || boot_drive || "\OS2\DLL\PMWP.DLL;"
  local_disk_resource  = "13 " || boot_drive || "\OS2\DLL\PMWP.DLL;"
  remote_disk_resource = "16 " || boot_drive || "\OS2\DLL\PMWP.DLL;"

  location   = "<WP_DESKTOP>"
  class      = "WPDISK"
  title      = "Test object^for drive "

  new_drives = "E"                  /* may contain any number of drives */

  do d = 1 to WORDS( new_drives )

    drive_letter =,
      WORD( new_drives, d )
    drive_number =,
      POS( drive_letter, drive_letters )


    setup_string =,
      "DRIVENUM=" || drive_number  || ";"

    select
      when ( drive_number = 1 ) | ( drive_number = 2 ) then
      do
        setup_string =,
               setup_string || "ICONRESOURCE=" || floppy_resource
      end /* when */

      when drive_number <= WORDS( local_drives ) then
      do
        setup_string =,
               setup_string || "ICONRESOURCE=" || local_disk_resource
      end /* when */

      otherwise
      do
        setup_string =,
               setup_string || "ICONRESOURCE=" || remote_disk_resource
      end /* otherwise */
    end /* select */

    setup_string =,
      setup_string ||,
      "OBJECTID=<New drive " || drive_letter || " object>;"

    call SysCreateObject class,,
                        title || drive_letter,,
                        location,,
                        setup_string,,
                        "R"
    if RESULT <> 1 then
    do
      say "   Unable to crea object for drive" drive_letter
    end /* if RESULT <> 1 then */

  end /* do d = 1 to ... */


[Back: Hints for Creating & Changing objects ...]
[Next: Creating shadows of drive objects]