I am trying to open windows 7 help from a .Net form application to a specific bookmark, at printer installation for example.
I tried to open it in the same whay that I open Control Panel applets (Back & Restore in the example below).
ProcessStartInfo startInfo = new ProcessStartInfo(#"c:\windows\system32\control.exe", "/name Microsoft.BackupAndRestore");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
But it doesn't work.
I didn't succeed neither to open the .exe.
Does anyone know how to do this?
IIRC HelpPane.exe works with .h1s files so if you have full path to such a file you can just use for example Process.Start (#"C:\myDir\myhelpfile.h1s"); to open it.
According to MS another option (most likely the recommenced one) is to host the HelpPane (which is basically a COM object!) - for details see http://msdn.microsoft.com/en-us/library/ms728715%28v=VS.85%29.aspx
Other important MSDN links are:
http://msdn.microsoft.com/en-us/library/bb757030.aspx
http://msdn.microsoft.com/en-us/library/ms728718%28v=VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms728713%28v=VS.85%29.aspx
From the above links:
The Help Pane API can only be used to display the Windows Help content
set. It can be customized by OEMs, system builders, and enterprise
customers under license agreement, but cannot be used by third-party
programs. Displaying content that is not part of the Windows Help
content set is not supported.
Depending on what you want to achieve you might need to first sign a license agreement with MS...
EDIT - as per comments:
To display a specific topic you need to call the method DisplayTask of the COM object with the URL of that topic.
EDIT 2 - as per comments the final solution:
Add a reference to C:\Windows\System32\HelpPaneProxy.dll to the project then you can use the HelpPane like this
HxHelpPane pHelpPane = new HxHelpPane();
pHelpPane.DisplayTask("mshelp://windows/?id=e725b43f-94e4-4410-98e7-cc87ab2739aa");
Related
I work for an IT company where we all carry around flash drives that have our most used programs on them.In my spare time I am hoping to create a "main menu" item that is kind of a fun and convenient way to access these files. I am working on creating this using Visual Studio 2013 and using visual C# windows forms. I have come across a snag however that I can't seem to find a workaround for. I am by no means fluent in C#, but I need to have a button on the windows form open a file without specifying what drive it comes from. I understand that I have to specify a path, but as these will be stored on the flash drives of myself and my coworkers I cannot foresee that the path will always begin with E:. Depending on what USB slot the drive is plugged into it could be N: or F: or the like. I have provided an example below:
Using what I currently know I am opening files using this line of code:
System.Diagnostics.Process.Start("C:/Users/Myname/Desktop/Asmodeus/Anti-Virus/Anti-Virus Installers/avast_free_antivirus_setup.exe");
Is there any way possible I can have the file open simply from
System.Diagnostics.Process.Start("Asmodeus/Anti-Virus/Anti-Virus Installers/avast_free_antivirus_setup.exe");
or something of that nature?
Thanks in advance.
There must have been some mis-communication when I asked my question previously. what I am looking to do is open an executable file via a button click on the windows form using a relative path. I am not able to specify the absolute path because the application will be run from a flash drive and therefore will change depending on what USB slot it is currently inserted into.
What I am hoping to accomplish is insert a line of code that will allow me to open an executable file that is located in the \bin\debug folder along with the application itself. I have a picture for clarification but apparently do not have enough reputation to post it. Thank you and sorry for the earlier confusion.
Usually you can just use Environment.GetFolderPath (MSDN) to give you what you need. It doesn't do absolutely everything, but if you need Desktop and the like, that is plenty.
Depending on the target version of .Net, the SpecialFolders exposed are not all there. It may turn out that you need more than they provide, but in your case it doesn't sound like it.
If there is more you need that is not covered in the default, check out this project. I'm sure there are others like it, but it does a little more than the default BCL version, using the API directly. It is at least something to read and learn (and translate from vb.. use an online translator, very quick). I haven't looked at it, but it seems like you are learning this c#/.net thingy, so it might be helpful
This article is about accessing Windows special folders.
These folders include your “Favorites”, “Cookies”, system libraries and the like.
Here is code, including a large number of constant definitions, plus documentation,
allowing access to and creation of these folders.
I'm trying to open something in ie via
System.Diagnostics.Process.Start("iexplore.exe", uniquePartOfUrl);
However this doesn't account for the fact a window is already open, if it is then I want to just use that. How could this be done?
IMO, the best way to open a web page is to use the following syntax:
Process.Start("http://www.mysite.com");
This way the OS will open it in the users default browser, and use the browsers tab functionality if it has that capability. Nothing annoys me more (ok, maybe some things do) than programs that force me to use a specific browser for no good reason, when I already selected which browser I want to use already. Honoring the users decision here is a good thing.
On CodeProject, there exists a project to "Capturing the Running IE Instances in C#"
It gives you one way to do it.
Using the WIN32 API, you can enumerate the windows opened, and filter them to get the running instances of IE.
It may be helpful for you.
You can try something like this:
var p = new System.Diagnostics.Process();
var s = new System.Diagnostics.ProcessStartInfo(uniquePartOfUrl);
s.UseShellExecute = true;
s.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo = s;
p.Start();
I don't have a compiler handy to test it right now, but the idea is that it should simply tell the OS to "open this URL" and let the OS decide how, which may use the existing window depending on the application. Worth a shot.
For reusing an existing window of IE, you can approach it in 2 different ways
Find the current instance of IE and then open it using that instance. This is covered by the answer given by #LaGrandMere
Set IE using the inbuilt settings to make it reuse itself. For using this method, you can follow the instructions given at this Microsoft support article.
I am currently hosting an IE Browser control in a .NET (2.0) Form and using it to load Office files such as Excel and Word thusly:
_ieCtrl.Navigate("C:\\test.xls", False);
The hosting and loading works well except whenever I navigate to a file I am presented with a dialog that asks whether I want to save or open the file. (This is standard IE file-download behavior.) I always want to open it of course and I do not want the dialog to show.
Another issue is that when I close the window that hosts the IE control and the Office doc the document does not close and remains open on disk. This means that subsequent attempts to open the same file via my app or the native office app will fail because of the sharing violation.
Is there a programmatic way of avoiding this dialog and cleaning up resources afterward? I am asking for a programmatic answer because web research has only yielded solutions that entail modifying OS-level settings.
Bounty NOTE:
I am open to any solution to this issue that will allow me to:
Host an Excel spreadsheet inside my application
Work rather transparently (avoid usability issues like the one described above)
Avoid having to make any OS-specific changes that may affect other applications (especially icluding IE)
Is zero additional cost (no licensed 3rd party libs please) Code Project and other open source resources are OK
Not mess around with the DSO Framer ActiveX control, unless a stable version is developed/discovered
Is your intention for the user to be able to work with the Excel file in an Excel-ish way (i.e. columns, rows, formulas, etc.), possibly saving it back? If this is the case, I can't see how you can solve this problem well without relying on COM Interop with the Excel object model or by integrating third-party libraries to work with the Excel sheet. I know you said no paid solutions, but there are some feature-rich 3rd-party controls out there just for working with Excel files within applications.
I noticed in your comment to SLaks that the final product is a "dashboard of sorts". If your intention is to design a a custom dashboard application, have you considered parsing the Excel file(s) to extract the data and then presenting it in a logical manner within your application. This removes the need to directly display and work with the Excel file while still allowing you to work with the data inside that file. If you are trying to get the data outside of the file, here are two approaches among many:
You might consider using the Excel object model and COM interop to read the data from the Excel file into your application. Granted, this includes a dependency on Excel being installed, but it is a possibility. This article has some great code for getting started with reading Excel files in this way.
A better way might be to use a library that doesn't have a dependency on Excel being installed on the local system. This answer suggests using the Excel Data Reader library, available on CodePlex.
I know this answer side-steps your original answer of "hosting MS Office documents in [a] custom app," but in case what you're really interested in is the data inside those Excel files, hopefully this answer will prove helpful.
This is a horrible hack and should only be considered as a last resort: SendKeys.Send("{O}");
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys%28VS.71%29.aspx
Something similar to
_ieCtrl.Navigate("C:\\test.xls", False);
(code to sleep or wait may be needed here)
SendKeys.Send("{O}");
Basically, you send the "o" key to the dialog so it presses the "open" option. You are simulating a keyboard presses to click the "open" button. It is hackey because
1) you may need to wait in between
calls. If you send the o key before
the dialog is up it will be missed.
Hopefully the navigate call is finished when the dialog pops (dont know behavior of control in c#). You may need to experiment with the time since different computers will open faster\slower
2) If the dialog is not shown on a
computer, you will be inserting "o"s
into it. This may cause problems when
exiting because it may popup another dialog to try and save
the changes. May be able to prevent this by opening it in read-only mode
3) Different versions or windows may need different sendkeys commands. For example, you may need to send "o" and them the "{enter}" key
4) Probably more :)
If you want to open the file in a separate Excel instance (not embedded in the WebBrowser control), you can simply call
Process.Start(#"C:\Test.xls");
Office was never meant to run in embedded mode, not in a web page or in an ActiveX Document host. Microsoft had time and time again given us the warning. From pulling dsoframer from the knowledge base to skipping the BrowserFlags registry key in Office 2007.
Move to Office add-ins, Excel Web Access or Office Web Apps as quickly as you can.
I am using the Windows API Code Pack for Microsoft .NET Framework to try out of some of the new UI features of the Win7 taskbar. I am coding in C#.
I have a question regarding jumplists. All of the sample code provided assumes that the entries on the jump list are used to call out to run a particular application or open a document, e.g. a text document in a MRU list or run mspaint.exe.
I would like to implement some items which allow me to set state in my own application (i.e. the app which is interacting with the taskbar). MSN Messenger does this, for example, when you can set your status (Busy, Offline etc.).
Try as I might, I cannot create a JUmpListItem or JumpListLink to behave in this way - it treats them as applications or documents.
Does anyone have any samples of how to create an item which raises an event in the same application that created it? I am sure it is simple but I am being very daft.
Many thanks for your help.
I believe what you'd want to do is to call your application with a special set of flags (i.e. launch the executable with certain arguments). At application start up, you'd check to see what flags are set, then send a message to the main instance of the application and then exit out of the new instance.
Using the TaskBarDemo, to open an item created by your application would have to be referenced, ie if your program created a PDF file you would do this:
jumpList.AddUserTasks(new JumpListLink(Path.Combine(systemFolder, "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRD32.exe"), "Open Adobe Reader")
{
IconReference = new IconReference(Path.Combine(systemFolder, "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRD32.exe"), 0)
});
Otherwise you would have to ensure that your application registered file associations, for recent or frequent items.
I had a few problems with jumplists with the API Pack, i now use VS 2010 Beta 2 and let shell handle the jumplists.
Hope this is helpfull.
These tasks are some sort of IShellLink. Then, you should call ICustomDestinationList's AddUserTasks. Look up samples in Windows 7 Training Kit.
How to open files from explorer into different tabs. I can associate an open with menu with the file type, now when I already have the program working, how to open the new file into another tab, instead of new program.
How to find the already running process exactly, not with the name and send the filename to it.
Let me make myself clear: I want my app to be single instance, so that when user select 10 text files and press enter key, my application will open all the 10 text files into 10 tabs, instead of creating 10 processes. How to do that? How to communicate between various instances of the same process.
EDIT SOLVED: Implemented the functionality using WM_COPYDATA in C# and the SingleApplication class from codeproject.
I am not quite sure what you mean in this question. Are you trying to open Windows Explorer windows into one window with tabs? If that is the case, then I recommend you look into QT TabBar, which extends Windows Explorer to allow for such behavior.
Or perhaps you are trying to have a link open to a new tab in a web browser. If that is the case, this behavior is defined by the web browser itself. For Internet Explorer 7, you can set this behavior under Tools > Internet Options.
In the General tab, click the Settings button next to the "Tabs" section. You will want to set the "Open links from other programs in:" option to open a new tab.
Keep in mind that this behavior is defined by each user, and you can't ever make any guarantees that they will have the same browser settings as you do.
After reading your comments, I think I understand a bit better. It sounds like you want your application to only allow one instance at a time. Since you tagged this post C#, I will assume that is what you are writing your program in.
Codeproject.com has a great tutorial on how to make your program only allow a single instance.
Here is a snippet of code from their site:
static void Main()
{
if(SingleInstance.SingleApplication.Run() == false)
{
return;
}
//Write your program logic here
}
You would want to write code just before the return statement to have the existing instance open the file in a new tab.
If you are able to provide detailed information about what your program is doing, we might be able to help you with some of the specifics.