Detection of an installed program
-
How can we detect from our program that a prerequired program such as dotNetFrameWork3 or 4 is installed and also is active now or not? thanks
Create an installer for your program and let this installer check the required framework for you - Add Prerequisites of .NET Framework in Visual Studio Setup Project[^].
WP7.5 Apps - XKCD | Calvin | SMBC | Sound Meter | Speed Dial
-
The system will do it for you. If the framework is not installed then your program will not even start.
One of these days I'm going to think of a really clever signature.
-
Create an installer for your program and let this installer check the required framework for you - Add Prerequisites of .NET Framework in Visual Studio Setup Project[^].
WP7.5 Apps - XKCD | Calvin | SMBC | Sound Meter | Speed Dial
-
Shameel wrote:
Technically inaccurate.
On the contrary, the actual program will not start. The system will receive a request to start it, and the loader will check for prerequisites and abort the loading when it discovers that a required library is not present. The point being that the user code will never get control in order to 'see' this problem.
One of these days I'm going to think of a really clever signature.
Richard MacCutchan wrote:
On the contrary, the actual program will not start.
The actual program WILL start and execute a native bootstrap that loads the mscoree.dll (which is Framework version agnostic). It is this dll that actually checks if the supported Runtime is installed and displays a message box if it is not installed.
Richard MacCutchan wrote:
the point being that the user code will never get control in order to 'see' this problem.
Agree.
-
Richard MacCutchan wrote:
On the contrary, the actual program will not start.
The actual program WILL start and execute a native bootstrap that loads the mscoree.dll (which is Framework version agnostic). It is this dll that actually checks if the supported Runtime is installed and displays a message box if it is not installed.
Richard MacCutchan wrote:
the point being that the user code will never get control in order to 'see' this problem.
Agree.
So the program still never gets started, the only thing that gets any control is the framework that is wrapped round the app. My point was to show that the user code has no way of checking whether a required feature is present or not. Which, after all, is what the questioner is asking about.
One of these days I'm going to think of a really clever signature.
-
As I mentioned before, FrameWork was just an example. In general, how is it possible to check that a dll which is not even famous, is running or not?
DLLs do not 'run', they are loaded by the system when an application attempts to call a function within the DLL. Alternatively an application can load the DLL and make 'unlinked' calls to functions using the
LoadLibrary()
[^] and associated functions. This is true in native applications but I'm not sure that it is particularly straightforward in .NET based applications. Perhaps a clearer explanation of what you are trying to achieve would help.One of these days I'm going to think of a really clever signature.
-
DLLs do not 'run', they are loaded by the system when an application attempts to call a function within the DLL. Alternatively an application can load the DLL and make 'unlinked' calls to functions using the
LoadLibrary()
[^] and associated functions. This is true in native applications but I'm not sure that it is particularly straightforward in .NET based applications. Perhaps a clearer explanation of what you are trying to achieve would help.One of these days I'm going to think of a really clever signature.
-
You are right, assume that a program wants to check out a printer driver is loaded or not?
Though Enumerating All Device Drivers in the System[^] is in C++, I'm sure you could implement this in C#. You may want to look into this. A code sample at http://www.pinvoke.net/default.aspx/psapi.enumdevicedrivers[^] in C#, hope this sheds some light for you :)
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
-
How can we detect from our program that a prerequired program such as dotNetFrameWork3 or 4 is installed and also is active now or not? thanks
Based on your other responses your question is imprecise. There are many things that at application either requires or desires. The impact on the application on those depends on the nature of the item itself. As an extreme example if you have compiled windows binary it will not run on a BASIC-STAMP. It is also ridiculous to even consider that case. The needs can be broken into the following 1. It will always be on the target system 2. It will often be on the target system 3. It will sometimes be on the target system. What your application does based on the above depends on the need. Choices are. 1. Do not run. 2. Run but do not enable certain functionality. 3. Run and provide default functionality. 4. Inform the user and ask them to install the functionality. You can attempt to minimize problems by creating an appropriate installer. The nature of that installer depends on the decisions related to the above. But in general the installer must check for the specific functionality and then install it. How it does that still depends on the nature of the resource though. And all of the above also is impacted by the license of the specific resources.
-
You are right, assume that a program wants to check out a printer driver is loaded or not?
-
How can we detect from our program that a prerequired program such as dotNetFrameWork3 or 4 is installed and also is active now or not? thanks
I wouldn't bother; I'd just write the app normally and if something is missing it will throw an Exception. For instance, if my app tries to use the ACE engine to query an Access or Excel file, if ACE isn't present I get an Exception explaining this.