AddIScsiStaticTargetA function (iscsidsc.h)

The AddIscsiStaticTarget function adds a target to the list of static targets available to the iSCSI initiator.


  [in]           PSTR                        TargetName,
  [in, optional] PSTR                        TargetAlias,
  [in]           ISCSI_TARGET_FLAGS          TargetFlags,
  [in]           BOOLEAN                     Persist,
  [in, optional] PISCSI_TARGET_MAPPINGA      Mappings,
  [in, optional] PISCSI_LOGIN_OPTIONS        LoginOptions,
  [in, optional] PISCSI_TARGET_PORTAL_GROUPA PortalGroup


[in] TargetName

The name of the target to add to the static target list.

[in, optional] TargetAlias

An alias associated with the TargetName.

[in] TargetFlags

A bitmap of flags that affect how, and under what circumstances, a target is discovered and enumerated.

The following table lists the flags that can be associated with a target and the meaning of each flag.

Value Meaning
The target is added to the list of static targets. However, ReportIscsiTargets does not report the target, unless it was also discovered dynamically by the iSCSI initiator, the Internet Storage Name Service (iSNS), or a SendTargets request.
The iSCSI initiator service merges the information (if any) that it already has for this static target with the information that the caller passes to AddIscsiStaticTarget.

If this flag is not set, the iSCSI initiator service overwrites the stored information with the information that the caller passes in.

[in] Persist

If true, the target information persists across restarts of the iSCSI initiator service.

[in, optional] Mappings

A pointer to a structure of type ISCSI_TARGET_MAPPING that contains a set of mappings that the initiator uses when assigning values for the bus, target, and LUN numbers to the iSCSI LUNs associated with the target. If Mappings is null, the initiator will select the bus, target, and LUN numbers.

[in, optional] LoginOptions

A pointer to a structure of type ISCSI_LOGIN_OPTIONS that contains the options that specify the default login parameters that an initiator uses to login to a target.

[in, optional] PortalGroup

A pointer to a structure of type ISCSI_TARGET_PORTAL_GROUP that indicates the group of portals that an initiator can use login to the target.

Return value

Returns ERROR_SUCCESS if the operation succeeds. Otherwise, it returns the appropriate Win32 or iSCSI error code.


This routine adds a target to the iSCSI initiator service's list of static targets. If the caller specifies a value of true in Persist, the target is stored in the registry and information about the target persists across restarts of the initiator service and reboots of the operating system.

By setting the ISCSI_TARGET_FLAG_HIDE_STATIC_TARGET flag, callers can configure default login information for a target prior to its discovery by an iSCSI initiator, the iSNS service, or a SendTargets request.


The iscsidsc.h header defines AddIScsiStaticTarget as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header iscsidsc.h
Library Iscsidsc.lib
DLL Iscsidsc.dll

See also