Windows Programming Tips

From Lazarus-ccr

Jump to: navigation, search

This page is dedicated to desktop Windows programming tips.

Contents


[edit] Other Interfaces

[edit] Platform specific Tips

  • OS X Programming Tips - Lazarus installation, useful tools, Unix commands, and more...
  • WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
  • Windows Programming Tips - Desktop Windows programming tips.

[edit] Interfaces Development Articles

[edit] Code snipets

[edit] Listing all available drives

 
program listdevices;
 
{$ifdef fpc}{$mode delphi}{$endif}
{$apptype console}
 
uses
  Windows;
 
var
  Drive: Char;
  DriveLetter: string;
begin
  WriteLn('The following drives were found in this computer:');
  WriteLn('');
 
  // Search all drive letters
  for Drive := 'A' to 'Z' do
  begin
    DriveLetter := Drive + ':\';
 
    case GetDriveType(PChar(DriveLetter)) of
     DRIVE_REMOVABLE: WriteLn(DriveLetter + ' Floppy Drive');
     DRIVE_FIXED:     WriteLn(DriveLetter + ' Fixed Drive');
     DRIVE_REMOTE:    WriteLn(DriveLetter + ' Network Drive');
     DRIVE_CDROM:     WriteLn(DriveLetter + ' CD-ROM Drive');
     DRIVE_RAMDISK:   WriteLn(DriveLetter + ' RAM Disk');
    end;
  end;
 
  // Also add a stop to see the result under Windows
  WriteLn('');
  WriteLn('Please press <ENTER> to exit the program.');
  ReadLn(DriveLetter);
end.