Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:03:40+00:00 2026-05-27T20:03:40+00:00

Given the path of an mp3 file, how do I create and initialize an

  • 0

Given the path of an mp3 file,

how do I create and initialize an IPropertyStore object to operate on the metadata of that file?

Specifically, how do I get from here:

"C:\\Music\\Viva Las Vegas.mp3"

to here:

store->GetValue(PKEY_Music_AlbumArtist, &variant);

Here’s some pseudo-ish code to help clarify what I’m trying to do:

#include "stdafx.h"
#include <propsys.h>
#include <propkey.h>

void main ()
{
    // property store must somehow represent the mp3 file
    IPropertyStore* store = "C:\\Music\\Viva Las Vegas.mp3"; // HELP!
    PROPVARIANT variant;

    // get the existing album artist
    store->GetValue(PKEY_Music_AlbumArtist, &variant);
    assert(variant== "Elvis Presley");

    // set it to something else
    variant= "ZZ Top";
    store->SetValue(PKEY_Music_AlbumArtist, variant);
}

BACKGROUND

Perhaps there is a better language for doing this but I want to use C++ (it’s a long story).

Originally, after researching mp3 metadata, it seemed like ID3 tags with TagLib was the way to go. So I wrote a utility that worked fine on a couple of fields. But then I discovered that TagLib is limited to a small subset of the many possible fields, and I want access to all of them.

The field I’m most concerned with is Album Artist because Windows Media Player uses it as the default sort order which cannot be changed.

I modified the TagLib source to access the Album artist instead of the Contributing artist (by changing all occurrences of ‘\251ART’ to ‘\141ART’) but it didn’t work.

I’m sure there is a way that everything can be done with ID3 tags but I’d rather not rely on extra stuff like TagLib, ZLIB and the CMake facility. I want to use IPropertyStore because it’s built in, and it seems like the simplest way if I can just get over this hurdle.

I found a few examples of IPropertyStore on the web, and I’ve tried to massage them to suit my needs without any luck, I am still mystified.

MSDN “Help” isn’t the least bit helpful — no specs, no examples — it doesn’t even tell me which header file to include. MSDN Help is terrible now compared to what it used to be, or am I missing something? Without Google I’d be screwed. Anyway …

I hope someone can show me in 3 or 4 lines of code how to create and initialize IPropertyStore for my purpose. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:03:40+00:00Added an answer on May 27, 2026 at 8:03 pm

    Here’s the answer:

    #include <shobjidl.h>   // SHGetPropertyStoreFromParsingName, etc
    #include <propkey.h>    // PKEY_Music_AlbumArtist
    #include <propvarutil.h>// InitPropVariantFromString, needs shlwapi.lib
    
    void main() // error-checking removed
    {
        // initialize the COM library
        CoInitialize(NULL);
    
        // get a property store for the mp3 file
        IPropertyStore* store = NULL;
        SHGetPropertyStoreFromParsingName(L"C:\\Music\\Viva Las Vegas.mp3", 
            NULL, GPS_READWRITE, __uuidof(IPropertyStore), (void**)&store);
    
        // get the existing album artist ("Elvis Presley")
        PROPVARIANT variant;
        store->GetValue(PKEY_Music_AlbumArtist, &variant);
    
        // set it to something else
        InitPropVariantFromString(L"ZZ Top", &variant);
        store->SetValue(PKEY_Music_AlbumArtist, variant);
        store->Commit();
    
        // very important undocumented method
        store->Release();
    }
    

    Thanks to Logan Capaldo for pointing me in the right direction. I didn’t need those 2 functions when I found

    SHGetPropertyStoreFromParsingName()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a File object how can I create the path for saving it? I
Given a path and filename how can I get the Image object: Image image
Given a file path such as: \\server\folder_A\folder_B\etc\more.mov I need a regex that'll give me
I want to get the file name in a given path is there any
I'd basically like to get /path/file+name+with+plusses.mp3 to rewrite to /path/file name with plusses.mp3 In
How do I create a directory at a given path, and also create any
Given a path such as "mydir/myfile.txt" , how do I find the file's absolute
Given the path of a file (e.g. C:\MyPicture.jpg), how do I convert a binary
Given a DFS path, how can I programatically determine which physical file server it
How do I load a Python module given its full path? Note that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.