home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advos2 / ch09 / volname.asm < prev    next >
Encoding:
Assembly Source File  |  1988-12-12  |  5.8 KB  |  148 lines

  1.         title   VOLNAME - displays volume label
  2.         page    55,132
  3.         .286
  4. ; VOLNAME.ASM --- displays volume label for current drive,
  5. ;                 demonstrates use of DosQFSInfo.
  6. ; Copyright (C) October 1986 Ray Duncan 
  7. ;
  8. ; Build:        MASM VOLNAME;
  9. ;               LINK VOLNAME,,,OS2,VOLNAME;
  10. ;
  11. ; Usage:        VOLNAME
  12.  
  13. stdin   equ     0                       ; standard input handle
  14. stdout  equ     1                       ; standard output handle
  15. stderr  equ     2                       ; standard error handle
  16.  
  17. cr      equ     0dh                     ; ASCII carriage return
  18. lf      equ     0ah                     ; ASCII line feed
  19.  
  20.         extrn   DosExit:far             ; references to OS/2 API
  21.         extrn   DosQCurDisk:far
  22.         extrn   DosQFSInfo:far  
  23.         extrn   DosWrite:far
  24.  
  25. _vlinfo struc                           ; volume label structure
  26. date    dw      ?                       ; date of creation      
  27. time    dw      ?                       ; time of creation
  28. count   db      ?                       ; length of volume label
  29. vname   db      13 dup (?)              ; volume label text
  30. _vlinfo ends
  31.  
  32. DGROUP  group   _DATA
  33.  
  34. _DATA   segment word public 'DATA'
  35.  
  36. wlen    dw      ?                       ; receives bytes written
  37.  
  38. vlinf   _vlinfo <>                      ; volume label info
  39. vlinf_len equ $-vlinf
  40.  
  41. drive   dw      0                       ; receives drive ID
  42. drvmap  dd      0                       ; receives drive bitmap
  43.  
  44. msg1    db      cr,lf,'Volume in drive '
  45. msg1a   db      'X has no label.',cr,lf
  46. msg1_length equ $-msg1
  47.  
  48. msg2    db      cr,lf
  49. msg2_length equ $-msg2
  50.  
  51. msg3    db      cr,lf,'Volume in drive ' 
  52. msg3a   db      'X is '
  53. msg3_length equ $-msg3
  54.  
  55. _DATA   ends
  56.  
  57.  
  58. _TEXT   segment word public 'CODE'
  59.  
  60.         assume  cs:_TEXT,ds:DGROUP
  61.  
  62. volname proc    far                     ; entry point from OS/2
  63.                                 
  64.                                         ; get current drive...
  65.         push    ds                      ; receives drive code
  66.         push    offset DGROUP:drive
  67.         push    ds                      ; receives bitmap for
  68.         push    offset DGROUP:drvmap    ; available drives
  69.         call    DosQCurDisk             ; transfer to OS/2
  70.         or      ax,ax                   ; did function succeed?
  71.         jz      vol1                    ; yes, proceed
  72.         jmp     vol5                    ; exit if function failed
  73.  
  74. vol1:   mov     al,'A'-1                ; convert drive code to
  75.         add     ax,drive                ; ASCII letter and store
  76.         mov     msg3a,al                ; for output
  77.         mov     msg1a,al
  78.  
  79.                                         ; get volume label...
  80.         push    0                       ; drive = default
  81.         push    2                       ; file info level 2
  82.         push    ds                      ; buffer receives volume
  83.         push    offset DGROUP:vlinf     ; date, time, and name
  84.         push    vlinf_len               ; size of buffer
  85.         call    DosQFSInfo              ; transfer to OS/2
  86.         or      ax,ax                   ; call successful?
  87.         jnz     vol2                    ; jump, got volume label
  88.                                         
  89.         cmp     vlinf.count,0           ; null string?
  90.         jne     vol3                    ; no, go display label
  91.  
  92. vol2:                                   ; volume has no label...
  93.         push    stdout                  ; standard output handle
  94.         push    ds                      ; message address
  95.         push    offset DGROUP:msg1
  96.         push    msg1_length             ; message length
  97.         push    ds                      ; receives actual bytes written
  98.         push    offset DGROUP:wlen
  99.         call    DosWrite                ; transfer to OS/2
  100.         jmp     vol4                    ; now eixt
  101.  
  102. vol3:                                   ; display initial message...
  103.         push    stdout                  ; standard output handle
  104.         push    ds                      ; message address
  105.         push    offset DGROUP:msg3
  106.         push    msg3_length             ; message length
  107.         push    ds                      ; receives actual bytes written
  108.         push    offset DGROUP:wlen      
  109.         call    DosWrite                ; transfer to OS/2
  110.  
  111.                                         ; display actual volume label...
  112.         push    stdout                  ; standard output handle
  113.         push    ds                      ; label address
  114.         push    offset DGROUP:vlinf.vname
  115.         mov     al,vlinf.count          ; label length
  116.         xor     ah,ah
  117.         push    ax
  118.         push    ds                      ; receives bytes written
  119.         push    offset DGROUP:wlen
  120.         call    DosWrite                ; transfer to OS/2
  121.  
  122.                                         ; output CR-LF sequence...
  123.         push    stdout                  ; standard output handle
  124.         push    ds                      ; address of CR-LF
  125.         push    offset DGROUP:msg2
  126.         push    msg2_length             ; length of CR-LF
  127.         push    ds                      ; receives bytes written
  128.         push    offset DGROUP:wlen
  129.         call    DosWrite                ; transfer to OS/2
  130.  
  131. vol4:                                   ; success exit point...
  132.         push    1                       ; terminate all threads
  133.         push    0                       ; return code=0 (success)
  134.         call    DosExit                 ; transfer to OS/2
  135.  
  136. vol5:                                   ; error exit point...
  137.         push    1                       ; terminate all threads
  138.         push    1                       ; return code=1 (error)
  139.         call    DosExit                 ; transfer to OS/2
  140.  
  141. volname endp
  142.  
  143. _TEXT   ends
  144.  
  145.         end     volname
  146.  
  147.