I don't really understand any of the code above, but to me it seems to be saying that to connect it needs to change your display settings to 16 bit colour and 640X480 resolution. Also it needs to be able to access the "open glide" facilities of your graphics card.
Have you changed anything lately? Try opening the properties of your graphic card and set the Resolution to "Optimal" Rather than a fixed one of 75 or 85 hz, this will at least enable your resolution to change back and forth with each change of display setting. j.