I am trying to execute notepad.exe from c# through ShellExecuteEx(). But notepad is not launching. I am running code in Windows 10 64 bit OS. Does this make any difference? What could be resolution.
Below is the code i have written
SHELLEXECUTEINFO SEI = SHELLEXECUTEINFO.CreateInstance();
SEI.cbSize = Marshal.SizeOf(SEI);
SEI.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI
| SEE_MASK_NOASYNC | SEE_MASK_INVOKEIDLIST;
SEI.hWnd = 0;
SEI.lpVerb = "open";
SEI.lpFile = sbResult.ToString(); //StringBuilder notepad.exe path
SEI.lpParameters = sDocName; // txt file path
SEI.lpDirectory = "";
SEI.nShow = SW_SHOWNORMAL;
SEI.hInstApp = 0;
SEI.lpIDList = 0;
lReturnedCode = ShellExecuteEx(ref SEI);
WaitForSingleObject(SEI.hProcess, INFINITE);
There's no need to use ShellExecuteEx()
. You can use Process.Start() :
Process proc = Process.Start("notepad.exe", sDocName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.