floppy disk volume name 
Author Message
 floppy disk volume name

Ivan,
GetVolumeInformation should do it.
---
Mike S.
Optimal Systems Corp.  www.oscorp.com
Software Dev - MSAccess and VisualBasic.
-----------------------------------------------------------------

Quote:

>Hi,

>We are writing a very small library database.

>We would like to automatically read the volume name
>from the Zip disk currently in the zip drive.

>What is the Windows API function that does this?
>Thanks.

>ivan.



Sat, 06 May 2000 03:00:00 GMT  
 floppy disk volume name

Hi,

Mike...if you can help...or anyone else...

I'm trying to use the GetVolumeInformation API call
to retrieve the volume name of a removeable disk.
But I never get any results back.

I have a floppy in drive A: whose label I can see using DOS.
Any hints on what's wrong with my code?  Is my function
declaration correct???

I test the function with a button on a form (Command0) that calls
the function VolumeName() in it's OnClick property.

Thanks,
ivan.

<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

(declarations)

Public Declare Function GetVolInfo Lib "kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
lpVolumeNameBuffer _
As String, ByVal nVolumeNameSize As Long, ByVal lpVolumeSerialNumber _
As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags
_
As Long, ByVal lpFileSystemNameBuffer As String, ByVal
nFileSystemNameSize _
As Long) As Long

<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

Public Function VolumeName()

Dim Result As String
Dim X As Long

pRootPathName = "A:\"
Result = Space$(256)
pVolumeNameSize = 256
pVolumeSerialNumber = 0
pMaximumComponentLength = 256
pFileSystemFlags = 0
pFileSystemNameBuffer = Space$(256)
pFileSystemNameSize = 256

X = GetVolInfo(pRootPathName, Result, pVolumeNameSize, _
    pVolumeSerialNumber, pMaximumComponentLength, pFileSystemFlags, _
    pFileSystemNameBuffer, pFileSystemNameSize)

MsgBox "#" & X & "#"

MsgBox "#" & Result & "#"

End Function

<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

(Button on Form)

Private Sub Command0_Click()

X = VolumeName()

End Sub

Quote:

> Ivan,
> GetVolumeInformation should do it.
> ---
> Mike S.
> Optimal Systems Corp.  www.oscorp.com
> Software Dev - MSAccess and VisualBasic.
> -----------------------------------------------------------------

> >Hi,

> >We are writing a very small library database.

> >We would like to automatically read the volume name
> >from the Zip disk currently in the zip drive.

> >What is the Windows API function that does this?
> >Thanks.

> >ivan.



Sun, 07 May 2000 03:00:00 GMT  
 floppy disk volume name

Ivan

You could use
        dir("a:\", vbVolume )
This will return the Volume Label from a floppy disk.

Hope this helps

Terry



Quote:
> Hi,

> Mike...if you can help...or anyone else...

> I'm trying to use the GetVolumeInformation API call
> to retrieve the volume name of a removeable disk.
> But I never get any results back.

> I have a floppy in drive A: whose label I can see using DOS.
> Any hints on what's wrong with my code?  Is my function
> declaration correct???

> I test the function with a button on a form (Command0) that calls
> the function VolumeName() in it's OnClick property.

> Thanks,
> ivan.

> <<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> (declarations)

> Public Declare Function GetVolInfo Lib "kernel32" Alias _
> "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
> lpVolumeNameBuffer _
> As String, ByVal nVolumeNameSize As Long, ByVal lpVolumeSerialNumber _
> As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags
> _
> As Long, ByVal lpFileSystemNameBuffer As String, ByVal
> nFileSystemNameSize _
> As Long) As Long

> <<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> Public Function VolumeName()

> Dim Result As String
> Dim X As Long

> pRootPathName = "A:\"
> Result = Space$(256)
> pVolumeNameSize = 256
> pVolumeSerialNumber = 0
> pMaximumComponentLength = 256
> pFileSystemFlags = 0
> pFileSystemNameBuffer = Space$(256)
> pFileSystemNameSize = 256

> X = GetVolInfo(pRootPathName, Result, pVolumeNameSize, _
>     pVolumeSerialNumber, pMaximumComponentLength, pFileSystemFlags, _
>     pFileSystemNameBuffer, pFileSystemNameSize)

> MsgBox "#" & X & "#"

> MsgBox "#" & Result & "#"

> End Function

> <<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> (Button on Form)

> Private Sub Command0_Click()

> X = VolumeName()

> End Sub


> > Ivan,
> > GetVolumeInformation should do it.
> > ---
> > Mike S.
> > Optimal Systems Corp.  www.oscorp.com
> > Software Dev - MSAccess and VisualBasic.
> > -----------------------------------------------------------------

> > >Hi,

> > >We are writing a very small library database.

