哦,只是弹出阿,用CM_Request_Device_Eject函数,这样:
function TUsbManger.EjectOneUsb(Index: integer): boolean;
var
DeviceInfoData: TSPDevInfoData;
Status, Problem: DWord;
VetoType: TPNPVetoType;
VetoName: array[0..256] of Char;
begin
result:=false;
DeviceInfoData.cbSize := SizeOf(TSPDevInfoData);
VetoType:=PNP_VetoTypeUnknown;
if (not SetupDiEnumDeviceInfo(DevInfo, index, DeviceInfoData)) then exit;
if (CM_Get_DevNode_Status(@Status, @Problem, DeviceInfoData.DevInst, 0) <> CR_SUCCESS) then exit;
VetoName[0] := #0;
case CM_Request_Device_Eject(DeviceInfoData.DevInst, VetoType, @VetoName, SizeOf(VetoName), 0) of
CR_SUCCESS:
begin
//DevInfo := SetupDiGetClassDevs(nil, nil, 0, DIGCF_PRESENT or DIGCF_ALLCLASSES);
result:=true;
end;
end;
end;