+short gCurrentResource = -1 ;
+
+wxStAppResource::wxStAppResource()
+{
+ m_currentRefNum = CurResFile() ;
+ if ( gCurrentResource != -1 )
+ {
+ UseResFile( gCurrentResource ) ;
+ }
+}
+
+wxStAppResource::~wxStAppResource()
+{
+ if ( m_currentRefNum != -1 )
+ {
+ UseResFile( m_currentRefNum ) ;
+ }
+}
+
+#ifdef WXMAKINGDLL
+
+// for shared libraries we have to manually get the correct resource ref num upon
+// initializing and releasing when terminating, therefore the __wxinitialize and __wxterminate
+// must be used
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void __sinit(void); /* (generated by linker) */
+pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
+pascal void __terminate(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+pascal OSErr __wxinitialize(const CFragInitBlock *theInitBlock)
+{
+ gCurrentResource = -1;
+
+ if (theInitBlock->fragLocator.where == kDataForkCFragLocator) {
+ gCurrentResource =
+ FSpOpenResFile(theInitBlock->fragLocator.u.onDisk.fileSpec,
+ fsRdPerm);
+ }
+ return __initialize( theInitBlock ) ;
+}
+
+pascal void __wxterminate(void)
+{
+ if (gCurrentResource != -1)
+ CloseResFile(gCurrentResource);
+ __terminate() ;
+}
+#endif
+
+int WXDLLEXPORT wxEntryStart( int argc, char *argv[] )