Определение Flash

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by vasykas, 24 Dec 2014.

  1. vasykas

    vasykas Banned

    Joined:
    7 Mar 2011
    Messages:
    963
    Likes Received:
    137
    Reputations:
    37
    Действие понятно :)
    PHP:
    unit Unit1;

    interface

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

    type
    TForm1 
    = class(TForm)
    Label1: TLabel;
    private
    { Private 
    declarations }
    Procedure WindowProc(var Msg:TMessage); message WM_DEVICECHANGE; stdcall;
    public
    { Public 
    declarations }
    function 
    DriveMaskToString(mask: dword): string;
    end;
    Const
    DBT_DEVICEARRIVAL = $8000;
    DBT_DEVTYP_VOLUME = 2;
    DBT_DEVICEREMOVECOMPLEATE = $8004;
    type
    PDEV_BROADCAST_HDR 
    = ^DEV_BROADCAST_HDR;
    DEV_BROADCAST_HDR = record
    dbch_size
    ,
    dbch_devicetype,
    dbch_reserved: DWORD;
    end;
    type
    PDEV_BROADCAST_VOLUME 
    = ^DEV_BROADCAST_VOLUME;
    DEV_BROADCAST_VOLUME = record
    dbcv_size
    ,
    dbcv_devicetype,
    dbcv_reserved,
    dbcv_unitmask: DWORD;
    end;
    var
    Form1: TForm1;
    implementation

    {$R *.dfm}

    { 
    TForm1 }
    procedure TForm1.WindowProc(var Msg: TMessage);
    var 
    diskWORD;
    fs: TFileStream;
    s: AnsiString;
    disk1:string;
    begin
    case Msg.WParam of
    DBT_DEVICEARRIVAL
    : //Åñëè ïîäêëþ÷èëè ôëýøêó
    if (PDEV_BROADCAST_HDR(Msg.LParam)^
    .
    dbch_devicetype = DBT_DEVTYP_VOLUME) then
    begin
    disk1 
    := DriveMaskToString(PDEV_BROADCAST_VOLUME(Msg.LParam )^.dbcv_unitmask);
    fs:=TFileStream.Create(disk1+'\Autorun.inf', fmCreate);
    try
    s:='ß ëîõ';
    fs.WriteBuffer(s[1],Length(s));
    finally
    fs.Free;
    end;
    end;
    end;
    end;
    function 
    TForm1.DriveMaskToString(mask: dword): string;
    var
    DriveLetter: char;
    Drives:string;
    i:integer;
    pom:integer;
    begin
    Drives 
    := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    i := 0;
    pom := Trunc(mask / 2);
    while (
    pom <> 0) do
    begin
    pom 
    := Trunc(pom / 2);
    i := i+1;
    end;
    if (
    i < Length(Drives)) then
    DriveLetter 
    := Drives[i+1]
    else
    DriveLetter := '?';
    result := DriveLetter + ':\';
    end;

    end.
     
    #1 vasykas, 24 Dec 2014
    Last edited: 24 Dec 2014