|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Visual Basic Win32 Shell
Routines Undocumented Windows: Overview |
||
Posted: | Wednesday August 6, 1997 | |
Updated: | Monday December 26, 2011 | |
Applies to: | VB4-32, VB5, VB6 | |
Developed with: | VB4-32, Windows 95 | |
OS restrictions: | None | |
Author: | Brad Martinez | |
Related: |
SHChangeNotifyRegister: Receive Shell Change Notifications Undocumented Windows: Shell Dialogs Undocumented Windows: Format Disk Dialog Undocumented Windows: Change Icon Dialog Undocumented Windows: Path Functions |
|
Introduction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To assist Windows in delivering its system services, it relies on
undocumented APIs. All of the Shell32.dll functions demonstrated are exported only by ordinal (NONAME) and are not known to be documented by
Microsoft. As a result, they are most likely not supported by Microsoft and may very well not be included in future versions of Shell32.dll,
may or may not use the same ordinal numbers for the same API, or may add or remove parameters. Therefore, use them at your own risk. Note
that these ordinals have been tested only against Windows 95 and NT4. Initial testing indicates none missing in Windows 98, however note that
Windows 98 has duplicated some of these as standard non-ordinal Shell APIs.
The SHFormatDrive syntax was provided by Joe LeVasseur. The syntax and description of all other functions below was derived and tested by Brad Martinez, who has provided the following explanations of the APIs and their usage. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From what may have been their original exported name in the debug
version of the library, these undocumented API functions have been renamed to a slightly more intuitive name (since only the ordinals are
shown in an export dump of Shell32.dll). It is suggested that developers who decide to implement these functions maintain the names that are
used here to avoid confusion.
APIs by Category / Ordinal Numbers
pb refers to parameter bytes .... that is, the number of bytes passed in the calls as parameters. These are but a small portion of the ordinal undocumented APIs .... just those that are presently demonstrated in the associated VBnet demo pages. As time goes on, more will be added. IMPORTANT NOTE: Unlike most documented Win32 API functions, the functions that accept string parameters (all but SHShutDownDialog) expect strings in either the ANSI or Unicode character sets depending on the Windows platform the function is called from (i.e. there are no separate ANSI "A" or Wide "W" function versions as in the documented APIs). In order for a function to return an accurate value (and reduce the potential for a fatal exception), the function must be passed ANSI strings when called in Win95, and must be passed Unicode strings when called in WinNT. Note the explicit use of the global "bIsWinNT" flag throughout the demos, and the corresponding calls to VBs StrConv function (in the wrapper routine CheckString) to convert the ANSI strings to their Unicode equivalent when bIsWinNT evaluates to True (this is the same as using the MultiByteToWideChar API on those strings). If it is discovered that any of the information in this demo proves to be inaccurate or incomplete, Brad Martinez and/or VBnet would appreciate notification at either of the email addresses below, so that the required corrections can be made. And if anyone has insight into the purpose of the "unknown" variables in the declares below, again, please let us know. Finally, this demo would not have happened if it weren't for the function prototypes found at Chris Becke's site. I thank him for making this information available. Enjoy!.
The code for all undocumented sample apps was developed and tested by Brad using VB4.0a-32 on both Win95 v4.00.950a and WinNT v4.0 Server SP2, and then again by Randy (who often can't leave well-enough alone and broke his example into smaller topical pieces for posting here) with VB5.0 under Win95 4.00.950b (OSR2). NOTE: The following is for information and completeness only; each Windows by the Numbers sample app will have the required declaration code for that routine. Dialog Functions (sorted by ordinal) The "System Settings Change" message box ("You must restart your computer before the new settings will take effect.") Declare Function SHRestartSystemMB Lib "shell32" Alias
"#59" _ hOwner = Message box owner; specify 0& for the desktop (will be top-level) WinNT Win95 Shuts the system down (no reboot) and does not include the default prompt. Reboots the system and includes the default prompt. Return values: Yes = 6 (vbYes), No = 7 (vbNo) The "Shut Down" dialog (i.e. Start menu / Shut Down) Declare Function SHShutDownDialog Lib "shell32" Alias
"#60" _ The "Run" dialog (i.e. Start menu / Run) Declare Function SHRunDialog Lib "shell32" Alias "#61" _ hOwner = Dialog owner; specify 0& for the desktop (will be top-level) If uFlags is the following constant, the string from the last-run program will
not appear in the dialogs combo box (that's all I found...) If there is some way to set and return the command line, I didn't find it... Always returns 0 (?) The "Change Icon" dialog Declare Function SHChangeIconDialog Lib "shell32" Alias
"#62" _ hOwner = Dialog owner; specify 0& for the desktop (will be top-level) Returns non-zero on select, zero if cancelled. Path functions (sorted by ordinal): Declare Function SHGetExtension Lib "shell32" Alias "#31"
_ Returns pointer to the last dot in szPath and the string following it (includes the dot with the extension). Returns 0 if szPath contains no dot. For the function to succeed, szPath should be null terminated and be allocated to MAX_PATH bytes (260). Does not check szPath for validity. (could be called "GetStrAtLastDot") Declare Function SHAddBackslash Lib "shell32" Alias "#32"
_ Inserts a backslash before the first null char in szPath. szPath is unchanged if it already contains a backslash before the first null char or contains no null char at all. Returns pointer to ??? Does not check szPath for validity. (the name almost fits...) Declare Function SHGetFileName Lib "shell32" Alias "#34" _ Returns a pointer to the string in szPath after the last backslash. Returns 0 if szPath contains no backslash or no char follows the last backslash. For the function to succeed, szPath should be null terminated and be allocated to MAX_PATH bytes (260). Does not check szPath for validity. (could be called "GetStrAfterLastBackslash") Declare Function SHGetPath Lib "shell32" Alias "#35" _ Returns a pointer to the string in szPath before the last backslash. Returns 0 if szPath contains no backslash or no char follows the last backslash. For the function to succeed, szPath should be null terminated and be allocated to MAX_PATH bytes (260). Does not check szPath for validity. (could be called "GetStrBeforeLastBackslash") Declare Function SHPathIsRelative Lib "shell32" Alias
"#40" _ Returns non-zero if szPath does not evaluate to a UNC path (if either the first char is not a backslash "\" or the 2nd char is not a colon ":"). Does not check szPath for validity. (the name almost fits...) Declare Function SHPathIsExe Lib "shell32" Alias "#43" _ Returns non-zero if szPath has an executable extension (if last 4 char are either ".exe", ".com", ".bat" or ".pif"). Does not check szPath for validity. (could have been called "HasExeExtension") Declare Function SHFileExists Lib "shell32" Alias "#45" _ Returns non-zero if szPath is valid absolute UNC path. Accepts file, folder or network paths. Returns True for a relative path only if it exists in the current directory. (the name actually fits...) Declare Function SHGetPathArgs Lib "shell32" Alias "#52" _ Returns a pointer to the string after first space in szPath. Returns null pointer if szPath contains no space or no char following the first space. For the function to succeed, szPath should be null terminated and be allocated to MAX_PATH bytes (260). Does not check szPath for validity. (could be called "GetStrAfterFirstSpace") Declare Function SHAddPathQuotes Lib "shell32" Alias "#55"
_ Returns a pointer to a string embraced in quotes if the original passed string contained a space. Returns the original string otherwise. Does not check szPath for validity. (could be called "AddQuotesIfPathHasASpace") Declare Function SHRemovePathQuotes Lib "shell32" Alias
"#56" _ Returns a pointer to a string without embracing quotes if the original passed string contained was originally quoted. Returns the original string otherwise. Does not check szPath for validity. (could be called "RemoveQuotesIfPathHasASpace") Declare Function SHGetShortPathName Lib "shell32" Alias
"#92" _ Fills szPath with its DOS (8.3) file system string. If successful, returns non-zero (sometimes is a pointer to szPath, sometimes not!) Returns zero if path is invalid. szPath must be a valid, absolute path. Returns non-zero for a relative path only if it exists in the current directory. For the function to work correctly, szPath should be null terminated and be allocated to MAX_PATH bytes (260). (the name definitely fits.) Undocumented Non-Ordinal Functions Declare Function SHFormatDrive Lib "shell32" _ hOwner = Dialog owner; specify 0& for the desktop (will be top-level) Public Const SHFD_CAPACITY_DEFAULT = 0 ' default drive capacity iFormatType = Based on the OS, can be the following values: WinNT Win95 Return vals: Operation cancelled by user: -2 ( - vbCancel ) The return values do not indicate any options chosen by the user (Quick, No Label, Copy System Files), nor the type of format performed (Quick, Full, System Only) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||
|
|||||
|
|||||
Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved. |