Hi Daniel,

Date: Thu, 7 Apr 2011 17:20:51 -0300
From: daniel.franz...@gmail.com
To: lazarus@lists.lazarus.freepascal.org
Subject: Re: [Lazarus] Lazarus errors -- DVD procedure identifiers.

>It seems that these functions and constants you are using are from Windows 
>unit.
>Did you tried to include it in your uses clause?

I need to get this working for Linux and cross-platform compiling. Is there a 
Linux equivalent of these procedures?
I think that maybe I can replace "ZeroMemory" with "FillChar"... what is the 
syntax?
What about GetDriveType, DRIVE_CDROM and DeviceIoControl ? Also what is the 
syntax for the Linux versions (cross platform) of these?
Best Regards,Peter / pew
2011/4/7 Peter Williams <pewilliams2...@live.com>






Hi All,
I have a legacy Delphi 7 project which works fine in D7, but it gives these 
errors in Lazarus 0.9.31.

Options changed, recompiling clean with -BHint: Start of reading config file 
/etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfgFree Pascal Compiler version 
2.4.2-0 [2010/11/11] for i386
Copyright (c) 1993-2010 by Florian KlaempflTarget OS: Linux for i386Compiling 
Project1.lpr
Compiling DVDregion1.pasDVDregion1.pas(62,13) Error: Identifier not found 
"ZeroMemory"DVDregion1.pas(63,21) Error: Identifier not found "GetDriveType"
DVDregion1.pas(65,23) Error: Identifier not found 
"DRIVE_CDROM"DVDregion1.pas(76,28) Error: Identifier not found "DeviceIoControl"
DVDregion1.pas(115) Fatal: There were 4 errors compiling module, stopping   


unit DVDregion1;
{$MODE Delphi}

interface
uses  LCLIntf, LCLType, LMessages, Classes, SysUtils, Forms, StdCtrls, Controls;

type  DVD_REGION = record    CopySystem,
      RegionData, // current media region    SystemRegion, // current drive 
region    ResetCount: Byte;
  end;  PDVD_REGION = ^DVD_REGION;
const
  IOCTL_DVD_GET_REGION = $335014;
type  TForm1 = class(TForm)
    Memo1: TMemo;    Button1: TButton;    procedure Button1Click(Sender: 
TObject);
  private    { Private declarations }  public    { Public declarations }
  end;
var  Form1: TForm1;

implementation
{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);const  drive_letter = 'H:';
  RegionStrings: array[0..8] of string = (    ' 0 --- No Region Code - works in 
any DVD player',    ' 1 --- United States of America, Canada',
    ' 2 --- Europe, France, Greece, Turkey, Egypt, Arabia, Japan and South 
Africa',    ' 3 --- Korea, Thailand, Vietnam, Borneo and Indonesia',
    ' 4 --- Australia, New Zealand, Mexico, the Caribbean, and South America',  
  ' 5 --- India, Africa, Russia and former USSR countries',
    ' 6 --- Peoples Republic of China',    ' 7 --- Unused',    ' 8 --- Airlines 
and Cruise Ships');
var  handle: THandle;  rv, Region2Check: Integer;  region: DVD_REGION;
  dw: DWORD;  status: Boolean;  Mask: byte;begin
  Memo1.Clear;  ZeroMemory(@region, SizeOf(DVD_REGION));  rv := 
GetDriveType(drive_letter);

  if rv = DRIVE_CDROM then    Memo1.Lines.Add('Drive is a CD/DVD drive');

  handle := FileCreate('\\.\' + drive_letter); { *Converted from CreateFile*  }

  if handle = INVALID_HANDLE_VALUE then  begin    Memo1.Lines.Add('Cannot open 
the drive');
    Exit;  end;
  status := DeviceIoControl(
    handle, // handle to device    IOCTL_DVD_GET_REGION, // dwIoControlCode    
nil, // lpInBuffer
    0, // nInBufferSize    @region, // output buffer    SizeOf(DVD_REGION), // 
buffer size
    dw, // number of bytes returned    nil);
  if not status then
  begin    FileClose(handle); { *Converted from CloseHandle*  }    
Memo1.Lines.Add('DevIoControl Failed');
    Exit;  end;
  Memo1.Lines.Add('The Region and Code for this DVD :');
  Memo1.Lines.Add('');  Memo1.Lines.Add('Code - Region');

  if region.RegionData and $3F = 0 then    Memo1.Lines.Add(RegionStrings[0])  
else
  begin    Mask := 1;    for Region2Check := 1 to 8 do    begin
      if region.RegionData and Mask = 0 then        
Memo1.Lines.Add(RegionStrings[Region2Check]);      Mask := Mask shl 1;
    end;  end;
  FileClose(handle); { *Converted from CloseHandle*  }
end;
end.

Best Regards,Peter E Williams

                                          

--

_______________________________________________

Lazarus mailing list

Lazarus@lists.lazarus.freepascal.org

http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




-- 
Daniel

"Let us change our traditional attitude to the construction of programs. 
Instead of imagining that our main task is to instruct a computer what to do, 
let us concentrate rather on explaining to human beings what we want a computer 
to do." (Donald Knuth)


"Yes, technogeeks can be funny, even if only to each other." 
(http://www.boogieonline.com/revolution/science/humor/)"

"Man is driven to create; I know I really love to create things. And while I'm 
not good at painting, drawing, or music, I can write software." (Yukihiro 
Matsumoto, a.k.a. ``Matz'')




--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus                    
                  
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to