Определение 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:
    136
    Reputations:
    37
    Действие понятно :)
    PHP:
    unit Unit1;

    interface

    uses
    Windows
    MessagesSysUtilsVariantsClassesGraphicsControlsForms,
    DialogsStdCtrls;

    type
    TForm1 
    = class(TForm)
    Label1TLabel;
    private
    { Private 
    declarations }
    Procedure WindowProc(var Msg:TMessage); message WM_DEVICECHANGEstdcall;
    public
    { Public 
    declarations }
    function 
    DriveMaskToString(maskdword): 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_reservedDWORD;
    end;
    type
    PDEV_BROADCAST_VOLUME 
    = ^DEV_BROADCAST_VOLUME;
    DEV_BROADCAST_VOLUME record
    dbcv_size
    ,
    dbcv_devicetype,
    dbcv_reserved,
    dbcv_unitmaskDWORD;
    end;
    var
    Form1TForm1;
    implementation

    {$R *.dfm}

    TForm1 }
    procedure TForm1.WindowProc(var MsgTMessage);
    var 
    diskWORD;
    fsTFileStream;
    sAnsiString;
    disk1:string;
    begin
    case Msg.WParam of
    DBT_DEVICEARRIVAL
    //Åñëè ïîäêëþ÷èëè ôëýøêó
    if (PDEV_BROADCAST_HDR(Msg.LParam)^
    .
    dbch_devicetype DBT_DEVTYP_VOLUMEthen
    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(maskdword): string;
    var
    DriveLetterchar;
    Drives:string;
    i:integer;
    pom:integer;
    begin
    Drives 
    := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    := 0;
    pom := Trunc(mask 2);
    while (
    pom <> 0) do
    begin
    pom 
    := Trunc(pom 2);
    := i+1;
    end;
    if (
    Length(Drives)) then
    DriveLetter 
    := Drives[i+1]
    else
    DriveLetter := '?';
    result := DriveLetter ':\';
    end;

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