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.
(Creata pagina con '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...') |
|||
Riga 5: | Riga 5: | ||
Mostriamo un semplice codice che consentirà di sapere la lista dei ''drive'' CD-ROM presenti nel sistema: | Mostriamo un semplice codice che consentirà di sapere la lista dei ''drive'' CD-ROM presenti nel sistema: | ||
− | + | Private Const SDL_INIT_CDROM As Short = 256 <FONT color=gray>' ''0x00000100''</font> | |
Riga 12: | Riga 12: | ||
<FONT color=gray>' ''int SDL_Init(Uint32 flags)''</font> | <FONT color=gray>' ''int SDL_Init(Uint32 flags)''</font> | ||
− | + | Private Extern SDL_Init(flags As Integer) As Integer | |
<FONT color=gray>' ''char *SDL_GetError(void)'' | <FONT color=gray>' ''char *SDL_GetError(void)'' | ||
' ''returns a NULL terminated string containing information about the last internal SDL error.''</font> | ' ''returns a NULL terminated string containing information about the last internal SDL error.''</font> | ||
− | + | Private Extern SDL_GetError() As String | |
<FONT color=gray>' ''int SDL_CDNumDrives(void)'' | <FONT color=gray>' ''int SDL_CDNumDrives(void)'' | ||
' ''Returns the number of CD-ROM drives on the system.''</font> | ' ''Returns the number of CD-ROM drives on the system.''</font> | ||
− | + | Private Extern SDL_CDNumDrives() As Integer | |
<FONT color=gray>' ''const char *SDL_CDName(int drive)'' | <FONT color=gray>' ''const char *SDL_CDName(int drive)'' | ||
' ''Returns a human-readable, system-dependent identifier for the CD-ROM.'' | ' ''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''</font> | ' ''drive is the index of the drive. Drive indices start to 0 and end at SDL_CDNumDrives() - 1''</font> | ||
− | + | Private Extern SDL_CDName(drive As Integer) As String | |
Riga 31: | Riga 31: | ||
Dim j As Byte | Dim j As Byte | ||
− | |||
<FONT color=gray>' ''Inizializza la libreria libSDL, ed imposta il parametro relativo al CD-ROM:''</font> | <FONT color=gray>' ''Inizializza la libreria libSDL, ed imposta il parametro relativo al CD-ROM:''</font> | ||
− | + | If SDL_Init(SDL_INIT_CDROM) < 0 Then | |
− | + | Error.Raise("Impossibile inizializzare la libreria 'libSDL': " & SDL_GetError()) | |
− | + | Endif | |
− | + | ||
<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() | |
+ | |||
+ | For j = 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(j) | |
− | + | Next | |
− | + | ||
'''End''' | '''End''' |
Versione delle 10:15, 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:
Private Const SDL_INIT_CDROM As Short = 256 ' 0x00000100 Library "libSDL-1.2:0.11.4" ' 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 Public Sub Button1_Click() Dim j 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 SDL_CDNumDrives() For j = 0 To SDL_CDNumDrives() - 1 ' Mostra il "drive" CD-ROM connesso al sistema: Print "Drive CDROM connesso: "; SDL_CDName(j) Next End