shellexecute

How to get AppPath to Executable file's directory using C language on Windows (using MinGW gcc )

你说的曾经没有我的故事 提交于 2019-12-13 20:05:03
问题 My executable file is in this place --> D:\Examples\C_Pro\newApp.exe Also in that "C_Pro" folder contain several files ( file1.txt, file2.txt, file44.exe, newApp.c ) In my newApp.c file, I includes a ShellExecute Function to execute "file44.exe" file in same folder like this --> ShellExecute(NULL,"open","D:\Examples\C_Pro\file44.exe",NULL,NULL,1) in this way all work properly.. I'm talking about AppPath like thing in VB But the case is I want to run this newApp.exe on different pc's So I want

Using ShellExecuteEx to open an executable, also specifying an lpClass?

半腔热情 提交于 2019-12-13 07:23:32
问题 I have read this and understand lpClass can be used to fix the "wrong file extension issue". However, when I am reading the following lines of code, I can't figure out what lpClass is used for when opening an executable file . //code excerpt from foo.exe SHELLEXECUTEINFO info; ZeroMemory(&info, sizeof(SHELLEXECUTEINFO)); info.cbSize = sizeof(SHELLEXECUTEINFO); info.nShow = SW_NORMAL; info.lpVerb = L"open"; info.lpClass = L"ProgId Of foo.exe"; //what is this used for??? info.fMask = SEE_MASK

How to replicate ShellExecuteEx failure with ERROR_NO_ASSOCIATION error?

放肆的年华 提交于 2019-12-13 02:58:04
问题 My application displays a report to its end-users by composing it into an .htm file that is placed into a user's temp folder (that is derived by calling GetTempPath API). It is then shown to the user with the code as such: //strCmd == file:///C:/Users/UserName/AppData/Local/Temp/My_Report.htm SHELLEXECUTEINFO sei = {0}; sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_FLAG_NO_UI; sei.nShow = SW_SHOW; sei.lpVerb = L"open"; sei.lpFile = strCmd.GetBuffer(); sei.hwnd = hParentWnd; BOOL bInitialized

Why Desktop.Open() doesn't work with MagicISO being installed

China☆狼群 提交于 2019-12-12 11:06:27
问题 Here's my code if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { try { desktop.open(file.getCanonicalFile()); } catch (Exception ex) { ex.printStackTrace(); } } else { System.out.println("Desktop open action is not supported"); } } else { System.out.println("Desktop is not supported"); } I know that installing MagicISO (got it from this Java bug) will make this code doesn't work. But why? What does MagicISO

Print PDF file in duplex mode via Python

孤者浪人 提交于 2019-12-11 18:35:46
问题 I have an script in Python that prints PDF files. The script works using win32api.ShellExecute() and everything is fine, but now, I need to print PDF files that have double sided content, user manuals in concrete. I have tried setting the duplex mode in win32print, but nothing works, the printer still print 2 pages on 2 sheets for my PDF instead of two pages on a double sided sheet. The printer works with this mode in other applications, but with the python script doesn't work well. This is

How do I execute a program from Python? os.system fails due to spaces in path

帅比萌擦擦* 提交于 2019-12-11 16:41:45
问题 I have a Python script that needs to execute an external program, but for some reason fails. If I have the following script: import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); Then it fails with the following error: 'C:\Temp\a' is not recognized as an internal or external command, operable program or batch file. If I escape the program with quotes: import os; os.system('"C:\\Temp\\a b c\\Notepad.exe"'); raw_input(); Then it works. However, if I add a parameter, it stops

Process.Start with 'UseShellExecute = true' doesn't return for corrupt word documents

ぐ巨炮叔叔 提交于 2019-12-11 12:58:07
问题 I am trying to print pdf, ppt, and word documents from my windows service using ShellExecute. Process printingProcess = new Process { StartInfo = { FileName = filePath, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, UseShellExecute = true, Verb = "Print" } }; printingProcess.Start(); This works in most cases. But for word documents that are corrupt, the Process.Start method never completes and the service hangs. Basically, word pops up the "bad document! repair" dialog. I

How can I set scheduledtask without prompting for a password

一个人想着一个人 提交于 2019-12-11 08:14:19
问题 I have an application which needs to set a scheduled tasks in Windows. For this I have used the ShellExecute function to call the schtasks.exe I have used the following code : ShellExecute(NULL, _T("open"), _T("schtasks.exe"), _T("/create /TN SampleSchedule /TR calc.exe /SC DAILY /ST 12:15:00 /SD 09/04/2012"),_T(""),0); but it has not created the scheduled task. But when I changed the last parameter of ShellExecute function (display command prompt) to 1 ShellExecute(NULL, _T("open"), _T(

Why do I get file not found excpetion with Interaction.Shell method?

早过忘川 提交于 2019-12-11 07:37:46
问题 I want to open a notepad file using VisualBasic.Interaction.Shell method. At present I get a file not found exception using the following code. int pid = Interaction.Shell(@"D:\abc.txt", AppWinStyle.NormalNoFocus, false, -1); But this works: int pid = Interaction.Shell(@"notepad.exe", AppWinStyle.NormalNoFocus, false, -1); Which just opens a notepad file. Why is this? I do need it to open a file in a specific location. I see some advantage with Interaction.Shell execution. How is it possible

How can I print HTML files to a specified printer using shellexecute?

可紊 提交于 2019-12-11 07:32:15
问题 I have an application that has records that can have a number of attachments associated to them, which may be a collection of JPG, TIF, PDF or HTM files (theoretically this list is arbitrary, and these are the most typical types). One of the actions I need to be able to do is to allow these to be printed en mass to a specific printer. For most file types, I can emulate the shell and perform the same action as had they dragged the file and dropped it onto a printer in explorer, by using the