PRB: GetSaveFileName Allows You to Select Invalid Folder (245718)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- Microsoft Windows NT Server 4.0
- Microsoft Windows NT Workstation 4.0
This article was previously published under Q245718 SYMPTOMS
When a Save As dialog box is displayed using GetSaveFileName, the dialog box allows you to select an invalid folder as the destination folder when you click Save. When an invalid folder is selected, GetSaveFileName uses the current working directory when returning the full path and filename. Examples of invalid folders are Network Neighborhood and network server names, such as \\MyMachine.
CAUSE
The GetSaveFileName does not validate the destination folder to see if it is part of the file system.
RESOLUTION
An application using GetSaveFileName can verify if the destination folder is part of the file system by using a hook procedure that handles the CDN_FILEOK notification.
When handling the CDN_FILEOK notification, the hook procedure obtains a pointer to the ITEMIDLIST (PIDL) of the selected folder by sending the dialog box a CDM_GETFOLDERIDLIST message. The returned PIDL is then passed to SHGetFileInfo to request the attributes of the folder. If the folder has the SFGAO_FILESYSTEM attribute it is part of the file system and can be used as the destination folder.
Modification Type: | Minor | Last Reviewed: | 12/20/2004 |
---|
Keywords: | kbCmnDlg kbCmnDlgSave kbprb KB245718 |
---|
|