Differenze tra le versioni di "Individuare con le funzioni dell'API di SDL i drive CD-ROM connessi al sistema"
Da Gambas-it.org - Wikipedia.
(Una versione intermedia di uno stesso utente non è mostrata) | |||
Riga 26: | Riga 26: | ||
<FONT color=gray>' ''void SDL_Quit(void)'' | <FONT color=gray>' ''void SDL_Quit(void)'' | ||
' ''Clean up all initialized subsystems.''</font> | ' ''Clean up all initialized subsystems.''</font> | ||
− | Private Extern SDL_Quit() | + | Private Extern SDL_Quit() |
Riga 39: | Riga 39: | ||
<FONT color=gray>' ''Mostra quanti drive CD-ROM sono connessi al sistema:''</font> | <FONT color=gray>' ''Mostra quanti drive CD-ROM sono connessi al sistema:''</font> | ||
− | Print SDL_CDNumDrives() | + | Print "Drive CD-ROM connessi al sistema: "; SDL_CDNumDrives() |
For b = 0 To SDL_CDNumDrives() - 1 | For b = 0 To SDL_CDNumDrives() - 1 | ||
<FONT color=gray>' ''Mostra il "drive" CD-ROM connesso al sistema:''</font> | <FONT color=gray>' ''Mostra il "drive" CD-ROM connesso al sistema:''</font> | ||
− | Print "Drive CDROM connesso: "; SDL_CDName(b) | + | Print "Drive CDROM connesso: \e[1m"; SDL_CDName(b) |
Next | Next |
Versione delle 10:25, 16 ago 2020
Le funzioni esterne dell'API di SDL consentono di conoscere la lista dei drive CD-ROM connessi al sistema.
Per utilizzare le funzioni esterne dell'API di SDL sarà necessario richiamare l'attuale libreria "libSDL-1.2.so.0.11.4".
Mostriamo un semplice codice che consentirà di sapere la lista dei drive CD-ROM presenti nel sistema:
Library "libSDL-1.2:0.11.4" Private Const SDL_INIT_CDROM As Short = 256 ' 0x00000100 ' int SDL_Init(Uint32 flags) Private Extern SDL_Init(flags As Integer) As Integer ' char *SDL_GetError(void) ' returns a NULL terminated string containing information about the last internal SDL error. Private Extern SDL_GetError() As String ' int SDL_CDNumDrives(void) ' Returns the number of CD-ROM drives on the system. Private Extern SDL_CDNumDrives() As Integer ' const char *SDL_CDName(int drive) ' Returns a human-readable, system-dependent identifier for the CD-ROM. ' drive is the index of the drive. Drive indices start to 0 and end at SDL_CDNumDrives() - 1 Private Extern SDL_CDName(drive As Integer) As String ' void SDL_Quit(void) ' Clean up all initialized subsystems. Private Extern SDL_Quit() Public Sub Main() Dim b As Byte ' Inizializza la libreria libSDL, ed imposta il parametro relativo al CD-ROM: If SDL_Init(SDL_INIT_CDROM) < 0 Then Error.Raise("Impossibile inizializzare la libreria 'libSDL': " & SDL_GetError()) Endif ' Mostra quanti drive CD-ROM sono connessi al sistema: Print "Drive CD-ROM connessi al sistema: "; SDL_CDNumDrives() For b = 0 To SDL_CDNumDrives() - 1 ' Mostra il "drive" CD-ROM connesso al sistema: Print "Drive CDROM connesso: \e[1m"; SDL_CDName(b) Next SDL_Quit() End