
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
SYSTEM
Search an application on a volume
Call FN FindAppOnVolume as follows:
OSErr = FN FindAppOnVolume(theVolume, theCreator&, @appSpec)
where theVolume is a volume reference number, theCreator& is the app's creator signature, and appSpec is an FSSpec record. If an app with the specified signature exists on the specified volume, the function will return its fsSpec info into appSpec, and will return zero into OSErr.
If you want to search on more than one volume, you can use FN HGETVINFO to find the vol. reference numbers for all mounted volumes, and call FN FindAppOnVolume with different vol. reference numbers until you get a zero result (or you run out of volumes).
'==== constants ====
_gvpInfoBufferSize = 20 'size of info buffer for GetVolParms
'For FN PBDTGetAPPL:
_ioIndex = 26
_ioFileCreator = 52
_ioAPPLParID = 100
'==== record structures ====
DIM RECORD fsSpec
DIM fsVRefNum%
DIM fsParID&
DIM 63 fsName$
DIM END RECORD .fsSpec
'====================
'-------------------------------------------
LOCAL FN PBDTGetAPPL(pBlkPtr&)
DIM OSErr
` move.l ^pBlkPtr&,a0 ;pblock
` moveq #$27,d0 ;selector
` dc.w $a260 ;HFSdispatch (sync)
` move.w d0,^OSErr
END FN = OSErr
'-------------------------------------------
LOCAL FN PBDTGetPath(pBlkPtr&)
DIM OSErr
` move.l ^pBlkPtr&,a0 ;pblock
` moveq #$20,d0 ;selector
` dc.w $a260 ;HFSdispatch (sync)
` move.w d0,^OSErr
END FN = OSErr
'-------------------------------------------
LOCAL FN PBHGetVolParms(pBlkPtr&)
DIM OSErr
` move.l ^pBlkPtr&,a0 ;pblock
` moveq #$30,d0 ;selector
` dc.w $a260 ;HFSdispatch (sync)
` move.w d0,^OSErr
END FN = OSErr
'-------------------------------------------
'-------------------------------------------
LOCAL FN FindAppOnVolume(theVolume, theCreator&, appSpecAddr&)
'Looks in the desktop database (if any) on the indicated volume
'and attempts to find the app whose creator signature is theCreator&.
'If such an app is found, an fsSpec record for the app is put into
'the record pointed to by appSpecAddr&. (If multiple versions of
'the app are found, the most recent one is used.)
DIM pb.44, getVParmsInfoBuffer.gvpInfoBufferSize, OSErr, dtpb.104
DIM 63 appName$
pb.ioCompletion& = _nil
pb.ioNamePtr& = _nil
pb.ioVRefNum% = theVolume
pb.ioBuffer& = @getVParmsInfoBuffer
pb.ioReqCount& = _gvpInfoBufferSize
OSErr = FN PBHGetVolParms(@pb)
LONG IF OSErr = _noErr
LONG IF (getVParmsInfoBuffer.vmAttrib& AND _bHasDeskTopMgr%) = 0
'This volume doesn't have a desktop DB:
OSErr = _paramErr
XELSE
'Volume supports Desktop Manager calls:
dtpb.ioNamePtr& = _nil
dtpb.ioVRefNum% = theVolume
OSErr = FN PBDTGetPath(@dtpb) 'fills ioDTRefNum field
LONG IF OSErr = _noErr
dtpb.ioCompletion& = _nil
dtpb.ioNamePtr& = @appName$
dtpb.ioIndex% = 0 'Get newest version of app.
dtpb.ioFileCreator& = theCreator&
OSErr = FN PBDTGetAPPL(@dtpb)
LONG IF OSErr = _noErr
appSpecAddr&.fsVRefNum% = theVolume
appSpecAddr&.fsParID& = dtpb.ioAPPLParID&
appSpecAddr&.fsName$ = appName$
END IF 'PBDTGetAPPL OSErr = _noErr
END IF 'PBDTGetPath OSErr = _noErr
END IF 'Volume supports Desktop Manager calls:
END IF 'PBHGetVolParms OSErr = _noErr
END FN = OSErr
'-------------------------------------------
|