PDA

Click to See Complete Forum and Search --> : Please solve my problem


santy
Aug 11th, 2001, 11:16 PM
Helloooo!

my problem is that i want my application to be run when the application in floppy and as i insert the floppy in floppy drive.


Thanks in advance.

Santy

beachbum
Aug 11th, 2001, 11:39 PM
Hi
Can't be 100% sure but i really dont think u can do that. U can autorun from CD.
Regards
Stuart

Kaverin
Aug 12th, 2001, 02:38 AM
You could try to access the file that you're trying to get to run from the A drive inside a timer, and when you can actually get the file, run it, but that's not really an elegant solution. The CD thing beachbum mentioned would be much better though.

totally unrelated note: beachbum, look deep into my avatar... could you wash my car? hehehe :D

TiPeRa
Aug 12th, 2001, 05:05 AM
I think it can be done. Xteq X-Setup has the option to autorun removable drives (diskettes, ZIP) etc. It use the registry path:

HKLM\System\CurrentControlSet\Services\Cdrom\Autorun

Here is all the code: (not sure if it works)

'HKLM\System\CurrentControlSet\Services\Cdrom\Autorun

'Declaration of some constants
DRIVE_UNKNOWN=1 'Bit 0
DRIVE_NO_ROOT=2 'Bit 1
DRIVE_REMOVABLE=4 'Bit 2
DRIVE_FIXED=8 'Bit 3
DRIVE_REMOTE=16 'Bit 4
DRIVE_CDROM=32 'Bit 5
DRIVE_RAMDISK=64 'Bit 6
DRIVE_FUTURE=128 'Bit 7

sPathValue="HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun"

'Called when the Plugin is started
SUB Plugin_Initialize
s=RegReadValue(sPathValue)

dim i
if len(s)>1 then
s=left(s,2)
i=s
else
i=CInt(0)
end if

'//Convert the value to INT
s="&H" & i
i=CInt(s)


'TH: Looks stupid, I know! but there is no way to get OR working with variants!
'AK: JScript ||. Should work

dim b1,b2,b3,b4,b5,b6,b7
i=OrHelper(i,DRIVE_FUTURE,b1)
i=OrHelper(i,DRIVE_RAMDISK,b2)
i=OrHelper(i,DRIVE_CDROM,b3)
i=OrHelper(i,DRIVE_REMOTE,b4)
i=OrHelper(i,DRIVE_FIXED,b5)
i=OrHelper(i,DRIVE_REMOVABLE,b6)
i=OrHelper(i,DRIVE_NO_ROOT,b7)


'//If the bit is set, AutoRun is DISABLED
Call SetBox(b3,1)
Call SetBox(b6,2)
Call SetBox(b5,3)
Call SetBox(b4,4)
END SUB

Function OrHelper(CurValue,CheckVal,CheckValSet)
i=CurValue

if i>=CheckVal then
CheckValSet=true
i=i-CheckVal
else
CheckValSet=false
end if

OrHelper=i
End Function

Sub SetBox(CurVal,Elm)
if CurVal=true then
SetUIElement elm,false
else
SetUIElement elm,true
end if
End Sub


'Called when the Plugin should validate the Data the user has entered
SUB Plugin_CheckData(ElementIndex)
END SUB

'Called when the Plugin should apply the changes
SUB Plugin_Apply(ElementIndex,ElementSubIndex)
i=0

'Always disable autorun for the following drives
'according to Q136214 from MS KB
i=i+DRIVE_UNKNOWN
i=i+DRIVE_FUTURE
'//Needed??? i=i+DRIVE_NO_ROOT


'No let's see what the user wants
if GetUIElement(1)=false then i=i+DRIVE_CDROM
if GetUIElement(2)=false then i=i+DRIVE_REMOVABLE
if GetUIElement(3)=false then i=i+DRIVE_FIXED
if GetUIElement(4)=false then i=i+DRIVE_REMOTE

'Convert to HEX so XSET can write the value
Dim v
v=Hex(i)
v=v & "000000"


Call RegWriteValue(sPathValue,v,3)
Call Restart
END SUB

'Called when the Plugin is about to be removed from memory
SUB Plugin_Terminate
END SUB

TiPeRa
Aug 12th, 2001, 05:07 AM
IMPORTANT: If you activate AutoRun for removable devices or network drives, Windows will check these drives every time you open the explorer or a file requester in an application. Because this check takes some time, this behavior can be really annoying. Please keep this in mind.