Funkcia umožňuje použiť pre grafiku iný ovládač, ako je v základnej ponuke.
- Deklarace
InstallUserDriver(Name : string; AutoDetectPtr : pointer) : integer
- Režim
- Reálný, Chráněný
- Poznámky
Ovládač musí byť uložený v súbore, ktorého meno je v parametre NAME. Parameter AUTODETECTPTR môže udávať vstupný bod užívateľskej autodetekčnej funkcie. Táto funkcia nesmie mať formálne parametre, musí byť preložená ako FAR funkcia (direktíva prekladača {$F+}) a jej funkčná hodnota musí byť typu Integer.
Funkčná hodnota autodetekčnej funkcie udáva implicitný grafický režim inštalovaného grafického ovládača. Výsledkom činnosti funkcie INSTALLUSERDRIVER je natiahnutie špecifikovaného ovládača do dynamickej pamäte a jeho zápis do tabuľky ovládačov. Ak sú tieto akcie úspešné, je výstupná hodnota funkcie číslo ovládača. (kladná hodnota). Pokiaľ nieje možné niektorú akciu uskutočniť úspešne je výstupnou hodnotou číslo chyby 11 (GRERROR).
There are two ways to use this vendor-supplied driver. Suppose you have a new video card called the Spiffy Graphics Array (SGA) and that the SGA manufacturer provided you with a BGI device driver (SGA.BGI). The easiest way to use this driver is to install it by calling InstallUserDriver and then passing the return value (the assigned driver number) directly to InitGraph:
var Driver, Mode: Integer; begin Driver := InstallUserDriver('SGA', nil); if Driver = grError then { Table full? } Halt(1); Mode := 0; { Every driver supports mode of 0 } InitGraph(Driver, Mode, ); { Override autodetection } ... { Do graphics ... } end.
The nil value for the AutoDetectPtr parameter in the InstallUserDriver call indicates there isn't an autodetect function for the SGA.
The other, more general way to use this driver is to link in an autodetect function that will be called by InitGraph as part of its hardware-detection logic. Presumably, the manufacturer of the SGA gave you an autodetect function that looks something like this:
{$F+} function DetectSGA: Integer; var Found: Boolean; begin DetectSGA := grError; { Assume it's not there } Found := ... { Look for the hardware } if not Found then Exit; { Returns -11 } DetectSGA := 3; { Return recommended default video mode } end; {$F-}
DetectSGA's job is to look for the SGA hardware at run time. If an SGA is not detected, DetectSGA returns a value of -11 (grError); otherwise, the return value is the default video mode for the SGA (usually the best mix of color and resolution available on this hardware).
This function takes no parameters, returns a signed, integer-type value, and must be a far call. When you install the driver (by calling InstallUserDriver), you pass the address of DetectSGA along with the device driver's file name:
var Driver, Mode: Integer; begin Driver := InstallUserDriver('SGA', @@DetectSGA); if Driver = grError then { Table full? } Halt(1); Driver := Detect; { Discard SGA driver #; trust autodetection } InitGraph(Driver, Mode, ); ... end.
After you install the device driver file name and the SGA autodetect function, you call InitGraph and let it go through its normal autodetection process. Before InitGraph calls its built-in autodetection function (DetectGraph), it first calls DetectSGA. If DetectSGA doesn't find the SGA hardware, it returns a value of -11 (grError) and InitGraph proceeds with its normal hardware detection logic (which might include calling any other vendor-supplied autodetection functions in the order in which they were "installed").
If, however, DetectSGA determines that an SGA is present, it returns a nonnegative mode number, and InitGraph locates and loads SGA.BGI, puts the hardware into the default graphics mode recom-mended by DetectSGA, and finally returns control to your program.
- Viz také
- GraphResult
- InitGraph
- RegisterBGIdriver