problems using aspi in delphi (part 2)

From: NARS (no_at_spam.plz)
Date: 11/30/03

  • Next message: Brian Cook: "Re: problems using aspi in delphi (part 2)"
    Date: Sun, 30 Nov 2003 05:57:10 -0000
    
    

    Hi,

    I had investigated more about my stange problem I posted already at some
    time ago, and I made a simple sample that raises similar stupid access
    violation...
    This code can only be runned at win9x!
    With original aspi drivers that come with win 95 or 98 it raises an access
    violation at returning from the function (if make some changes it can raise
    at different places...), but If I update aspi to 4.60 version for example,
    it works fine.
    Note: I tried to make same thing using VC++ and even with old (original)
    aspi version it works... but at delphi not...

    Thanks.

    Regards.

    Here is my sample:

    -------------------------
    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;

    type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    function SendASPI32Command(LPSRB : pointer) : DWORD; cdecl;

    implementation

    function SendASPI32Command; external 'WNASPI32';

    {$R *.DFM}

    type SRB_GetDiskInfo = packed record
            SRB_Cmd,
            SRB_Status,
            SRB_HaId,
            SRB_Flags : BYTE;
            SRB_Hdr_Rsvd : DWORD;
            SRB_Target,
            SRB_Lun,
            SRB_DriveFlags,
            SRB_Int13HDriveInfo,
            SRB_Heads,
            SRB_Sectors : BYTE;
            SRB_Rsvd1 : array [0..9] of byte;
         end;

    function getdriveletter(ha, id, lun : byte) : string;
    var srb : SRB_GetDiskInfo;
    begin
      FillChar(srb, sizeof(srb), 0);
      srb.SRB_Cmd := 6; //SC_GET_DISK_INFO
      srb.SRB_HaId := ha;
      srb.SRB_Target := id;
      srb.SRB_Lun := lun;
      SendASPI32Command(@srb);
      result := chr(ord('A') + srb.SRB_Int13HDriveInfo);
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      showmessage(getdriveletter(0,0,0));
    end;

    end.

    -------------------------


  • Next message: Brian Cook: "Re: problems using aspi in delphi (part 2)"