|
Here's a simple little demo that takes a basic concept, stuffing the keyboard buffer of a console application, and builds it into an incredibly poweful CDW command line utility. With a Sub Main that amounts to perhaps 15 or 20 lines of code, we build a tool that displays a "browse for folder" dialog, then upon exit it issues the appropriate changedrive and changedirectory commands to the parent process.
There are lots of hidden gems in this sample, so by all means dig through it. Besides the several ways it offers to call the folder browse dialogs, you'll also add another handy method to your console application arsenal.
This sample hasn't been published anywhere except here on this website, but first rights to such publication are jealously guarded - you have been warned. <g>
This sample uses the following API calls:
Module Library Function MCDW.bas kernel32
user32ExitProcess
GetShortPathName
GetVersionEx
RtlMoveMemory
EnumThreadWindows
GetWindowLongMFolderBrowse.bas kernel32
ole32
shell32
user32GetVersionEx
LocalAlloc
LocalFree
lstrcpyA
lstrlenA
RtlMoveMemory
CoTaskMemFree
SHBrowseForFolder
SHGetPathFromIDList
SHGetSpecialFolderLocation
SHSimpleIDListFromPath
SendMessageMKeyStuff.bas kernel32
user32CloseHandle
GetStdHandle
RtlMoveMemory
WriteConsoleInput
MapVirtualKey
VkKeyScanDon't see what you're looking for? Here's a complete API cross-reference.
Please, enjoy and learn from this sample. Include its code within your own projects, if you wish. But, in order to insure only the most recent code is available to all, I ask that you don't share the sample by any form of mass distribution. Download KeyStuff.zip, 49Kb, Last Updated: Thursday, July 29, 2010
The following resources may also be of interest:
- Console - Full console application development support from within VB5/6 IDE.