问题描述
当你插入U盘的时候,计算机会弹出一个界面,显示有移动U盘存在.我想快点要这个程序,也有程序解析,谢谢!
解决方案
解决方案二:
$
解决方案三:
估计,是调用系统API了我没有做过,我一个同学做过。联系一下他看看能不能将代码发出来,不过是VB6了
解决方案四:
AttributeVB_Name="DevEject"OptionExplicitPrivateDeclareFunctionRegOpenKeyExLib"advapi32.dll"_Alias"RegOpenKeyExA"(_ByValhKeyAsLong,ByVallpSubKeyAsString,ByValulOptionsAsLong,_ByValsamDesiredAsLong,phkResultAsLong_)AsLongPrivateDeclareFunctionRegCloseKeyLib"advapi32.dll"(_ByValhKeyAsLong_)AsLongPrivateDeclareFunctionRegQueryValueExLib"advapi32.dll"_Alias"RegQueryValueExA"(_ByValhKeyAsLong,ByVallpValueNameAsString,ByVallpReservedAsLong,_lpTypeAsLong,lpDataAsAny,lpcbDataAsAny_)AsLongPrivateConstHKEY_LOCAL_MACHINEAsLong=&H80000002PrivateConstKEY_QUERY_VALUEAsLong=&H1PrivateConstKEY_ENUMERATE_SUB_KEYSAsLong=&H8PrivateConstKEY_NOTIFYAsLong=&H10PrivateConstSYNCHRONIZEAsLong=&H100000PrivateConstSTANDARD_RIGHTS_READAsLong=&H20000PrivateConstKEY_READAsLong=((STANDARD_RIGHTS_READOrKEY_QUERY_VALUEOrKEY_ENUMERATE_SUB_KEYSOrKEY_NOTIFY)And(NotSYNCHRONIZE))PrivateConstERROR_SUCCESSAsLong=0&PrivateDeclareFunctionCM_Request_Device_EjectALib"setupapi.dll"(_ByValhDeviceAsLong,lVetoTypeAsLong,lpVetoNameAsAny,_ByValcbVetoNameAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Locate_DevNodeALib"setupapi.dll"(_hDeviceAsLong,lpDeviceNameAsAny,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_Device_IDALib"setupapi.dll"(_ByValhDeviceAsLong,ByVallpIDBufferAsLong,_ByValcbIDBufferAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_Device_ID_SizeLib"setupapi.dll"(_ByReflSizeAsLong,ByValhDeviceAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_ParentLib"setupapi.dll"(_hParentDeviceAsLong,ByValhDeviceAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_ChildLib"setupapi.dll"(_hChildDeviceAsLong,ByValhDeviceAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_SiblingLib"setupapi.dll"(_hSiblingDeviceAsLong,ByValhDeviceAsLong,ByValdwFlagsAsLong_)AsLongPrivateDeclareFunctionCM_Get_DevNode_StatusLib"setupapi.dll"(_lStatusAsLong,lProblemAsLong,ByValhDeviceAsLong,_ByValdwFlagsAsLong_)AsLongPrivateConstDN_REMOVABLEAsLong=&H4000PrivateConstCR_SUCCESSAsLong=0PrivateConstREG_PATH_MOUNTAsString="SYSTEMMountedDevices"PrivateConstREG_VALUE_DOSDEVAsString="DosDevices"PublicFunctionEjectDevice(ByValDriveLetterAsString)AsBooleanDimstrDeviceInstanceAsStringDimbtRegData()AsByteDimhDeviceAsLongDimlngStatusAsLongDimlngProblemAsLongDriveLetter=UCase$(Left$(DriveLetter,1))&":"IfNotHKLMRegBinaryRead(REG_PATH_MOUNT,REG_VALUE_DOSDEV&DriveLetter,btRegData)ThenExitFunctionEndIfstrDeviceInstance=btRegDataIfNotLeft$(strDeviceInstance,4)="??"ThenExitFunctionstrDeviceInstance=Mid$(strDeviceInstance,5,InStr(1,strDeviceInstance,"{")-6)strDeviceInstance=Replace$(strDeviceInstance,"#","")IfCR_SUCCESS<>CM_Locate_DevNodeA(hDevice,ByValstrDeviceInstance,0)ThenExitFunctionEndIfIfCR_SUCCESS<>CM_Get_DevNode_Status(lngStatus,lngProblem,hDevice,0)ThenExitFunctionEndIfDoWhileNot(lngStatusAndDN_REMOVABLE)>0IfCR_SUCCESS<>CM_Get_Parent(hDevice,hDevice,0)ThenExitDoIfCR_SUCCESS<>CM_Get_DevNode_Status(lngStatus,lngProblem,hDevice,0)ThenExitDoLoopIf(lngStatusAndDN_REMOVABLE)>0ThenEjectDevice=CR_SUCCESS=CM_Request_Device_EjectA(hDevice,0,ByValSpace$(255),255,0)EndIfEndFunctionPrivateFunctionHandleToDeviceID(hDeviceAsLong)AsStringDimstrDeviceIDAsStringDimcDeviceIDAsLongIfCM_Get_Device_ID_Size(cDeviceID,hDevice,0)=0ThenstrDeviceID=Space(cDeviceID)IfCM_Get_Device_IDA(hDevice,StrPtr(strDeviceID),cDeviceID,0)>0ThenstrDeviceID=StrConv(strDeviceID,vbUnicode)strDeviceID=Left(strDeviceID,cDeviceID)ElsestrDeviceID=""EndIfEndIfHandleToDeviceID=strDeviceIDEndFunctionPrivateFunctionHKLMRegBinaryRead(ByValstrPathAsString,ByValstrValueNameAsString,btValue()AsByte)AsBooleanDimhKeyAsLongDimlngDataLenAsLongDimlngResultAsLongDimregTypeAsLongDimbtDataBuf()AsByteIfRegOpenKeyEx(HKEY_LOCAL_MACHINE,strPath,0,KEY_READ,hKey)=ERROR_SUCCESSThenIfRegQueryValueEx(hKey,strValueName,0,regType,ByVal0&,lngDataLen)=ERROR_SUCCESSThenReDimbtDataBuf(lngDataLen-1)AsByteIfRegQueryValueEx(hKey,strValueName,0,regType,btDataBuf(0),lngDataLen)=ERROR_SUCCESSThenbtValue=btDataBufHKLMRegBinaryRead=TrueEndIfEndIfRegCloseKeyhKeyEndIfEndFunction
这个是VB6的代码,使用的是API,因此你可以借鉴一下另外,可以看看有没有开源的,对USB炒作的类库看看