Hi,
how can I get a list of the available drive letters? Günther |
> how can I get a list of the available drive letters?
!KernelLibrary methodsFor! getLogicalDriveStrings: bufferSize buffer: returnString "The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system. DWORD GetLogicalDriveStrings( DWORD nBufferLength, // size of buffer LPTSTR lpBuffer // drive strings buffer );" <stdcall: dword GetLogicalDriveStringsA dword lpstr> ^self invalidCall ! ! !KernelLibrary categoriesFor: #getLogicalDriveStrings:buffer:!public! ! !File class methodsFor! logicalDrives "Answer a collection that contains the system's logical drive letters." | buffer retSize col | buffer := String new: 4 * 26. retSize := KernelLibrary default getLogicalDriveStrings: buffer size buffer: buffer. col := OrderedCollection new. (0 to: retSize - 1 by: 4) do: [:index | col add: (buffer midString: 1 from: index + 1)]. ^col! ! !File class categoriesFor: #logicalDrives!file operations!public! ! |
In reply to this post by Günther Schmidt
Guenther Schmidt wrote:
> Hi, > > how can I get a list of the available drive letters? > > Günther Günther, This is the solution I implemented for myself a while ago. It returns the drive letter and a colon, so if you'd only like the letter, you'll need to adjust the "basepath first: 2" expression. Best Regards, Bernhard !File class methodsFor! drives "Answer a collection with all the existing drives. The elements of the answer are strings containing the drive letter and the colon, i.e. 'C:', 'D:' " | answer basepath | answer := OrderedCollection new. $A asInteger to: $Z asInteger do: [ :each | basepath := each asCharacter asString, ':\'. (self isDirectory: basepath) ifTrue: [ answer add: (basepath first: 2) ] ]. ^answer! ! !File class categoriesFor: #drives!file operations!public! ! |
In reply to this post by Günther Schmidt
"Guenther Schmidt" <[hidden email]> wrote in message
news:d53lpt$34j$00$[hidden email]... > Hi, > > how can I get a list of the available drive letters? > > Günther The simplest might be: IFileSystem3 new drives HTH, Don |
Don,
Is IFileSystem3 included in some special extension? Because I can't find this global identifier in my 5.1.4 image. Bernhard Don Rylander wrote: > "Guenther Schmidt" <[hidden email]> wrote in message > news:d53lpt$34j$00$[hidden email]... > >>Hi, >> >>how can I get a list of the available drive letters? >> >>Günther > > The simplest might be: > > IFileSystem3 new drives > > HTH, > Don > > |
In reply to this post by Don Rylander-3
Hi Don,
thanks, I *always* prefer the simplest solution, however class is also not part of my image (using Dolphin Pro 5.1.4). Günther Don Rylander wrote: > "Guenther Schmidt" <[hidden email]> wrote in message > news:d53lpt$34j$00$[hidden email]... > >>Hi, >> >>how can I get a list of the available drive letters? >> >>Günther > > The simplest might be: > > IFileSystem3 new drives > > HTH, > Don > > |
In reply to this post by Bernhard Kohlhaas-7
"Bernhard Kohlhaas" <[hidden email]> wrote in message
news:d55os2$i12$[hidden email]... > > This is the solution I implemented for myself a while ago. It returns the > drive letter and a colon, so if you'd only like the letter, you'll need to > adjust the "basepath first: 2" expression. ... This is an interesting idea, but on some systems (Mine apparently, Windows XP SP2) it will cause Windows to open this dialog: --------------------------- Windows - No Disk --------------------------- There is no disk in the drive. Please insert a disk into drive . --------------------------- Cancel Try Again Continue --------------------------- when it looks at the A: drive and finds no disk in it. Chris |
In reply to this post by Bernhard Kohlhaas-7
Bernhard,
> Is IFileSystem3 included in some special extension? Because I can't find > this global identifier in my 5.1.4 image. It's one of those ActiveX thingummybobs and is included in the Windows scripting dll. If you evaluate the following the class should be added to your image. tlb := AXTypeLibraryAnalyzer open: 'scrrun.dll'. tlb prefix: ''. tlb generateInterfaceWrappers. -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
In reply to this post by Günther Schmidt
Guenther,
"Guenther Schmidt" <[hidden email]> wrote in message news:d562oi$v98$00$[hidden email]... > Hi Don, > > thanks, I *always* prefer the simplest solution, however class is also not > part of my image (using Dolphin Pro 5.1.4). Oops! I see Ian Bartholomew's already given you a good answer, but I should note that it's in my image because it's in his Scripting.pac extension. For some reason, it doesn't show up as one of his packages in my image. Of course, everyone else has all of Ian's stuff loaded all the time, too, right? ;^) Thanks again, Ian! Don > > Günther > > Don Rylander wrote: >> "Guenther Schmidt" <[hidden email]> wrote in message >> news:d53lpt$34j$00$[hidden email]... >> >>>Hi, >>> >>>how can I get a list of the available drive letters? >>> >>>Günther >> >> The simplest might be: >> >> IFileSystem3 new drives >> >> HTH, >> Don >> |
In reply to this post by Christopher J. Demers
Christopher J. Demers wrote:
> This is an interesting idea, but on some systems (Mine apparently, Windows > XP SP2) it will cause Windows to open this dialog: > --------------------------- > Windows - No Disk > --------------------------- > There is no disk in the drive. Please insert a disk into drive . > --------------------------- > Cancel Try Again Continue > --------------------------- > when it looks at the A: drive and finds no disk in it. > > Chris > > Chris, Thanks for trying this. I didn't have a disk drive connected to my computer, so I never noticed this. So I guess, I'll switch to Louis' routine instead. Bernhard |
In reply to this post by Don Rylander-3
Don,
> Oops! I see Ian Bartholomew's already given you a good answer, but I > should note that it's in my image because it's in his Scripting.pac > extension. For some reason, it doesn't show up as one of his packages in > my image. I don't think I can be blamed for this one :-). I did use to have a scripting package extension but at some stage I stopped using it and changed to dynamically loading the control when needed, usually from a package's script. I found it caused a _lot_ less problems when deploying - needed methods kept being stripped. You can't see the package because, as far as my goodies are concerned anyway, it doesn't exist :-). FWIW, I haven't got IFileSystem3 in my working image, one that has all my current goodies installed. > Thanks again, Ian! You're welcome :-) -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
In reply to this post by Don Rylander-3
Hello all,
> Oops! I see Ian Bartholomew's already given you a good answer, but I should > note that it's in my image because it's in his Scripting.pac extension. For > some reason, it doesn't show up as one of his packages in my image. Of > course, everyone else has all of Ian's stuff loaded all the time, too, > right? ;^) Of course<g>, but I think it would be better to avoid the scripting engine in this case, if possible. Have a good one, Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
Free forum by Nabble | Edit this page |