This documentation is archived and is not being maintained.

AddResource Method

Visual Studio .NET 2003

Adds the specified resource to the project.

[Visual Basic .NET]
Public Function AddResource( _
   ByVal bstrNameID As String, _
   ByVal bstrInFileName As String, _
   ByVal bstrType As String, _
   Optional ByVal bstrOptCompDirectives As String = , _
   Optional ByVal bAllowDuplicateID As Long = 0 _
) As String
[Visual Basic 6]
Function AddResource( _
   ByVal bstrNameID As String, _
   ByVal bstrInFileName As String, _
   ByVal bstrType As String, _
   Optional ByVal bstrOptCompDirectives As String = , _
   Optional ByVal bAllowDuplicateID As Long = 0 _
) As String
[C++]
HRESULT __stdcall AddResource(
   BSTR bstrNameID,
   BSTR bstrInFileName,
   BSTR bstrType,
   BSTR bstrOptCompDirectives,
   long bAllowDuplicateID,
   /* [out, retval] */ BSTR* retVal
);
[C#]
string AddResource(
   string bstrNameID,
   string bstrInFileName,
   string bstrType,
   string bstrOptCompDirectives,
   int bAllowDuplicateID
);
[JScript .NET]
public function AddResource(
   bstrNameID : String,
   bstrInFileName : String,
   bstrType : String,
   bstrOptCompDirectives : String,
   bAllowDuplicateID : int
) : String

Parameters

bstrNameID
Required. A bstr specifying the resource name ID.
bstrInFileName
Required. A bstr specifying the file name containing the resource.
bstrType
Required. A bstr containing the type of resource to open. In the Resource Editor, types are represented by folders containing the resources. See Remarks for a list of types.
bstrOptCompDirectives
Optional. A bstr specifying the resource compiler directives.
bAllowDuplicateID
Optional. Indicates that the resource ID can be a duplicate of an existing resource ID.

Remarks

Adds the specified resource to the project.

Use one of the following types for bstrType:

Accelerator Bitmap Cursor
Cursor (not group) Data Default
DESIGNINFO Dialog Dialog Info
Font Font Dir Icon
Icon (not group) Menu Name Table
PLUGPLAY String Table String Table (not group)
TEXTINCLUDE Toolbar Version
VXD (the device driver, treated as a custom resource)    

Example

//From the MFC Application Wizard
   var strProjectRC = GetProjectFile(selProj, "RC", true, false);
   var strDLGID = "IDD_" + strUpperShortName;
   var oResHelper = wizard.ResourceHelper;
   oResHelper.OpenResourceFile(strProjectRC);
   var strSymbolValue = oResHelper.AddResource(strDLGID, strTemplatePath + "\\dialog.rc", "DIALOG");
   wizard.AddSymbol("IDD_DIALOGID", strSymbolValue.split("=").shift());
   oResHelper.OpenResourceInEditor(strDLGID);
   oResHelper.CloseResourceFile();

See Also

Applies To: VCResourceHelper Object

Show: