Check if VLC is installed - c#

I'm calling vlc from a C# app in order to play a video. I need a way to consistently check if VLC is installed. I've tried checking registry keys, but they don't seem to be consistent or reliable depending on your Windows version or architecture. Anyone have any suggestions/advice?

I'd say you're doing unnecessary work in trying to detect this. What are you going to do if VLC is not installed? Show an error message? Then just try to launch it, and show an error message if it fails to launch. That way, you also capture the case where it is installed, but still fails to launch for whatever reason. Both are error conditions for your program.
Beyond that, make sure that you include a setup program with your application that automatically installs VLC, since your application requires it to work properly. Then, the only situation where it wouldn't be installed (and thus your application would have to show an error message) is if the user explicitly removes it after installation. Since they would have to do so intentionally, it's very unlikely they would be surprised when your application subsequently failed to work.

I ended up just checking HKLM\Software\VideoLAN\VLC\ on machines I could find it and giving the user an option in the settings to specify the path to VLC manually if it wasn't detected from that registry value.

Related

Monodevelop crashes when I type the letter "o" instead of an integer

Working with Monodevelop has been a nightmare overall. But among all the crashes, I have been able to recreate one of them reliably.
It seems like when I type "o" (the letter) when Monodevelop expects me to type an integer it will always crash.
Examples:
if (spriteRenderers.Length == o <----*CRASH*
for (int i=o <----*CRASH*
Now, of course, this typically only happens when I've made a mistake, but it does seem to be causing the crash.
And by "crash" I mean that Monodevelop stops working, and I get an error message from Windows asking if I would like to force quit the application. Upon re-opening Monodevelop it shows a blank white screen (every time).
The only fix I've found for the white screen is to delete the "Assembly-CSharp..." files in the project folder and then resync the Monodevelop project in Unity3D. I sometimes have to repeat this up to 10 times before Monodevelop will work again, and about half the time I lose a significant amount of work as a result.
Has anyone else experienced something similar? Any ideas on how to prevent this type of crash?
PS: It also tends to crash a lot when I'm typing "default" within a switch statement, but not every time like the "o" instance above.
If typing a specific letter crashes monodevelop there's certainly something going totally wrong here. First, confirm whether typing 'o' crashes monodevelop anywhere in any situation. Because I find it hard to believe that it crashes only when you type o where 0 is expected - because how would monodevelop know what is "expected" in a given situation? So unless that is confirmed, I assume this is not what is actually going on but rather something that you've came to conclude due to confirmation bias (ie it happend two or three times by chance in a situation where you intended to type 0 rather than o).
That said, check if any keyboard shortcut has been assigned to the letter o. You may want to reset keyboard shortcuts to their default. In general you may want to reset all preferences just to ensure monodevelop is using safe defaults for everything. Also check any plugin you may have installed, and disable them if only for testing.
You should also try shutting down Unity, and only run monodevelop. Then create a standalone project in monodevelop (ie C# windows app) to see if the problem also appears in "regular app development mode".
Lastly, upgrade Unity. If you are already on 4.6, get the latest "patch release" from the download page. This might also give you an updated monodevelop.
If all of that does not help, you may want to try Xamarin - the latest version of monodevelop. You can integrate that with unity by installing its Unity plugins, but currently it will not allow you to debug with Unity. In any case it installs itself side-by-side, so you should at least try that to see whether that has a similar problem.
If all of that fails, consider that the problem may be with your system. For instance a tool might have set a global keyboard shortcut on the letter o. A virus scanner or system driver may somehow interfere. Or the whole system is just whacky, perhaps a trojan, a hardware failure, and so on. That is all rather speculative, so at this point it's a matter of trial and error.

DirectX End-User Runtimes Redistributable Exit Codes

Can anyone point me to a list of exit codes for the DirectX End-User Runtimes (specifically the June 2010 version, if it matters)? I apologize in advance if this is a simple matter (it should be), but apparently my google skills are sub-par as I have been unable to find them.
For bonus points:
I'm trying to use InstallShield LE to create an installer for a game I am working on. I downloaded the DirectX End-User Redistributable (June 2010). This redistributable has the user install/extract the DX files to a location they specify with the expectation that the user will then manually run the DXSETUP.exe that is extracted to that location. I handle this silently in a custom action with a location that I have specified (with the intent to clean up these files in a later custom action).
From here, I would like to run the DXSETUP.exe from the location that I specified and respond appropriately to any errors that it encounters (display a message to the user that will help them with their specific problem). I'm currently using a C# executable that I have created to run the DXSETUP.exe, which is run from ISLE via a custom action. Since I couldn't find a list of the possible exit codes for DXSETUP.exe, I decided to display a generic message whenever a non-zero (unsuccessful) exit code is encountered which will contain the exit code returned by DXSETUP.exe. Normally, I would call it a day and wait until users start contacting me with error codes, but this setup does not cover a very specific case.
Apparently, if the user cancels the DXSETUP.exe, it returns an exit code of 0, which is supposed to indicate success. I do not know how to detect/deal with this circumstance. As-is, my game's installer will continue to run happily, leaving the user unable to play the game after the installer finishes due to missing DX files.
I apologize if this came out a bit verbose, but hopefully it clearly and adequately explains my situation.
Don't give the user the chance to cancel by running dxsetup.exe with the /silent flag. This is recommended as a best practice by Microsoft.

Detecting raised-event at OS-level (OS Appearance)

I have what seems to be a common problem. I am running Windows 7 Home Premium on one of the most awesomest computers (when it was bought last year) and certain visual effects just automatically turn themselves off.
My average user experience rating is high, so it doesn't explain why this happens. The only feature that ever gets turned off is the 'Show window contents while dragging' option. And it really annoys me.
There are currently no working solutions to this problem online. Other than to "there must be a conflict with another app installed on your machine."
And yes, I do know what app is causing this conflict. It's my bloody Internet Provider's software - you know... that app that you absolutely MUST have open at all times when you're connected to the net.
So, I had a thought. What if I could subscribe to an event so that my app that runs in the background will detect when this 'show window contents while dragging' option is turned off - and then my app will simply turn it back on again.
When I do this manually, it seems to stay in effect for about an hour or two, then it gets switched off again.
Is it possible to handle these types of events, and re-start certain visual effect features? If so, are there any resources on this?
I have not been able to find anything on this sibject yet.
Yes the WM_SETTINGSCHANGE message is sent to all windows when a system setting is changed. Then you can call SystemParametersInfo with SPI_GETDRAGFULLWINDOWS to determine if the "Show window contents while dragging" is disabled and use SPI_SETDRAGFULLWINDOWS to enable it.
So all that you will need to do is create an application with a form (that can even stay hidden) and override the forms WndProc and handle the WM_SETTINGSCHANGE message and call SystemParametersInfo using p/Invoke. The p/Invoke definition for SystemParamtersInfo is available at pinvoke.net
Altough what may be easier is change security on the HKCU\Control Panel\Desktop\DragFullWindows registry value so that it can't be changed.

Is there a way to set the compatibility mode in Win7 programmatically in C#

I am working on a program. In testing it on Win7(32-bit, don't know if it will be the same in 64-bit) I found a problem.
Now my problem is that some of the functionality does not work(like the right click doesn't show options or the program takes long to react). If however I set up a the compatibility mode it works fine. I mainly see this problem in Microstation, but it does appear in other places as well.
My question is as follows, is there a way to set these settings(like the check boxes) programmatically from C# ?
This might be necessary in cases where we do not do the installation of the program, to insure that it works on every pc it is installed on. Let us assume that during the installation the program has admin rights. (would it be needed to do this??)
this has nothing to do with Internet Explorer. i wanted to add a picture, but i dont have enough rep yet
There is no way to change this while the application is running, you have two choices to handle this issue:
Modify the installer to create shortcuts that have the compatibility mode flag set to whatever you need
You can manually manipulate the registry to force an executable to use compatibility mode, your application will require admin rights todo so + will need to restart afterwards
Here it's explained how todo it manually, you simply have to do it programatically:
http://kb.winzip.com/kb/entry/139/
In general I discourage you from doing either, fix your bugs instead.

Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException)

I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results).
We make use of a .DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is This from AzSdk.
In fact, this works perfectly under Windows XP. However, for some strange reason, inside our project (way bigger), we get this exception:
Exception Type: System.DllNotFoundException
Exception Message: Unable to load DLL 'HardwareID.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
Exception Target Site: GetHardwareID
I don't know what can be causing the problem, since I have full control over the folder. The project is a c#.net Windows Forms application and everything works fine, except the call for the external library.
I am declaring it like this: (note: it's not a COM library and it doesn't need to be registered).
[DllImport("HardwareID.dll")]
public static extern String GetHardwareID(bool HDD,
bool NIC, bool CPU, bool BIOS, string sRegistrationCode);
And then the calling code is quite simple:
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = GetHardwareID(cb_HDD.Checked,
cb_NIC.Checked,
cb_CPU.Checked,
cb_BIOS.Checked,
"*Registration Code*");
}
When you create a sample application, it works, but inside my projectit doesn't. Under XP works fine. Any ideas about what should I do in Vista to make this work?
As I've said, the folder and its sub-folders have Full Control for "Everybody".
UPDATE: I do not have Vista SP 1 installed.
UPDATE 2: I have installed Vista SP1 and now, with UAC disabled, not even the simple sample works!!! :( Damn Vista.
Unable to load DLL 'HardwareID.dll':
Invalid access to memory location.
(Exception from HRESULT: 0x800703E6)
The name of DllNotFoundException is confusing you - this isn't a problem with finding or loading the DLL file, the problem is that when the DLL is loaded, it does an illegal memory access which causes the loading process to fail.
Like another poster here, I think this is a DEP problem, and that your UAC, etc, changes have finally allowed you to disable DEP for this application.
#Martín
The reason you were not getting the UAC prompt is because UAC can only change how a process is started, once the process is running it must stay at the same elevation level. The UAC will prompt will happen if:
Vista thinks it's an installer (lots of rules here, the simplest one is if it's called "setup.exe"),
If it's flagged as "Run as Administrator" (you can edit this by changing the properties of the shortcut or the exe), or
If the exe contains a manifest requesting admin privileges.
The first two options are workarounds for 'legacy' applications that were around before UAC, the correct way to do it for new applications is to embed a manifest resource asking for the privileges that you need.
Some program, such as Process Explorer appear to elevate a running process (when you choose "Show details for all process" in the file menu in this case) but what they really do is start a new instance, and it's that new instance that gets elevated - not the one that was originally running. This is the recommend way of doing it if only some parts of your application need elevation (e.g. a special 'admin options' dialog).
Is the machine you have the code deployed on a 64-bit machine? You could also be running into a DEP issue.
Edit
This is a 1st gen Macbook Pro with a 1st gen Core Duo 2 Intel processor. Far from 64 bits.
I mentioned 64 bit, because at low levels structs from 32 bit to 64 bit do not get properly handled. Since the machines aren't 64bit, then more than likely disabling DEP would be a good logical next step. Vista did get more secure than XP SP2.
Well, I've just turned DEP globally off to no avail. Same error.
Well, I also read that people were getting this error after updating a machine to Vista SP1. Do these Vista installs have SP1 on them?
Turns out to be something completely different. Just for the sake of testing, I've disabled de UAC (note: I was not getting any prompt).
Great, I was actually going to suggest that, but I figured you probably tried it already.
Have you made a support request to the vendor? Perhaps there's something about the MacBook Pro hardware that prevents the product from working.
Given that the exception is a DllNotFoundException, you might want to try checking the HardwareID.dll with Dependency Walker BEFORE installing any dev tools on the Vista install to see if there is in fact a dependency missing.
In addition to allowing full control to "Everyone" does the location also allow processes with a medium integrity level to write?
How do I check that ? I am new to Vista, I don't like it too much, it's too slow inside a VM for daily work and for VStudio usage inside a Virtual Machine, it doesn't bring anything new.
From a command prompt to you can execute:
icacls C:\Folder
If you see a line such as "Mandatory Label\High Mandatory Level" then the folder is only accessible to a high integrity process. If there is no such line then medium integrity processes can access it provided there are no other ACLs denying access (based on user for example).
EDIT: Forgot to mention you can use the /setintegritylevel switch to actually change the required integrity level for accessing the object.

Categories

Resources