This sample code will enumerate all the drivers on a local computer.
#define INCL_BASE #define INCL_DOSMEMMGR #define INCL_SPL #define INCL_SPLDOSPRINT #define INCL_SPLERRORS #include <os2.h> #include <stdio.h> /* for printf function */ INT main () { SPLERR splerr ; ULONG cbBuf ; ULONG cTotal ; ULONG cReturned ; ULONG cbNeeded ; ULONG i ; PSZ pszComputerName = NULL ; PSZ pszDriverName ; PBYTE pbuf ; /* Call the function the first time with zero in cbBuf. The count of bytes */ /* needed for the buffer to hold all the info will be returned in cbNeeded.*/ splerr = SplEnumDriver(pszComputerName, 0L, NULL, 0L, &cReturned, &cTotal, &cbNeeded, NULL ); /* If the return code is ERROR_MORE_DATA or NERR_BufTooSmall, then all the */ /* parameters were correct; and we can continue. */ if (splerr == ERROR_MORE_DATA || splerr == NERR_BufTooSmall) { /* Allocate memory for the buffer to hold the returned information. Use */ /* the count of bytes that were returned by our first call. */ if (!DosAllocMem( &pbuf, cbNeeded, PAG_READ|PAG_WRITE|PAG_COMMIT) ) { /* Set count of bytes to the value returned by our first call. */ cbBuf= cbNeeded ; /* Now call the function a second time with the correct values, and */ /* the information will be returned in the buffer. */ splerr= SplEnumDriver(pszComputerName, 0L, pbuf, cbBuf, &cReturned ,&cTotal, &cbNeeded, NULL ) ; if (splerr == NO_ERROR) { /* Set a pointer to point to the beginning of the buffer. */ pszDriverName = (PSZ)pbuf; /* Print the names that are in the buffer. The count of the number*/ /* of names in pBuf have been returned in cReturned. */ for (i=0;i < cReturned ; i++) { printf("Driver name - %s\n", pszDriverName) ; /* Increment the pointer to point to the next name. */ pszDriverName += DRIV_NAME_SIZE + DRIV_DEVICENAME_SIZE + 2; } } /* Free the memory allocated for the buffer. */ DosFreeMem(pbuf) ; } } else { /* If the first call to the function returned any error code other */ /* than ERROR_MORE_DATA or NERR_BufTooSmall, we print the following. */ printf("SplEnumDriver error=%ld \n",splerr) ; } DosExit( EXIT_PROCESS , 0 ) ; return (splerr); }