Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an application, which will run in elevated mode on Windows Vista and Windows 7. It is a small music library application. I have options to open ,mp3 files with default programs.

Here is the problem.

If user on the PC already opened any .mp3 files with windows media player. The player will be opened with current logged on user rights.

If i try to open any .mp3 file with shell execute from my elevated application it is failing to open the file and throwing some error like "Server Execution failed".

Please help me how to solve the issue.

I am thinking to open the file with the logged on user privileges. How to open the .mp3 files with associated application using ::ShellExecute.

For error picture please look @ (i don't have option to upload picture here so) http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/28e5d5f6-960a-44c3-90e6-c8f6ec7f8b06[^]

I am calling the functionality like bellow
C++
SHELLEXECUTEINFO ExecInfo;
 
ExecInfo.cbSize			= sizeof(SHELLEXECUTEINFO);
ExecInfo.fMask			= SEE_MASK_INVOKEIDLIST;
ExecInfo.lpVerb			= NULL;
ExecInfo.lpIDList		= NULL;
ExecInfo.hwnd			= hwnd;
ExecInfo.nShow			= SW_SHOW;
ExecInfo.lpParameters	        = NULL;
ExecInfo.lpDirectory	        = L"D:\Songs";
ExecInfo.lpFile			= L"There is light that.mp3";
ExecInfo.hInstApp		= NULL;
 
::ShellExecuteEx(&ExecInfo);  


Thanks in advance.
Posted
Updated 27-Oct-11 4:52am
v2

Well ..Posting "current" code would be considered polite ...

ShellExecute(handle, "open", fullpathtofile_andfilename_andextension, NULL, NULL, SW_SHOWNORMAL);


try this one ..
 
Share this answer
 
C++
SHELLEXECUTEINFO ExecInfo;

ExecInfo.cbSize			= sizeof(SHELLEXECUTEINFO);
ExecInfo.fMask			= SEE_MASK_INVOKEIDLIST;
ExecInfo.lpVerb			= NULL;
ExecInfo.lpIDList		= NULL;
ExecInfo.hwnd			= hwnd;
ExecInfo.nShow			= SW_SHOW;
ExecInfo.lpParameters	        = NULL;
ExecInfo.lpDirectory	        = L"D:\Songs";
ExecInfo.lpFile			= L"There is light that.mp3";
ExecInfo.hInstApp		= NULL;

::ShellExecuteEx(&ExecInfo);


This is how i am calling the shell execute function.
 
Share this answer
 
Comments
Richard MacCutchan 28-Oct-11 5:06am    
L"D:\Songs"; You must escape the backslash character in strings. Using the return value of the function call would help you to discover this.
You must check the status of system calls if you expect to be able to diagnose errors in your code. The ShellExecuteEx()[^] function returns FALSE if it does not succeed, at which point you should call GetLastError()[^] to help diagnose why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900