> > >We would like to automatically read the volume name
> > >from the Zip disk currently in the zip drive.

> > >What is the Windows API function that does this?
> > >Thanks.

> > >ivan.



Sun, 07 May 2000 03:00:00 GMT  
 floppy disk volume name

Mike,

I appreciate your help.

When I run the code you posted, the value of ret is FALSE
and volname and sysname still don't get any value.

Any other suggestions???

I'm using Access '95 on Windows NT 4.0

Thanks so much...

ivan.

Quote:

> Ivan,
> Try this:

>    Dim volname As String, sysname As String, ret As Boolean
>    volname = Space(256)
>    sysname = Space(256)
>    ret = GetVolumeInformation("a:\", volname, 256, 0, 256, 0, sysname, 256)
>    MsgBox Left(volname, InStr(volname, Chr(0)) - 1)
>    MsgBox Left(sysname, InStr(sysname, Chr(0)) - 1)

> ---
> Mike S.
> Optimal Systems Corp.  www.oscorp.com
> Software Dev - MSAccess and VisualBasic.
> -----------------------------------------------------------------

> >Hi,

> >We are writing a very small library database.

> >We would like to automatically read the volume name
> >from the Zip disk currently in the zip drive.

> >What is the Windows API function that does this?
> >Thanks.

> >ivan.



Sun, 07 May 2000 03:00:00 GMT  
 floppy disk volume name

Ivan,
Try this:

   Dim volname As String, sysname As String, ret As Boolean
   volname = Space(256)
   sysname = Space(256)
   ret = GetVolumeInformation("a:\", volname, 256, 0, 256, 0, sysname, 256)
   MsgBox Left(volname, InStr(volname, Chr(0)) - 1)
   MsgBox Left(sysname, InStr(sysname, Chr(0)) - 1)

---
Mike S.
Optimal Systems Corp.  www.oscorp.com
Software Dev - MSAccess and VisualBasic.
-----------------------------------------------------------------

Quote:

>Hi,

>We are writing a very small library database.

>We would like to automatically read the volume name
>from the Zip disk currently in the zip drive.

>What is the Windows API function that does this?
>Thanks.

>ivan.



Sun, 07 May 2000 03:00:00 GMT  
 floppy disk volume name

This works

You would call this with VolName("a:\")

'************** Code Start ********************
Private Declare Function GetVolumeInformation Lib "kernel32" Alias _
    "GetVolumeInformationA" (ByVal lpRootPathName As String, _
    ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
    lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
    lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
    ByVal nFileSystemNameSize As Long) As Long

Function VolName(lpRootPathName As String) As String
  Dim lngret As Long
  Dim strRet As String
  Dim lpVolumeNameBuffer As String
  Dim nVolumeNameSize As Long

  lpVolumeNameBuffer = String$(255, 0)
  nVolumeNameSize = Len(lpVolumeNameBuffer)

  lngret = GetVolumeInformation(lpRootPathName, _
           lpVolumeNameBuffer, nVolumeNameSize, 0, _
           0, 0, vbNullString, 0)
  If lngret <> 0 Then
    strRet = Left(lpVolumeNameBuffer, InStr(lpVolumeNameBuffer,
vbNullChar) - 1)
  End If
  VolName = strRet
End Function
'************** Code Start ********************

Quote:

>Hi,

>Mike...if you can help...or anyone else...

>I'm trying to use the GetVolumeInformation API call
>to retrieve the volume name of a removeable disk.
>But I never get any results back.

>I have a floppy in drive A: whose label I can see using DOS.
>Any hints on what's wrong with my code?  Is my function
>declaration correct???

>I test the function with a button on a form (Command0) that calls
>the function VolumeName() in it's OnClick property.

>Thanks,
>ivan.

><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

>(declarations)

>Public Declare Function GetVolInfo Lib "kernel32" Alias _
>"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
>lpVolumeNameBuffer _
>As String, ByVal nVolumeNameSize As Long, ByVal lpVolumeSerialNumber _
>As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags
>_
>As Long, ByVal lpFileSystemNameBuffer As String, ByVal
>nFileSystemNameSize _
>As Long) As Long

><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

>Public Function VolumeName()

>Dim Result As String
>Dim X As Long

>pRootPathName = "A:\"
>Result = Space$(256)
>pVolumeNameSize = 256
>pVolumeSerialNumber = 0
>pMaximumComponentLength = 256
>pFileSystemFlags = 0
>pFileSystemNameBuffer = Space$(256)
>pFileSystemNameSize = 256

>X = GetVolInfo(pRootPathName, Result, pVolumeNameSize, _
>    pVolumeSerialNumber, pMaximumComponentLength, pFileSystemFlags, _
>    pFileSystemNameBuffer, pFileSystemNameSize)

>MsgBox "#" & X & "#"

>MsgBox "#" & Result & "#"

>End Function

><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

>(Button on Form)

>Private Sub Command0_Click()

>X = VolumeName()

>End Sub


>> Ivan,
>> GetVolumeInformation should do it.
>> ---
>> Mike S.
>> Optimal Systems Corp.  www.oscorp.com
>> Software Dev - MSAccess and VisualBasic.
>> -----------------------------------------------------------------

>> >Hi,

>> >We are writing a very small library database.

>> >We would like to automatically read the volume name
>> >from the Zip disk currently in the zip drive.

>> >What is the Windows API function that does this?
>> >Thanks.

>> >ivan.



Mon, 08 May 2000 03:00:00 GMT  
 floppy disk volume name

This code worked!!!

The key appears to be passing 0 as the MaximumComponentLength
when calling the API.

Thanks for all the help!!!

ivan.

Quote:

> This works

> You would call this with VolName("a:\")

> '************** Code Start ********************
> Private Declare Function GetVolumeInformation Lib "kernel32" Alias _
>     "GetVolumeInformationA" (ByVal lpRootPathName As String, _
>     ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
>     lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
>     lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
>     ByVal nFileSystemNameSize As Long) As Long

> Function VolName(lpRootPathName As String) As String
>   Dim lngret As Long
>   Dim strRet As String
>   Dim lpVolumeNameBuffer As String
>   Dim nVolumeNameSize As Long

>   lpVolumeNameBuffer = String$(255, 0)
>   nVolumeNameSize = Len(lpVolumeNameBuffer)

>   lngret = GetVolumeInformation(lpRootPathName, _
>            lpVolumeNameBuffer, nVolumeNameSize, 0, _
>            0, 0, vbNullString, 0)
>   If lngret <> 0 Then
>     strRet = Left(lpVolumeNameBuffer, InStr(lpVolumeNameBuffer,
> vbNullChar) - 1)
>   End If
>   VolName = strRet
> End Function
> '************** Code Start ********************


> >Hi,

> >Mike...if you can help...or anyone else...

> >I'm trying to use the GetVolumeInformation API call
> >to retrieve the volume name of a removeable disk.
> >But I never get any results back.

> >I have a floppy in drive A: whose label I can see using DOS.
> >Any hints on what's wrong with my code?  Is my function
> >declaration correct???

> >I test the function with a button on a form (Command0) that calls
> >the function VolumeName() in it's OnClick property.

> >Thanks,
> >ivan.

> ><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> >(declarations)

> >Public Declare Function GetVolInfo Lib "kernel32" Alias _
> >"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
> >lpVolumeNameBuffer _
> >As String, ByVal nVolumeNameSize As Long, ByVal lpVolumeSerialNumber _
> >As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags
> >_
> >As Long, ByVal lpFileSystemNameBuffer As String, ByVal
> >nFileSystemNameSize _
> >As Long) As Long

> ><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> >Public Function VolumeName()

> >Dim Result As String
> >Dim X As Long

> >pRootPathName = "A:\"
> >Result = Space$(256)
> >pVolumeNameSize = 256
> >pVolumeSerialNumber = 0
> >pMaximumComponentLength = 256
> >pFileSystemFlags = 0
> >pFileSystemNameBuffer = Space$(256)
> >pFileSystemNameSize = 256

> >X = GetVolInfo(pRootPathName, Result, pVolumeNameSize, _
> >    pVolumeSerialNumber, pMaximumComponentLength, pFileSystemFlags, _
> >    pFileSystemNameBuffer, pFileSystemNameSize)

> >MsgBox "#" & X & "#"

> >MsgBox "#" & Result & "#"

> >End Function

> ><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>

> >(Button on Form)

> >Private Sub Command0_Click()

> >X = VolumeName()

> >End Sub


> >> Ivan,
> >> GetVolumeInformation should do it.
> >> ---
> >> Mike S.
> >> Optimal Systems Corp.  www.oscorp.com
> >> Software Dev - MSAccess and VisualBasic.
> >> -----------------------------------------------------------------

> >> >Hi,

> >> >We are writing a very small library database.

> >> >We would like to automatically read the volume name
> >> >from the Zip disk currently in the zip drive.

> >> >What is the Windows API function that does this?
> >> >Thanks.

> >> >ivan.



Mon, 08 May 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Name of volume disk And Icon's Path

2. Floppy disk to disk copy?

3. Diskette's properties in Floppy Disk

4. Format Floppy disk using VB

5. Floppy disk detect

6. Backup to Floppy Disk

7. Insert Floppy disk MSDN ???

8. Floppy Disk / Setup.EXE BUg In Service Pack 5

9. spanning floppy disks when making a backup

10. Format a floppy disk

11. Formatting A Floppy Disk With NT 4 (How)

12. Ejecting floppy disk from code

 

 
Powered by phpBB® Forum Software