Yup!
And only the current process has a default directory other than root, so all other drives worked, and only the current one failed.
Case closed.
------------------
Announcement
Collapse
No announcement yet.
GetVolumeInformation
Collapse
X
-
I tried following.
Code:#Compile Exe #Register None #Dim All #Include "Win32Api.Inc" '================================ Sub CPrint (SOut As String) Static hConsole As Long, cWritten As Long If hConsole = 0 Then AllocConsole: hConsole = GetStdHandle(-11&) WriteConsole hConsole, ByCopy sOut + $CrLf, Len(sOut) + 2, cWritten, ByVal 0& End Sub '=============================== CallBack Function CB_Dlg If CbMsg = %WM_COMMAND Then CPrint "CbCtl = " + Str$(CbCtl) + " " + Time$ End Function Function PbMain Dim lpRootPathName As Asciiz * 4 lpRootPathName = "C:\" Dim lpVolumeNameBuffer As Asciiz * 12 Dim lpVolumeSerialNumber As Long Dim lpMaximumComponentLength As Long Dim lpFileSystemFlags As Long Dim lpFileSystemNameBuffer As Asciiz * 10 If GetVolumeInformation(lpRootPathName, _ lpVolumeNameBuffer, SizeOf(lpVolumeNameBuffer) - 1, _ lpVolumeSerialNumber, _ lpMaximumComponentLength, _ lpFileSystemFlags, _ lpFileSystemNameBuffer, SizeOf(lpFileSystemNameBuffer) - 1) = 0 Then CPrint "Allocation Error" Else CPrint "File System: " + lpFileSystemNameBuffer CPrint "Max name length: " + Str$(lpMaximumComponentLength) CPrint "Volume Name: " + lpVolumeNameBuffer CPrint "Serial Number:" + Hex$(lpVolumeSerialNumber) CPrint "System Flags: " + Hex$(lpFileSystemFlags) End If Sleep 3000 End Function
John --
perhaps, you specify "C:" instead of "C:\" ?
------------------
Leave a comment:
-
Here you go. Just standard stuff. I wouldn't even have questioned the version issue, except that the PB IDE is similarly sensitive to which drive you are executing from, and which drive you compile to.
SUB GetVolumeInfo ALIAS "GetVolumeInfo" (BYVAL lroot AS STRING, BYREF lvolume AS STRING, BYREF lvolserial AS LONG, BYREF lmaxlen AS LONG, lfileflags AS LONG, BYREF lfilesysname AS STRING) EXPORT
DIM lvolumebuffer AS LONG, lfilenamebuff AS LONG
DIM returnval AS LONG
'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
lvolumebuffer = 255
lvolume = SPACE$(lvolumebuffer)
lfilenamebuff = 255
lfilesysname = SPACE$(lfilenamebuff)
ON ERROR RESUME NEXT
returnval = GetVolumeInformation(lroot, lvolume, lvolumebuffer, lvolserial, lmaxlen, lfileflags, lfilesysname, lfilenamebuff)
' CALL GetVolumeInformation(sDrv & ":\", str, 256, RetVal,a, b, str2, 256)
IF returnval = 0 THEN
MSGBOX "Allocation Error on " & lroot & " - " & TRIM$(lvolume) & " - " & TRIM$(lfilesysname)
ELSE
' lvolume = stripterminator(lvolume)
' lfilesysname = stripterminator(lfilesysname)
' print "Volume Name: "; lvolume
' print "Serial Number: "; lvolserial
' print "Max name length: "; lmaxlen
' print "File System: "; lfilesysname
END IF
END SUB
------------------
Leave a comment:
-
There is no reason that an API call should *ever* work differently from one version of the "compiler" to another. Although, things can work different from one version of the "operating system" to another.
Without any sample code to review, attempting to help you would be akin to a doctor providing a diagnosis without ever seeing a patient. And I'm not covered for malpractice.
--Dave
------------------
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
Sounds very strange. Can you post the separate fragment, which not works ?
------------------
Leave a comment:
-
GetVolumeInformation
I have had an application which reads volume information for some time now, but recently, after reorganizing things around different partitions, I have run into a problem.
I can't get volume information from the drive which the PB app executes from. I don't know if this problem is new to PB6, or if I just never happened to get info on the current drive before.
Is there a reason the execution drive would be locked out? If I move the dll to a different drive it works fine (except for that drive of course).Tags: None
Leave a comment: