C 코드 예제, DISKINFO.C:
#include <windows.h>
#include <dos.h>
int CALLBACK LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
LPSTR lpszCmdLine)
// 다음은 윈도우 3.1에서만 필요한 UnlockData()이다
{
if (wHeapSize > 0)
UnlockData (0); //라이브러리의 데이터 세그먼트를 Unlocks
return 1;
}
void __export CALLBACK GetDiskInfo (char *cDrive, char *szVolumeName,
unsigned long *ulFreeSpace)
{
unsigned drive;
struct _diskfree_t driveinfo;
struct _find_t c_file;
_dos_getdrive (&drive);
_dos_getdiskfree( drive, &driveinfo );
if (!_dos_findfirst( "*.*", _A_VOLID, &c_file )) wsprintf( szVolumeName,
"%s", c_file.name);
else wsprintf ( szVolumeName, "NO LABEL");
*cDrive = drive + 'A' -1;
*ulFreeSpace = (unsigned long) driveinfo.avail_clusters * (unsigned
long) driveinfo.sectors_per_cluster * (unsigned long) driveinfo.bytes_per_sector;
}
DISKINFO.DEF 파일 예제
LIBRARY diskinfo
DESCRIPTION 'GetDiskInfo 는 VB에서 콜된다.
EXETYPE WINDOWS 3.1
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 4096
EXPORTS
GetDiskInfo @1