Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

DefineDosDeviceW function (fileapi.h)

  • 2022-11-22
Feedback

In this article

Defines, redefines, or deletes MS-DOS device names.

Syntax

BOOL DefineDosDeviceW(  [in]           DWORD   dwFlags,  [in]           LPCWSTR lpDeviceName,  [in, optional] LPCWSTR lpTargetPath);

Parameters

[in] dwFlags

The controllable aspects of theDefineDosDevice function. This parametercan be one or more of the following values.

ValueMeaning
DDD_EXACT_MATCH_ON_REMOVE
0x00000004
If this value is specified along withDDD_REMOVE_DEFINITION, the function will use an exact match to determine which mapping to remove. Use this value to ensure that you do not delete something that you did not define.
DDD_NO_BROADCAST_SYSTEM
0x00000008
Do not broadcast theWM_SETTINGCHANGE message. By default, this message is broadcast to notify the shell and applications of the change.
DDD_RAW_TARGET_PATH
0x00000001
Uses thelpTargetPath string as is. Otherwise, it is converted from an MS-DOS path to a path.
DDD_REMOVE_DEFINITION
0x00000002
Removes the specified definition for the specified device. To determine which definition to remove, the function walks the list of mappings for the device, looking for a match oflpTargetPath against a prefix of each mapping associated with this device. The first mapping that matches is the one removed, and then the function returns.

IflpTargetPath isNULL or a pointer to aNULL string, the function will remove the first mapping associated with the deviceand pop the most recent one pushed. If there is nothing left to pop, the device name will be removed.

If this value is not specified, the string pointed to by thelpTargetPathparameter will become the new mapping for this device.

[in] lpDeviceName

A pointer to an MS-DOS device name string specifying the device the function is defining, redefining, ordeleting. The device name string must not have a colon as the last character, unless a drive letter is beingdefined, redefined, or deleted. For example, drive C would be the string "C:". In no case is atrailing backslash (\) allowed.

[in, optional] lpTargetPath

A pointer to a path string that will implement this device. The string is an MS-DOS path string unless theDDD_RAW_TARGET_PATH flag is specified, in which case this string is a pathstring.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError.

Remarks

MS-DOS device names are stored as junctions in the object namespace. The code that converts an MS-DOS pathinto a corresponding path uses these junctions to map MS-DOS devices and drive letters. TheDefineDosDevice function enables an application to modify the junctions used toimplement the MS-DOS device namespace.

To retrieve the current mapping for a particular MS-DOS device name or to obtain a list of all MS-DOS devicesknown to the system, use theQueryDosDevicefunction.

To define a drive letter assignment that is persistent across boots and not a network share, use theSetVolumeMountPoint function. If the volume tobe mounted already has a drive letter assigned to it, use theDeleteVolumeMountPoint function to remove theassignment.

Drive letters and device names defined at system boot time are protected from redefinition and deletion unlessthe user is an administrator.

Starting with Windows XP, this function creates a device name for a caller that is not running inthe "LocalSystem" context in its own Local MS-DOS device namespace. If the caller is running inthe "LocalSystem" context, the function creates the device name in the Global MS-DOS devicenamespace. For more information, seeDefining an MS DOS Device Name andFile Names, Paths, and Namespaces.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

TechnologySupported
Server Message Block (SMB) 3.0 protocolNo
SMB 3.0 Transparent Failover (TFO)No
SMB 3.0 with Scale-out File Shares (SO)No
Cluster Shared Volume File System (CsvFS)No
Resilient File System (ReFS)No
 

SMB does not support volume management functions. For CsvFs, a new name will not be replicated to the other nodes on the cluster.

Examples

For an example, seeEditing Drive Letter Assignments.

Requirements

RequirementValue
Minimum supported clientWindows XP [desktop apps only]
Minimum supported serverWindows Server 2003 [desktop apps only]
Target PlatformWindows
Headerfileapi.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See also

DeleteVolumeMountPoint

QueryDosDevice

SetVolumeMountPoint

Volume Management Functions


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo