简体   繁体   English

如何以编程方式更改Windows音频设备的友好名称?

[英]How to programmatically change the friendly name of a Windows audio device?

What is the proper API call that I should use to rename an audio device on windows? 在Windows上重命名音频设备时应使用什么正确的API调用? My goal is to change the device name that is shown to the user when they right click the volume icon and select "playback devices." 我的目标是更改在用户右键单击音量图标并选择“播放设备”时显示给用户的设备名称。 I believe "friendly name" is the property I want to alter. 我相信“好记的名字”是我要更改的属性。

I've managed to successfully call SetupDiSetDeviceProperty , which returns true. 我已经成功地成功调用SetupDiSetDeviceProperty ,它返回true。 If I subsequently call SetupDiGetDeviceProperty , the recently set value is returned. 如果随后我调用SetupDiGetDeviceProperty ,则返回最近设置的值。 However, this value seems to only exist within the context of my application - the system setting seems unchanged. 但是,此值似乎仅存在于我的应用程序上下文中-系统设置似乎不变。

Is there another function call that I should call instead of or in addition to SetupDiSetDeviceProperty ? 除了SetupDiSetDeviceProperty之外,还有其他函数调用吗?

I have been running my application as an administrator, so permissions shouldn't be an issue. 我一直以管理员身份运行应用程序,因此权限不应该成为问题。

I am not sure if this will allow you to change it, but according to this : (msdn.microsoft.com/en-us/library/windows/desktop/dd316587(v=vs.85).aspx) 我不知道这是否会允许你改变它,但根据 :(msdn.microsoft.com/en-us/library/windows/desktop/dd316587(v=vs.85).aspx)

PKEY_DeviceInterface_FriendlyName PKEY_DeviceInterface_FriendlyName

The PKEY_DeviceInterface_FriendlyName property contains the friendly name of the audio adapter to which the endpoint device is attached (for example, "XYZ Audio Adapter"). PKEY_DeviceInterface_FriendlyName属性包含终结点设备连接到的音频适配器的友好名称(例如,“ XYZ音频适配器”)。

The vt member of the PROPVARIANT structure is set to VT_LPWSTR. PROPVARIANT结构的vt成员设置为VT_LPWSTR。 The pwszVal member of the PROPVARIANT structure points to a null-terminated, wide-character string that contains the friendly name. PROPVARIANT结构的pwszVal成员指向一个以空字符结尾的宽字符串,其中包含友好名称。 Requirements 要求

Minimum supported client - Windows Vista [desktop apps only] Minimum supported server - Windows Server 2008 [desktop apps only] 支持的最低客户端-Windows Vista [仅桌面应用]支持的最低服务器-Windows Server 2008 [仅桌面应用]

Header - Functiondiscoverykeys_devpkey.h 标头-Functiondiscoverykeys_devpkey.h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM