Applies to VB4+ |
Most API functions use the null character, Chr$(0)
, to mark the end of strings that they return. To use the strings in Visual Basic, you often need to remove the null character. The ZTrim function in General.bas searches a string for the null character and returns everything preceding it:
vbNullChar is an intrinsic constant equivalent to Chr$(0)
.
This code fragment displays the path of the user's Documents folder:
Dim Path As String Path = String$(260, 0) SHGetSpecialFolderPath hWnd, Path, CSIDL_PERSONAL, 0 MsgBox ZTrim(Path)
Here are the required DLL declarations:
Declare Function SHGetSpecialFolderPath Lib "shell32" _ Alias "SHGetSpecialFolderPathA" (ByVal hWndOwner As Long, _ ByVal lpszPath As String, ByVal nFolder As Long, _ ByVal fCreate As Long) As Long ' Special folder constants: Public Const CSIDL_PERSONAL = 5
Note that this example requires the Microsoft Internet Explorer 4.0 Desktop Update.
Copyright © 2001 Rising Productions.