Udostępnij za pośrednictwem


IVsProject3.AddItem Method

Creates new items in a project, adds existing files to a project, or causes Add Item wizards to be run.

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

Syntax

'Declaration
Function AddItem ( _
    itemidLoc As UInteger, _
    dwAddItemOperation As VSADDITEMOPERATION, _
    pszItemName As String, _
    cFilesToOpen As UInteger, _
    rgpszFilesToOpen As String(), _
    hwndDlgOwner As IntPtr, _
    <OutAttribute> pResult As VSADDRESULT() _
) As Integer
int AddItem(
    uint itemidLoc,
    VSADDITEMOPERATION dwAddItemOperation,
    string pszItemName,
    uint cFilesToOpen,
    string[] rgpszFilesToOpen,
    IntPtr hwndDlgOwner,
    VSADDRESULT[] pResult
)
int AddItem(
    [InAttribute] unsigned int itemidLoc, 
    [InAttribute] VSADDITEMOPERATION dwAddItemOperation, 
    [InAttribute] String^ pszItemName, 
    [InAttribute] unsigned int cFilesToOpen, 
    [InAttribute] array<String^>^ rgpszFilesToOpen, 
    [InAttribute] IntPtr hwndDlgOwner, 
    [OutAttribute] array<VSADDRESULT>^ pResult
)
abstract AddItem : 
        itemidLoc:uint32 * 
        dwAddItemOperation:VSADDITEMOPERATION * 
        pszItemName:string * 
        cFilesToOpen:uint32 * 
        rgpszFilesToOpen:string[] * 
        hwndDlgOwner:IntPtr * 
        pResult:VSADDRESULT[] byref -> int 
function AddItem(
    itemidLoc : uint, 
    dwAddItemOperation : VSADDITEMOPERATION, 
    pszItemName : String, 
    cFilesToOpen : uint, 
    rgpszFilesToOpen : String[], 
    hwndDlgOwner : IntPtr, 
    pResult : VSADDRESULT[]
) : int

Parameters

  • itemidLoc
    Type: System.UInt32
    [in] Identifier of the container folder for the item being added. Should be VSITEMID_ROOT or other valid item identifier. See the enumeration VSITEMID. Note that this parameter is currently ignored because only adding items as children of a project node is supported. Projects that support the notion of folders will want to add the items relative to itemidLoc.
  • pszItemName
    Type: System.String
    [in] Name of the item to be added.
  • rgpszFilesToOpen
    Type: array<System.String[]
    [in, size_is(cFilesToOpen)] Array of pointers to OLESTR file names. If dwAddItemOperation is VSADDITEMOP_CLONEFILE or VSADDITEMOP_OPENDIRECTORY, the first item (rgpszFilesToOpen[0]) in the array is the name of the file to clone or the directory to open. If it is VSADDITEMOP_RUNWIZARD, the first item (rgpszFilesToOpen[0]) is the name of the wizard to run, and the second item (rgpszFilesToOpen[1]) is the file name the user supplied (same as pszItemName).
  • hwndDlgOwner
    Type: System.IntPtr
    [in] Handle to the Add Item dialog box.

Return Value

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

Implements

IVsProject2.AddItem(UInt32, VSADDITEMOPERATION, String, UInt32, array<String[], IntPtr, array<VSADDRESULT[])

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProject3::AddItem(
   [in] VSITEMID itemidLoc,
   [in] VSADDITEMOPERATION dwAddItemOperation,
   [in] LPCOLESTR pszItemName,
   [in] ULONG cFilesToOpen,
   [in, size_is(cFilesToOpen)] LPCOLESTR rgpszFilesToOpen[],
   [in] HWND hwndDlgOwner,
   [out, retval] VSADDRESULT * pResult
);

This method is used by the Add Item dialog box. The method can create new items, add existing files, or cause Add Item wizards to be run.

.NET Framework Security

See Also

Reference

IVsProject3 Interface

Microsoft.VisualStudio.Shell.Interop Namespace