Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!crdgw1!ge-dab!tarpit!libcmp!sdgsun!lab From: lab@sdgsun.uucp (Larry Baird) Newsgroups: comp.windows.ms Subject: RE: registering a call in a DLL Message-ID: <1990Jul13.231427.4144@sdgsun.uucp> Date: 13 Jul 90 23:14:27 GMT Organization: SDG Group of SAIC COMSYSTEMS Lines: 61 There are a couple of tricks you need to apply. Register your new class from you DLL's init function. Have every application that uses your new class call a registeration and dereg function. In the reg function keep count of how many peple are using your class. In the dereg if this is last user you need to help windows and do a little clean up. Here's the code i use for reg and dereg. NOTE: Each should only be called once per applicatio. Hope this helps. static WORD wRefCount = 0; // Number of users void FAR PASCAL pgStartUp( void ) { LockData( 0 ); wRefCount++; UnlockData( 0 ); } void PASCAL FAR pgCleanUp( HANDLE hInstance ) { LockData( 0 ); if ( --wRefCount == 0 ) { HWND hWnd; HANDLE hModule; hWnd = CreateWindow ( PAGE_CLASS, // window class name NULL, // window caption 0L, // window style 0, // initial x position 0, // initial y position 0, // initial x size 0, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program handle NULL ); // create parameters UTIL_WIN_ASSERT( hWnd != NULL ); hModule = GetModuleHandle( MAKEINTRESOURCE( hInstance ) ); UTIL_WIN_ASSERT( hModule != NULL ); SetClassWord( hWnd, GCW_HMODULE, hModule ); DestroyWindow( hWnd ); } UnlockData( 0 ); } -- Larry A. Baird SAIC ComSystems, SDG division Manager, Software Development 450 N. Lakemont Avenue UUCP:ucf-cs!sdgsun!lab Winter Park, FL 32792 CIS: 72355,171 (407) 657-1300