How to open an application?
ShellExecute(this->m_hWnd,"open","calc.exe","","", SW_SHOW );
Or
ShellExecute(this->m_hWnd,"open","notepad.exe", "c://MyLog.log","",SW_SHOW );
As you can see, I have not passed the complete path of the program.
Q: How do I open a file related to the same system program?
ShellExecute(this->m_hWnd,"open", "c://abc.txt","","",SW_SHOW );
Q: How to open a webpage?
ShellExecute(this->m_hWnd,"open", "http://www.google.com","","", SW_SHOW );
Q: How to activate related programs and send emails?
ShellExecute(this->m_hWnd,"open", "mailto:nishinapp@yahoo.com","","", SW_SHOW );
Q: How do I print documents with a system printer?
ShellExecute(this->m_hWnd,"print", "c://abc.txt","","", SW_HIDE);
Q: How can I use the system search function to find a specified file?
ShellExecute(m_hWnd,"find","d://nish", NULL,NULL,SW_SHOW);
Q: How do I start a program until it finishes running?
SHELLEXECUTEINFO ShExecInfo = {0};ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;ShExecInfo.hwnd = NULL;ShExecInfo.lpVerb = NULL;ShExecInfo.lpFile = "c://MyProgram.exe";ShExecInfo.lpParameters = "";ShExecInfo.lpDirectory = NULL;ShExecInfo.nShow = SW_SHOW;ShExecInfo.hInstApp = NULL;ShellExecuteEx(&ShExecInfo);WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
Or:
PROCESS_INFORMATION ProcessInfo; STARTUPINFO StartupInfo; //This is an [in] parameterZeroMemory(&StartupInfo, sizeof(StartupInfo));StartupInfo.cb = sizeof StartupInfo ; //Only compulsory fieldif(CreateProcess("c://winnt//notepad.exe", NULL, NULL,NULL,FALSE,0,NULL, NULL,&StartupInfo,&ProcessInfo)){ WaitForSingleObject(ProcessInfo.hProcess,INFINITE); CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess);} else{ MessageBox("The process could not be started...");}
Q: How do I display attributes of a file or folder?
SHELLEXECUTEINFO ShExecInfo ={0};ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ;ShExecInfo.hwnd = NULL;ShExecInfo.lpVerb = "properties";ShExecInfo.lpFile = "c://"; //can be a file as wellShExecInfo.lpParameters = ""; ShExecInfo.lpDirectory = NULL;ShExecInfo.nShow = SW_SHOW;ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo);