MCI Command String can't play .wav when packaged release in vs2019

81 views Asked by At

It can't play .wav file when I packaged release project in vs2019, but it work in debug. I use the MCI Command String api. I have not idea. Does anyone have an idea? This is code: Open the wav

TemStr = "";
                TemStr = TemStr.PadLeft(127, Convert.ToChar(" "));
                CommandName = CommandName.PadLeft(260, Convert.ToChar(" "));
                mc.iName = value;
                ilong = GetShortPathName(mc.iName, CommandName, CommandName.Length);
                CommandName = GetCurrPath(CommandName);
                CommandName = "open " + mc.iName + " type MPEGVideo alias media ";//media
                ilong = mciSendString("close all", TemStr, TemStr.Length, 0);

                ilong = mciSendString(CommandName, TemStr, TemStr.Length, 0);

                durLength = "";
                durLength = durLength.PadLeft(128, Convert.ToChar(" "));

                ilong = mciSendString("set media time format milliseconds", TemStr, TemStr.Length, 0);

                mc.state = PlayModeEnum.Stop;

Play wav

TemStr = "";
            TemStr = TemStr.PadLeft(127, Convert.ToChar(" "));
            mciSendString("play media", TemStr, TemStr.Length, 0);
            
            mc.state = PlayModeEnum.Play;

I think code no problems in debug. It works. But can’t work in packaged release.

1

There are 1 answers

0
zhao On

The reason is it can’t install program files path. It is default path when use the setup project. So you need manual set the install path. Don’t use the default path.