Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connected to Network
Message
From
10/10/1998 13:21:42
 
 
To
10/10/1998 09:41:29
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00144975
Message ID:
00145684
Views:
33
>>* GetLogicalDriveStrings
>>DECLARE INTEGER GetLogicalDriveStrings IN Win32API;
>> INTEGER lnbufferlength, STRING @lcbuffer
>>lcbuffer = SPACE(105)
>>lnresult = GetLogicalDriveStrings(105, @lcbuffer)
>>lcbuffer = LEFT(lcbuffer, lnresult)
>>lndrives = OCCURS(CHR(0), lcbuffer)
>>lnstart = 1
>>FOR lni = 1 TO lndrives
>> ? SUBSTR(lcbuffer, lnstart, 3)
>> lnstart = AT(CHR(0), lcbuffer, lni) + 1
>>NEXT
>>hth,
>
>I've taken this and included into a function of mine (your name is mentioned, if you can recognize it :). Being a FoxTools freak, simply had to replace AT() with WordNum(), but, alas (I'm not advertising my company here!), it doesn't take chr(0) as a word delimiter, so it looks like this:
>
>_diskovi=""
>_delim=""
>* Džordž Tasker, 9.10.98
>* GetLogicalDriveStrings
>DECLARE INTEGER GetLogicalDriveStrings IN Win32API;
> INTEGER lnbufferlength, STRING @lcbuffer
>lcbuffer = SPACE(105)
>lnresult = GetLogicalDriveStrings(105, @lcbuffer)
>lcbuffer = LEFT(lcbuffer, lnresult)
>lcBuffer=ChrTran(lcBuffer,chr(0), chr(1))
>for i=1 to words(lcBuffer, chr(1))
> _diskovi=_diskovi+_delim+WordNum(lcBuffer, i, chr(1))
> _delim=";"
>endfor
>retu _diskovi
>
>
>BTW, what's the scope of Declare API command? For how long does an API function stay declared, and if it remains, when should it be unloaded? I've seen some people here clearing them out, but it seems to have only CLEAR DLLS which clearse them ALL out, unlike other CLEAR commands which know how to be selective.

And then, for the Wscript-enabled among us, there's:
oWshNet = CREATEOBJ('Wscript.Network')
oNetDrives = oWshNet.EnumNetworkDrives
DECLARE aNetDrives[1,2], nNetDriveCount, i
nNetDriveCount = 0
aNetDrives = ''
*   Items occur in pairs, and item number starts at 0
FOR i = 0 TO oNetDrives.Count - 1 STEP 2
    nNetDriveCount = nNetDriveCount + 1
    DECLARE aNetDrives[nNetDriveCount,2]
    aNetDrives[nNetDriveCount,1] = oNetDrives.Item(i)  && Drive letter
    aNetDrives[nNetDriveCount,2] = oNetDrives.Item(i+1) && UNC
ENDFOR
Column 1 is the drive letter, column 2 the UNC assigned to it.

You need to install the Windows Scripting Host (you can download it from M$; it's installed with 98, NT with Option Pack 4, and NT 5 beta 2. You can also download WSH.EXE from MSDN OnLine; it installs itself nicely under all current Win32 versions except Win32s. There's a ton of functionality in the objects exposed through WSHOM.OCX, the main ProgIDs on interest being "Wscript.Shell" and "WScript.Network".
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
Reply
Map
View

Click here to load this message in the networking platform