IVsProject3.AddItem Method (UInt32, VSADDITEMOPERATION, String, UInt32, array<String[], IntPtr, array<VSADDRESULT )
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
'Déclaration
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
'Utilisation
Dim instance As IVsProject3
Dim itemidLoc As UInteger
Dim dwAddItemOperation As VSADDITEMOPERATION
Dim pszItemName As String
Dim cFilesToOpen As UInteger
Dim rgpszFilesToOpen As String()
Dim hwndDlgOwner As IntPtr
Dim pResult As VSADDRESULT()
Dim returnValue As Integer
returnValue = instance.AddItem(itemidLoc, _
dwAddItemOperation, pszItemName, _
cFilesToOpen, rgpszFilesToOpen, _
hwndDlgOwner, pResult)
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.
- dwAddItemOperation
Type: Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION
[in] Operation applied to the newly created item. Can be VSADDITEMOP_OPENDIRECTORY only if VSADDITEM_ShowAddFolderButton is passed to the method AddProjectItemDlg. See the enumeration VSADDITEMOPERATION.
- pszItemName
Type: System.String
[in] Name of the item to be added.
- cFilesToOpen
Type: System.UInt32
[in] Number of items in rgpszFilesToOpen. Can be zero. This must be 1 if dwAddItemOperation is VSADDITEMOP_CLONEFILE or VSADDITEMOP_OPENDIRECTORY. If VSADDITEMOP_RUNWIZARD, it must be 1 or 2.
- 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.
- pResult
Type: array<Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[]
[out, retval] Pointer to the VSADDRESULT enumeration indicating whether the item was successfully added to the project.
Return Value
Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Implements
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.