Compartilhar via


IVsProject3.GenerateUniqueItemName Method

Generates a unique document name for a given item.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Declaration
Function GenerateUniqueItemName ( _
    itemidLoc As UInteger, _
    pszExt As String, _
    pszSuggestedRoot As String, _
    <OutAttribute> ByRef pbstrItemName As String _
) As Integer
int GenerateUniqueItemName(
    uint itemidLoc,
    string pszExt,
    string pszSuggestedRoot,
    out string pbstrItemName
)
int GenerateUniqueItemName(
    [InAttribute] unsigned int itemidLoc, 
    [InAttribute] String^ pszExt, 
    [InAttribute] String^ pszSuggestedRoot, 
    [OutAttribute] String^% pbstrItemName
)
abstract GenerateUniqueItemName : 
        itemidLoc:uint32 * 
        pszExt:string * 
        pszSuggestedRoot:string * 
        pbstrItemName:string byref -> int
function GenerateUniqueItemName(
    itemidLoc : uint, 
    pszExt : String, 
    pszSuggestedRoot : String, 
    pbstrItemName : String
) : int

Parameters

  • itemidLoc
    Type: UInt32

    [in] Container folder for the unique item name being generated. Should be a valid item identifier. For further information, see VSITEMID. The value of this parameter is typically determined by the itemidLoc parameter that the project passes to the AddProjectItemDlg method.

  • pszExt
    Type: String

    [in] File extension of the new document name.

  • pszSuggestedRoot
    Type: String

    [in] If not nulla null reference (Nothing in Visual Basic) or empty, this value should be used as the base name for the item, and numbers should be appended to make the name unique. If supplied, the project should make up its own root name based on the pszExt file extension.

  • pbstrItemName
    Type: String%

    [out] Pointer to the new name, which contains the name only, not the item's file path.

Return Value

Type: Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProject3::GenerateUniqueItemName(
   [in] VSITEMID itemidLoc,
   [in] LPCOLESTR pszExt,
   [in] LPCOLESTR pszSuggestedRoot,
   [out] BSTR * pbstrItemName
);

The Add Item dialog box uses this method to suggest a name for the user when a new item is selected.

.NET Framework Security

See Also

Reference

IVsProject3 Interface

Microsoft.VisualStudio.Shell.Interop Namespace