OleCreateFromFile() Does Not Check for Reserved Names

ID: Q111015

The information in this article applies to:

Before an OLE 2.0 container application calls OleCreateFromFile() to create an embedded object from the contents of a named file, it must make sure that the filename it passes as the lpszFile parameter to OleCreateFromFile() is not a reserved MS-DOS device name, such as COM1 or LPT1. This check is necessary because OleCreateFromFile() does not perform such a check itself.

A container application generally obtains the filename to pass to OleCreateFromFile() by presenting the user with the Insert Object dialog box. Many containers use the OLE2UI library implementation of the Insert Object dialog box, by calling OleUIInsertObject(). OleUIInsertObject() performs a check to make sure that the filename supplied by the user is not a reserved MS-DOS device name; if the user supplies a filename such as "COM1", OleUIInsertObject() brings up a modal dialog box stating "File COM1 Does Not Exist."

Therefore, container applications that use OleUIInsertObject() do not have to perform a check for reserved names.

Additional reference words: 2.01 KBCategory: kbole KBSubcategory: LeTwoCdt

Last Reviewed: April 21, 1995