Microsoft KB Archive/58177

= How to Open Macintosh QuickBASIC Data File with Shared Access =

Article ID: 58177

Article Last Modified on 11/21/2006



This article was previously published under Q58177



SUMMARY
Below is an example of how to open a data file with &quot;shared&quot; access from Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.



MORE INFORMATION
This program will not work on machines with 64K ROMs (pre-MacPlus).

WARNING: Because this routine temporarily changes the operating system, incorrect use can cause the system to crash or other adverse effects to occur. You should not make any major alterations to the code and should be very careful in its use.

Code Example
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< '>> The following code demonstrates a technique for opening a '>> file with shared access. It accomplishes this by patching '>> the _OPEN OS routine to force the ioPermssn to Shared. '>> WARNING - This is not a trivial technique. If a BASIC error '>> occurs while the _OPEN trap is patched, the machine MUST '>> be rebooted. Therefore, you should keep the code between the '>> patch & unpatch to a minimum. '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

DIM reg&(16),hpatch&, pPatch&, pOpen& GetTrapAddress%=&HA246 : SetTrapAddress%=&HA247 ToolBox &quot;i&quot; '=== Find out where the current _OPEN code is   ToolBox &quot;RQ&quot;,GetTrapAddress%,reg&(0),0,0,0 pOpen&=reg&(0) '==== Set up the patch NewHandle 12,hpatch& hLock hpatch& : pPatch&=PEEKL(hpatch&) PRINT HEX$(PEEKL(hpatch&)) POKEW pPatch&,&H117C       'Move.B #4,1B(a0) POKEW pPatch&+2,&H4        'immediate data POKEW pPatch&+4,&H1B       'reg offset POKEW pPatch&+6,&H4EF9     'jmp    OldOpenCode POKEL pPatch&+8,pOpen&     'Abs.L for jmp

'>>>>>>>>>>>>>>>>>>>> Start of Critical Section <<<<<<<<<<<<<<<<< '==== Install the patch for _OPEN ToolBox &quot;RQ&quot;,SetTrapAddress%,reg&(0),(pPatch&),0,0 '=== Opens a file with shared access. It must be opened with the '=== patch. '   OPEN &quot;Am.tmp2&quot; FOR INPUT AS 1

'==== Remove the patch ToolBox &quot;RQ&quot;,SetTrapAddress%,reg&(0),(pOpen&),0,0 '>>>>>>>>>>>>>>>>>>>> End of Critical Section <<<<<<<<<<<<<<<<<<<

'==== clean up   hunLock hpatch& DisposeHandle hpatch&

Additional query words: MQuickB

Keywords: KB58177

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.