shellexecute

Open default browser as standard user (C++)

纵然是瞬间 提交于 2019-12-21 05:42:10
问题 I'm currently using ShellExecute "open" to open a URL in the user's browser, but running into a bit of trouble in Win7 and Vista because the program runs elevated as a service. When ShellExecute opens the browser, it seems to read the "Local Admin" profile instead of the user's. So for example, if the user at the keyboard has Firefox as his default browser, it may open IE (which is the admin's default). I know that the "runas" verb can be used to elevate, but how do you do it the other way

How to Print any document in a SELECTED printer

ⅰ亾dé卋堺 提交于 2019-12-21 04:55:14
问题 I would like to print any document such as pdf,word,excel or text files in a selected printer using .net .I have got success to do such printing in the default printer .The only issue now is to print in the selected printer. Here is the code for the printing. public bool Print(string FilePath) { if (File.Exists(FilePath)) { if (ShellExecute((System.IntPtr )1, "Print", FilePath, "", Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32() <= 32) { return false; } else { return true; } }

How to get the Handle that is executed in winexec or shellexecute?

强颜欢笑 提交于 2019-12-20 05:49:27
问题 i use to create a custom function like winexec(...):Hwnd that will retun the handle of executed application. i did use the findwindow() but having problem if it change window caption. 回答1: There is no general way to get "the" window handle of an application because there's no guarantee that any program has one window handle. A program may have many top-level handles (i.e., Microsoft Word, one for each document), or it may have no windows at all. You might question what you really need the

C++ open link with ShellExecute

泄露秘密 提交于 2019-12-20 03:23:11
问题 If I write like this: ShellExecute(NULL, "open", "www.google.com", NULL, NULL, SW_SHOWNORMAL); Everything's okay and is as it has to be. But I want so that user could enter a link where he wants to go. std::cout<<"Enter the link: "; char link; std::cin>>link; ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL); In this case I get an invalid conversion from 'char' to 'const CHAR* error. So, is there a way to do this properly? 回答1: Your code only gets one character in as the link. You

.net cf - launch explorer programmatically

淺唱寂寞╮ 提交于 2019-12-20 03:22:20
问题 I am trying to launch explorer programmatically from my .Net CF Window application. But its throwing win32 exception. I have used same kind of code in desktop .Net version, and it always worked. (I am using Windows CE 5 and .Net CF 3.5 ) Following code throws Win32 Exception, Process.Start("\\", null); Unfortunately, I am using the code like this :-( try { Process.Start("\\", null); } catch { } 回答1: Maybe you should give it a program name to start? "\" is not an application. Something like

How do I perform a shell execute in a chrome extension?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 10:56:24
问题 I'm not finding a way to do this in the chrome.* API or even the experimental. It doesn't run through wscript so ActiveXObject("Shell.Application") isn't allowed. I fear that my only option is to build a dll with NPAPI but I wanted to see if there was a simpler way. 回答1: If you want to do anything Natively, you need to use NPAPI. That allows you to run code outside the sandbox for your extensions. http://code.google.com/chrome/extensions/npapi.html 回答2: To update this for a fellow wary

How to Pass parameters for a Ant script , which is invoked via shell script?

旧城冷巷雨未停 提交于 2019-12-18 10:22:39
问题 I need to invoke a ant script via shell script. Let us consider the parameters for ant script are a,b,c. how can i pass the parameter for those variables? I must provide the parameters for ant vis invoke the shell script. can anyone help me on this? 回答1: Do you mean assigning value to a property from command line? If so, try -DpropertyName=itsValue For example, <project> <target name="hi"> <property name="person" value="world"/> <echo message="Hello ${person}"/> </target> </project> and then

Executing another program from C#, do I need to parse the “command line” from registry myself?

夙愿已清 提交于 2019-12-18 04:25:09
问题 From the registry, for a given file type, I get a string containing something like this: "C:\Program Files\AppName\Executable.exe" /arg1 /arg2 /arg3 or sometimes: "C:\Program Files\AppName\Executable.exe" /arg1 /arg2 /arg3 "%1" In order for me to execute this program, and pass along a filename as a parameter (which I know it accepts), do I have to parse this string myself, or is there a runtime class that will do this for me? Note that I'm not asking about handling the difference between the

How to open a default dialog for window if ShellExecute fails due to no file association in C++?

爷,独闯天下 提交于 2019-12-17 20:41:47
问题 I can use the windows ShellExecute function to open a file with no problems so long as the file has a correct association. If no association exists i would like to use the default windows dialog to open the file: Is this possible? If so how? 回答1: The documented way to show that dialog is to use the openas verb. CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE); SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_NOASYNC; sei.nShow = SW_SHOWNORMAL; sei.lpVerb =

How to Run cmd.exe with parameters from javascript

眉间皱痕 提交于 2019-12-17 15:51:50
问题 I am trying to write javascript which should run cmd.exe with a specified command line in it like this docs.google.com/file/d/0B7QHCoQDlEvKWUZSX3oxUDI2SDg/edit: I prepare a code after reading shellexecute method on microsoft site: var objShell = new ActiveXObject("Shell.Application"); objShell.ShellExecute("cmd.exe", "C: cd C:\\pr main.exe blablafile.txt auto", "C:\\WINDOWS\\system32", "open", "1"); but it does not insert command line in cmd.exe. Could anybody help me? Thank you in advance.