Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to detect cdrom?
Message
From
10/03/1999 06:23:37
 
 
To
10/03/1999 04:52:57
Jack Lee
Wheel Giant Inc.
Changhua, Taiwan
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00195747
Message ID:
00195753
Views:
28
>Hi All.
>
>I've seen someone paste how to do this ever, but maybe I'm missing something, The code is:
>

You're missing the DECLARE fro GetDriveType

DECLARE INTEGER GetDriveType IN Win32API STRING lpRootPathName


>*****************
>DECLARE INTEGER GetLogicalDrives IN Win32API
>IF NOT "6." $ VERSION()
> SET LIBRARY TO FOXTOOLS ADDITIVE
>ENDIF
>llfound = .F.
>lni = 0
>lnlast = 25
>STORE "" TO lcresult, lcdrive
>lndrives = GetLogicalDrives()
>DO WHILE NOT llfound AND lni < lnlast
> IF BITTEST(lndrives, lni)
> lcdrive = CHR(65 + lni)
> llfound = (GetDriveType(lcdrive) = 5)
> ENDIF
> lni = lni + 1
>ENDDO
>IF llfound
> lcresult = lcdrive
>ENDIF
>RETURN lcresult
>********************
>
>I got an error message "File: GetDriveType.prg does not exist" in VFP 6. Anybody tell me I'm missing?
>

I know it's heresy, but you can do this without FoxTools:
DECLARE INTEGER GetDriveType IN Win32API ;
   STRING @ lpRootPathName
DECLARE INTEGER GetLogicalDriveStrings IN WIN32API ;
   INTEGER nLength, ;
   STRING @ lpBuffer

LOCAL cBuffer, nLength, nResult, cTest, cCDROM
cBuffer = SPACE(2000)
nLength = GetLogicalDriveStrings(2000,@cBuffer)
cCDROM = NULL
IF nLength > 0
   IF nLength > 2000
      cBuffer = SPACE(nLength + 1)
      nLength = GetLogicalDriveStrings(nLength,@cBuffer)
   ENDIF
   cBuffer = LEFT(cBuffer, nLength)
   DO WHILE LEN(cBuffer) > 0
      nLength = AT(CHR(0), cBuffer)
      IF nLength # 0
         cTest = LEFT(cBuffer,nLength-1)
         cTest = IIF(LEN(cBuffer) > nLength, SUBST(cBuffer,nLength + 1), '')
      ELSE
         cTest = cBuffer
         cBuffer = ''
      ENDIF
      IF GetDriveType(cTest) = 5
         cCDROM = IIF(ISNULL(cCDROM),'',cCDROM +';') + cTest
      ENDIF
   ENDDO
ENDIF
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform