Loading
1

[U盘操作]一键弹出

DriveGet, list, list
loop,Parse,list
{
    ; 设定为你想弹出的驱动器的标号。
    popDriver:=A_LoopField . ":"
    DriveGet, type, type, %popDriver%
    ; 如果是移动磁盘,则执行弹出操作
    if(type == "Removable")
    {
        hVolume := DllCall("CreateFile", Str, "\\.\" . popDriver
        , UInt, 0x80000000 | 0x40000000
        , UInt, 0x1 | 0x2
        , UInt, 0
        , UInt, 0x3
        , UInt, 0, UInt, 0)
        if hVolume <> -1
        {
            DllCall("DeviceIoControl", UInt, hVolume , UInt, 0x2D4808
                , UInt, 0, UInt, 0, UInt, 0, UInt, 0 , UIntP, dwBytesReturned    
                , UInt, 0)
            DllCall("CloseHandle", UInt, hVolume)
        }
    }
}

 

本文为原创文章,未经同意禁止转载!!